22
33namespace Limenius \ReactRenderer \Tests \Renderer ;
44
5- use Limenius \ReactRenderer \Renderer \PhpExecJsReactRenderer ;
65use Limenius \ReactRenderer \Context \ContextProviderInterface ;
7- use Psr \Log \LoggerInterface ;
6+ use Limenius \ReactRenderer \Exception \EvalJsException ;
7+ use Limenius \ReactRenderer \Renderer \PhpExecJsReactRenderer ;
88use Nacmartin \PhpExecJs \PhpExecJs ;
9+ use PHPUnit \Framework \Exception ;
910use PHPUnit \Framework \TestCase ;
11+ use Psr \Log \LoggerInterface ;
1012use Psr \Log \LogLevel ;
1113
1214/**
@@ -32,7 +34,7 @@ class PhpExecJsReactRendererTest extends TestCase
3234 /**
3335 * {@inheritdoc}
3436 */
35- public function setUp ()
37+ public function setUp (): void
3638 {
3739 $ this ->logger = $ this ->getMockBuilder (LoggerInterface::class)
3840 ->getMock ();
@@ -47,11 +49,9 @@ public function setUp()
4749 $ this ->renderer ->setPhpExecJs ($ this ->phpExecJs );
4850 }
4951
50- /**
51- * @expectedException \RuntimeException
52- */
5352 public function testServerBundleNotFound ()
5453 {
54+ $ this ->expectException (\RuntimeException::class);
5555 $ this ->renderer = new PhpExecJsReactRenderer (__DIR__ .'/Fixtures/i-dont-exist.js ' , $ this ->logger , $ this ->contextProvider );
5656 $ this ->renderer ->render ('MyApp ' , 'props ' , 1 , null , false );
5757 }
@@ -109,9 +109,6 @@ public function testReactOnRails()
109109 $ this ->renderer ->render ('MyApp ' , '{msg:"It Works!"} ' , 1 , null , true ));
110110 }
111111
112- /**
113- * @expectedException \Limenius\ReactRenderer\Exception\EvalJsException
114- */
115112 public function testFailLoud ()
116113 {
117114 $ phpExecJs = $ this ->getMockBuilder (PhpExecJs::class)
@@ -120,6 +117,7 @@ public function testFailLoud()
120117 ->willReturn ('{ "html" : "go for it", "hasErrors" : true, "consoleReplayScript": " - my replay"} ' );
121118 $ this ->renderer = new PhpExecJsReactRenderer (__DIR__ .'/Fixtures/server-bundle.js ' , true , $ this ->contextProvider , $ this ->logger );
122119 $ this ->renderer ->setPhpExecJs ($ phpExecJs );
120+ $ this ->expectException (EvalJsException::class);
123121 $ this ->renderer ->render ('MyApp ' , 'props ' , 1 , null , true );
124122 }
125123
@@ -128,7 +126,7 @@ public function testFailLoud()
128126 */
129127 public function testFailLoudBubblesThrownException ()
130128 {
131- $ err = new \ Exception ('test exception ' );
129+ $ err = new Exception ('test exception ' );
132130 $ this ->phpExecJs ->method ('createContext ' )->willThrowException ($ err );
133131 $ this ->renderer = new PhpExecJsReactRenderer (__DIR__ .'/Fixtures/server-bundle.js ' , true , $ this ->contextProvider , $ this ->logger );
134132 $ this ->renderer ->setPhpExecJs ($ this ->phpExecJs );
@@ -159,7 +157,7 @@ public function testFailQuietReturnsEmptyErrorResultOnException()
159157 */
160158 public function testFailQuietLogsThrownExceptions ()
161159 {
162- $ err = new \ Exception ('test exception ' );
160+ $ err = new Exception ('test exception ' );
163161 $ this ->phpExecJs ->method ('createContext ' )->willThrowException ($ err );
164162
165163 $ this ->logger
0 commit comments