16
16
use PHPUnit \Framework \TestCase ;
17
17
use PHPJasper \PHPJasper ;
18
18
use PHPJasper \Exception ;
19
+ use ReflectionObject ;
19
20
20
21
/**
21
22
* @author Rafael Queiroz <rafaelfqf@gmail.com>
@@ -34,30 +35,35 @@ public function tearDown()
34
35
unset($ this ->instance );
35
36
}
36
37
37
- public function testConstructor ()
38
+ /** @test */
39
+ public function constructor ()
38
40
{
39
41
$ this ->assertInstanceOf (PHPJasper::class, new PHPJasper ());
40
42
}
41
43
42
- public function testCompile ()
44
+ /** @test */
45
+ public function compile ()
43
46
{
44
47
$ result = $ this ->instance ->compile ('examples/hello_world.jrxml ' , '{output_file} ' );
45
48
46
49
$ expected = '.*jasperstarter compile ".*hello_world.jrxml" -o "{output_file}" ' ;
47
50
48
- $ this ->expectOutputRegex ('/ ' . $ expected. '/ ' , $ result ->output ());
51
+ $ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ result ->output ());
49
52
}
50
53
51
- public function testProcess ()
54
+
55
+ /** @test */
56
+ public function process ()
52
57
{
53
58
$ result = $ this ->instance ->process ('examples/hello_world.jrxml ' , '{output_file} ' );
54
59
55
60
$ expected = '.*jasperstarter process ".*hello_world.jrxml" -o "{output_file}" ' ;
56
61
57
- $ this ->expectOutputRegex ('/ ' . $ expected. '/ ' , $ result ->output ());
62
+ $ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ result ->output ());
58
63
}
59
64
60
- public function testProcessWithOptions ()
65
+ /** @test */
66
+ public function processWithOptions ()
61
67
{
62
68
$ options = [
63
69
'locale ' => 'en_US ' ,
@@ -79,37 +85,35 @@ public function testProcessWithOptions()
79
85
$ expected = '.*jasperstarter --locale en_US process ".*hello_world.jrxml" -o "{output_file}" ' ;
80
86
$ expected .= '-f pdf -P param_1="value_1" param_2="value_2" -t driver -u user -p 12345678 -n db -r foo ' ;
81
87
82
- $ this ->expectOutputRegex (
83
- '/ ' .$ expected .'/ ' ,
84
- $ result ->output ()
85
- );
88
+ $ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ result ->output ());
86
89
}
87
90
88
- public function testListParameters ()
91
+ /** @test */
92
+ public function listParameters ()
89
93
{
90
94
$ result = $ this ->instance ->listParameters ('examples/hello_world.jrxml ' );
91
95
92
- $ this ->expectOutputRegex (
93
- '/.*jasperstarter list_parameters ".*hello_world.jrxml"/ ' ,
94
- $ result ->output ()
95
- );
96
+ $ this ->expectOutputRegex ('/.*jasperstarter list_parameters ".*hello_world.jrxml"/ ' , $ result ->output ());
96
97
}
97
98
98
- public function testCompileWithWrongInput ()
99
+ /** @test */
100
+ public function compileWithWrongInput ()
99
101
{
100
102
$ this ->expectException (Exception \InvalidInputFile::class);
101
103
102
104
$ this ->instance ->compile ('' );
103
105
}
104
106
105
- public function testCompileHelloWorld ()
107
+ /** @test */
108
+ public function compileHelloWorld ()
106
109
{
107
110
$ result = $ this ->instance ->compile ('examples/hello_world.jrxml ' );
108
111
109
112
$ this ->expectOutputRegex ('/.*jasperstarter compile ".*hello_world.jrxml"/ ' , $ result ->output ());
110
113
}
111
114
112
- public function testOutputWithUserOnExecute ()
115
+ /** @test */
116
+ public function outputWithUserOnExecute ()
113
117
{
114
118
$ this ->expectException (Exception \ErrorCommandExecutable::class);
115
119
@@ -120,37 +124,42 @@ public function testOutputWithUserOnExecute()
120
124
$ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ this ->instance ->output ());
121
125
}
122
126
123
- public function testExecuteWithoutCompile ()
127
+ /** @test */
128
+ public function executeWithoutCompile ()
124
129
{
125
130
$ this ->expectException (Exception \InvalidCommandExecutable::class);
126
131
127
132
$ this ->instance ->execute ();
128
133
}
129
134
130
- public function testInvalidInputFile ()
135
+ /** @test */
136
+ public function invalidInputFile ()
131
137
{
132
138
$ this ->expectException (Exception \InvalidInputFile::class);
133
139
134
140
$ this ->instance ->compile ('{invalid} ' )->execute ();
135
141
}
136
142
137
- public function testExecute ()
143
+ /** @test */
144
+ public function execute ()
138
145
{
139
146
$ actual = $ this ->instance ->compile (__DIR__ . '/test.jrxml ' )->execute ();
140
147
141
148
$ this ->assertInternalType ('array ' , $ actual );
142
149
}
143
150
144
- public function testExecuteWithOutput ()
151
+ /** @test */
152
+ public function executeWithOutput ()
145
153
{
146
154
$ actual = $ this ->instance ->compile (__DIR__ . '/test.jrxml ' , __DIR__ . '/test ' )->execute ();
147
155
148
156
$ this ->assertInternalType ('array ' , $ actual );
149
157
}
150
158
151
- public function testExecuteThrowsInvalidResourceDirectory ()
159
+ /** @test */
160
+ public function executeThrowsInvalidResourceDirectory ()
152
161
{
153
- $ reflectionObject = new \ ReflectionObject ($ this ->instance );
162
+ $ reflectionObject = new ReflectionObject ($ this ->instance );
154
163
$ reflectionProperty = $ reflectionObject ->getProperty ('pathExecutable ' );
155
164
$ reflectionProperty ->setAccessible (true );
156
165
$ reflectionProperty ->setValue ($ this ->instance , '' );
@@ -160,28 +169,39 @@ public function testExecuteThrowsInvalidResourceDirectory()
160
169
$ this ->instance ->compile (__DIR__ . '/test.jrxml ' , __DIR__ . '/test ' )->execute ();
161
170
}
162
171
163
- public function testListParametersWithWrongInput ()
172
+ /** @test */
173
+ public function listParametersWithWrongInput ()
164
174
{
165
175
$ this ->expectException (Exception \InvalidInputFile::class);
166
176
167
177
$ this ->instance ->listParameters ('' );
168
178
}
169
179
170
- public function testProcessWithWrongInput ()
180
+ /** @test */
181
+ public function processWithWrongInput ()
171
182
{
172
183
$ this ->expectException (Exception \InvalidInputFile::class);
173
184
174
- $ this ->instance ->process ('' , '' , [
175
- 'format ' => 'mp3 '
176
- ]);
185
+ $ this ->instance ->process (
186
+ '' ,
187
+ '' ,
188
+ [
189
+ 'format ' => 'mp3 '
190
+ ]
191
+ );
177
192
}
178
193
179
- public function testProcessWithWrongFormat ()
194
+ /** @test */
195
+ public function processWithWrongFormat ()
180
196
{
181
197
$ this ->expectException (Exception \InvalidFormat::class);
182
198
183
- $ this ->instance ->process ('hello_world.jrxml ' , '' , [
184
- 'format ' => 'mp3 '
185
- ]);
199
+ $ this ->instance ->process (
200
+ 'hello_world.jrxml ' ,
201
+ '' ,
202
+ [
203
+ 'format ' => 'mp3 '
204
+ ]
205
+ );
186
206
}
187
207
}
0 commit comments