1616use PHPUnit \Framework \TestCase ;
1717use PHPJasper \PHPJasper ;
1818use PHPJasper \Exception ;
19+ use ReflectionObject ;
1920
2021/**
2122 * @author Rafael Queiroz <rafaelfqf@gmail.com>
@@ -34,30 +35,35 @@ public function tearDown()
3435 unset($ this ->instance );
3536 }
3637
37- public function testConstructor ()
38+ /** @test */
39+ public function constructor ()
3840 {
3941 $ this ->assertInstanceOf (PHPJasper::class, new PHPJasper ());
4042 }
4143
42- public function testCompile ()
44+ /** @test */
45+ public function compile ()
4346 {
4447 $ result = $ this ->instance ->compile ('examples/hello_world.jrxml ' , '{output_file} ' );
4548
4649 $ expected = '.*jasperstarter compile ".*hello_world.jrxml" -o "{output_file}" ' ;
4750
48- $ this ->expectOutputRegex ('/ ' . $ expected. '/ ' , $ result ->output ());
51+ $ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ result ->output ());
4952 }
5053
51- public function testProcess ()
54+
55+ /** @test */
56+ public function process ()
5257 {
5358 $ result = $ this ->instance ->process ('examples/hello_world.jrxml ' , '{output_file} ' );
5459
5560 $ expected = '.*jasperstarter process ".*hello_world.jrxml" -o "{output_file}" ' ;
5661
57- $ this ->expectOutputRegex ('/ ' . $ expected. '/ ' , $ result ->output ());
62+ $ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ result ->output ());
5863 }
5964
60- public function testProcessWithOptions ()
65+ /** @test */
66+ public function processWithOptions ()
6167 {
6268 $ options = [
6369 'locale ' => 'en_US ' ,
@@ -79,37 +85,35 @@ public function testProcessWithOptions()
7985 $ expected = '.*jasperstarter --locale en_US process ".*hello_world.jrxml" -o "{output_file}" ' ;
8086 $ expected .= '-f pdf -P param_1="value_1" param_2="value_2" -t driver -u user -p 12345678 -n db -r foo ' ;
8187
82- $ this ->expectOutputRegex (
83- '/ ' .$ expected .'/ ' ,
84- $ result ->output ()
85- );
88+ $ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ result ->output ());
8689 }
8790
88- public function testListParameters ()
91+ /** @test */
92+ public function listParameters ()
8993 {
9094 $ result = $ this ->instance ->listParameters ('examples/hello_world.jrxml ' );
9195
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 ());
9697 }
9798
98- public function testCompileWithWrongInput ()
99+ /** @test */
100+ public function compileWithWrongInput ()
99101 {
100102 $ this ->expectException (Exception \InvalidInputFile::class);
101103
102104 $ this ->instance ->compile ('' );
103105 }
104106
105- public function testCompileHelloWorld ()
107+ /** @test */
108+ public function compileHelloWorld ()
106109 {
107110 $ result = $ this ->instance ->compile ('examples/hello_world.jrxml ' );
108111
109112 $ this ->expectOutputRegex ('/.*jasperstarter compile ".*hello_world.jrxml"/ ' , $ result ->output ());
110113 }
111114
112- public function testOutputWithUserOnExecute ()
115+ /** @test */
116+ public function outputWithUserOnExecute ()
113117 {
114118 $ this ->expectException (Exception \ErrorCommandExecutable::class);
115119
@@ -120,37 +124,42 @@ public function testOutputWithUserOnExecute()
120124 $ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ this ->instance ->output ());
121125 }
122126
123- public function testExecuteWithoutCompile ()
127+ /** @test */
128+ public function executeWithoutCompile ()
124129 {
125130 $ this ->expectException (Exception \InvalidCommandExecutable::class);
126131
127132 $ this ->instance ->execute ();
128133 }
129134
130- public function testInvalidInputFile ()
135+ /** @test */
136+ public function invalidInputFile ()
131137 {
132138 $ this ->expectException (Exception \InvalidInputFile::class);
133139
134140 $ this ->instance ->compile ('{invalid} ' )->execute ();
135141 }
136142
137- public function testExecute ()
143+ /** @test */
144+ public function execute ()
138145 {
139146 $ actual = $ this ->instance ->compile (__DIR__ . '/test.jrxml ' )->execute ();
140147
141148 $ this ->assertInternalType ('array ' , $ actual );
142149 }
143150
144- public function testExecuteWithOutput ()
151+ /** @test */
152+ public function executeWithOutput ()
145153 {
146154 $ actual = $ this ->instance ->compile (__DIR__ . '/test.jrxml ' , __DIR__ . '/test ' )->execute ();
147155
148156 $ this ->assertInternalType ('array ' , $ actual );
149157 }
150158
151- public function testExecuteThrowsInvalidResourceDirectory ()
159+ /** @test */
160+ public function executeThrowsInvalidResourceDirectory ()
152161 {
153- $ reflectionObject = new \ ReflectionObject ($ this ->instance );
162+ $ reflectionObject = new ReflectionObject ($ this ->instance );
154163 $ reflectionProperty = $ reflectionObject ->getProperty ('pathExecutable ' );
155164 $ reflectionProperty ->setAccessible (true );
156165 $ reflectionProperty ->setValue ($ this ->instance , '' );
@@ -160,28 +169,39 @@ public function testExecuteThrowsInvalidResourceDirectory()
160169 $ this ->instance ->compile (__DIR__ . '/test.jrxml ' , __DIR__ . '/test ' )->execute ();
161170 }
162171
163- public function testListParametersWithWrongInput ()
172+ /** @test */
173+ public function listParametersWithWrongInput ()
164174 {
165175 $ this ->expectException (Exception \InvalidInputFile::class);
166176
167177 $ this ->instance ->listParameters ('' );
168178 }
169179
170- public function testProcessWithWrongInput ()
180+ /** @test */
181+ public function processWithWrongInput ()
171182 {
172183 $ this ->expectException (Exception \InvalidInputFile::class);
173184
174- $ this ->instance ->process ('' , '' , [
175- 'format ' => 'mp3 '
176- ]);
185+ $ this ->instance ->process (
186+ '' ,
187+ '' ,
188+ [
189+ 'format ' => 'mp3 '
190+ ]
191+ );
177192 }
178193
179- public function testProcessWithWrongFormat ()
194+ /** @test */
195+ public function processWithWrongFormat ()
180196 {
181197 $ this ->expectException (Exception \InvalidFormat::class);
182198
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+ );
186206 }
187207}
0 commit comments