2
2
3
3
namespace Limenius \ReactRenderer \Tests \Renderer ;
4
4
5
- use Limenius \ReactRenderer \Renderer \PhpExecJsReactRenderer ;
6
5
use Limenius \ReactRenderer \Context \ContextProviderInterface ;
7
- use Psr \Log \LoggerInterface ;
6
+ use Limenius \ReactRenderer \Exception \EvalJsException ;
7
+ use Limenius \ReactRenderer \Renderer \PhpExecJsReactRenderer ;
8
8
use Nacmartin \PhpExecJs \PhpExecJs ;
9
+ use PHPUnit \Framework \Exception ;
9
10
use PHPUnit \Framework \TestCase ;
11
+ use Psr \Log \LoggerInterface ;
10
12
use Psr \Log \LogLevel ;
11
13
12
14
/**
@@ -32,7 +34,7 @@ class PhpExecJsReactRendererTest extends TestCase
32
34
/**
33
35
* {@inheritdoc}
34
36
*/
35
- public function setUp ()
37
+ public function setUp (): void
36
38
{
37
39
$ this ->logger = $ this ->getMockBuilder (LoggerInterface::class)
38
40
->getMock ();
@@ -47,11 +49,9 @@ public function setUp()
47
49
$ this ->renderer ->setPhpExecJs ($ this ->phpExecJs );
48
50
}
49
51
50
- /**
51
- * @expectedException \RuntimeException
52
- */
53
52
public function testServerBundleNotFound ()
54
53
{
54
+ $ this ->expectException (\RuntimeException::class);
55
55
$ this ->renderer = new PhpExecJsReactRenderer (__DIR__ .'/Fixtures/i-dont-exist.js ' , $ this ->logger , $ this ->contextProvider );
56
56
$ this ->renderer ->render ('MyApp ' , 'props ' , 1 , null , false );
57
57
}
@@ -109,9 +109,6 @@ public function testReactOnRails()
109
109
$ this ->renderer ->render ('MyApp ' , '{msg:"It Works!"} ' , 1 , null , true ));
110
110
}
111
111
112
- /**
113
- * @expectedException \Limenius\ReactRenderer\Exception\EvalJsException
114
- */
115
112
public function testFailLoud ()
116
113
{
117
114
$ phpExecJs = $ this ->getMockBuilder (PhpExecJs::class)
@@ -120,6 +117,7 @@ public function testFailLoud()
120
117
->willReturn ('{ "html" : "go for it", "hasErrors" : true, "consoleReplayScript": " - my replay"} ' );
121
118
$ this ->renderer = new PhpExecJsReactRenderer (__DIR__ .'/Fixtures/server-bundle.js ' , true , $ this ->contextProvider , $ this ->logger );
122
119
$ this ->renderer ->setPhpExecJs ($ phpExecJs );
120
+ $ this ->expectException (EvalJsException::class);
123
121
$ this ->renderer ->render ('MyApp ' , 'props ' , 1 , null , true );
124
122
}
125
123
@@ -128,7 +126,7 @@ public function testFailLoud()
128
126
*/
129
127
public function testFailLoudBubblesThrownException ()
130
128
{
131
- $ err = new \ Exception ('test exception ' );
129
+ $ err = new Exception ('test exception ' );
132
130
$ this ->phpExecJs ->method ('createContext ' )->willThrowException ($ err );
133
131
$ this ->renderer = new PhpExecJsReactRenderer (__DIR__ .'/Fixtures/server-bundle.js ' , true , $ this ->contextProvider , $ this ->logger );
134
132
$ this ->renderer ->setPhpExecJs ($ this ->phpExecJs );
@@ -159,7 +157,7 @@ public function testFailQuietReturnsEmptyErrorResultOnException()
159
157
*/
160
158
public function testFailQuietLogsThrownExceptions ()
161
159
{
162
- $ err = new \ Exception ('test exception ' );
160
+ $ err = new Exception ('test exception ' );
163
161
$ this ->phpExecJs ->method ('createContext ' )->willThrowException ($ err );
164
162
165
163
$ this ->logger
0 commit comments