Arbit - project tracking

PHP Depend

History

Diff

1113 1114 /tests/PHP/Depend/TextUI/RunnerTest.php
71 71 * directory.
72 72 *
73 73 * @return void
74 + * @covers PHP_Depend_TextUI_Runner
75 + * @group pdepend
76 + * @group pdepend::textui
77 + * @group unittest
74 78 */
75 79 public function testRunnerThrowsRuntimeExceptionForInvalidSourceDirectory()
76 80 {
90 94 * Tests that the runner stops processing if no logger is specified.
91 95 *
92 96 * @return void
97 + * @covers PHP_Depend_TextUI_Runner
98 + * @group pdepend
99 + * @group pdepend::textui
100 + * @group unittest
93 101 */
94 102 public function testRunnerThrowsRuntimeExceptionIfNoLoggerIsSpecified()
95 103 {
105 113 $runner->run();
106 114 }
107 115
116 + /**
117 + * testRunnerUsesCorrectFileFilter
118 + *
119 + * @return void
120 + * @covers PHP_Depend_TextUI_Runner
121 + * @group pdepend
122 + * @group pdepend::textui
123 + * @group unittest
124 + */
108 125 public function testRunnerUsesCorrectFileFilter()
109 126 {
110 127 $fileName = self::createRunResourceURI('pdepend.dummy');
111 - if (file_exists($fileName)) {
112 - unlink($fileName);
113 - }
114 128
115 129 $runner = new PHP_Depend_TextUI_Runner();
116 130 $runner->setSourceArguments(array(dirname(__FILE__). '/../_code'));
126 140 $code = $data['code'];
127 141 $this->assertEquals(3, $code->count());
128 142
129 - $code->rewind();
143 + foreach ($code as $package) {
144 + if ($package->getName() === 'pdepend.test') {
145 + $this->assertEquals(1, $package->getFunctions()->count());
146 + $this->assertEquals(1, $package->getClasses()->count());
130 147
131 - $package = $code->current();
132 - $this->assertEquals('pdepend.test', $package->getName());
133 -
134 - $this->assertEquals(1, $package->getFunctions()->count());
135 - $this->assertEquals(1, $package->getClasses()->count());
136 -
137 - $function = $package->getFunctions()->current();
138 - $this->assertEquals('foo', $function->getName());
139 - $this->assertEquals(1, $function->getExceptionClasses()->count());
140 - $this->assertEquals('MyException', $function->getExceptionClasses()->current()->getName());
141 -
142 - $code->next();
143 -
144 - $package = $code->current();
145 - $this->assertEquals('pdepend.test2', $package->getName());
146 -
147 - $sourceFile = realpath(dirname(__FILE__). '/../_code/function.inc');
148 - $this->assertEquals($sourceFile, $function->getSourceFile()->getName());
149 -
150 - unlink($fileName);
148 + $function = $package->getFunctions()->current();
149 + $this->assertEquals('foo', $function->getName());
150 + $this->assertEquals(1, $function->getExceptionClasses()->count());
151 + $this->assertEquals('MyException', $function->getExceptionClasses()->current()->getName());
152 + } else if ($package->getName() === 'pdepend.test') {
153 + $this->assertEquals('pdepend.test2', $package->getName());
154 + }
155 + }
151 156 }
152 157
153 158 /**
155 160 * correct.
156 161 *
157 162 * @return void
163 + * @covers PHP_Depend_TextUI_Runner
164 + * @group pdepend
165 + * @group pdepend::textui
166 + * @group unittest
158 167 */
159 168 public function testRunnerHandlesWithoutAnnotationsOptionCorrect()
160 169 {
161 170 $fileName = self::createRunResourceURI('pdepend.dummy');
162 - if (file_exists($fileName)) {
163 - unlink($fileName);
164 - }
165 171
166 172 $runner = new PHP_Depend_TextUI_Runner();
167 173 $runner->setSourceArguments(array(dirname(__FILE__). '/../_code'));
178 184 $code = $data['code'];
179 185 $this->assertEquals(3, $code->count());
180 186
181 - $code->rewind();
187 + foreach ($code as $package) {
188 + if ($package->getName() === 'pdepend.test') {
189 + $this->assertEquals(1, $package->getFunctions()->count());
190 + $this->assertEquals(1, $package->getClasses()->count());
182 191
183 - $package = $code->current();
184 - $this->assertEquals('pdepend.test', $package->getName());
185 -
186 - $this->assertEquals(1, $package->getFunctions()->count());
187 - $this->assertEquals(1, $package->getClasses()->count());
188 -
189 - $function = $package->getFunctions()->current();
190 - $this->assertEquals('foo', $function->getName());
191 - $this->assertEquals(0, $function->getExceptionClasses()->count());
192 -
193 - $code->next();
194 -
195 - $package = $code->current();
196 - $this->assertEquals('pdepend.test2', $package->getName());
197 -
198 - unlink($fileName);
192 + $function = $package->getFunctions()->current();
193 + $this->assertEquals('foo', $function->getName());
194 + $this->assertEquals(0, $function->getExceptionClasses()->count());
195 + }
196 + }
199 197 }
200 198
199 + /**
200 + * testSupportBadDocumentation
201 + *
202 + * @return void
203 + * @covers PHP_Depend_TextUI_Runner
204 + * @group pdepend
205 + * @group pdepend::textui
206 + * @group unittest
207 + */
201 208 public function testSupportBadDocumentation()
202 209 {
203 210 $fileName = self::createRunResourceURI('pdepend.dummy');
204 - if (file_exists($fileName)) {
205 - unlink($fileName);
206 - }
207 211
208 212 $runner = new PHP_Depend_TextUI_Runner();
209 213 $runner->setSourceArguments(array(dirname(__FILE__). '/../_code/code-without-comments'));
226 230
227 231 $this->assertEquals(7, $package->getClasses()->count());
228 232 $this->assertEquals(3, $package->getInterfaces()->count());
229 -
230 - unlink($fileName);
231 233 }
232 234 }
1113 1114 /tests/PHP/Depend/TextUI/CommandTest.php
84 84 * Tests the result of the print version option.
85 85 *
86 86 * @return void
87 + * @covers PHP_Depend_TextUI_Command
88 + * @group pdepend
89 + * @group pdepend::textui
90 + * @group unittest
87 91 */
88 92 public function testPrintVersion()
89 93 {
97 101 * Tests the result of the print usage option.
98 102 *
99 103 * @return void
104 + * @covers PHP_Depend_TextUI_Command
105 + * @group pdepend
106 + * @group pdepend::textui
107 + * @group unittest
100 108 */
101 109 public function testPrintUsage()
102 110 {
112 120 * Tests the output of the print help option.
113 121 *
114 122 * @return void
123 + * @covers PHP_Depend_TextUI_Command
124 + * @group pdepend
125 + * @group pdepend::textui
126 + * @group unittest
115 127 */
116 128 public function testPrintHelp()
117 129 {
126 138 * Tests that the command exits with an cli error if no $argv array exists.
127 139 *
128 140 * @return void
141 + * @covers PHP_Depend_TextUI_Command
142 + * @group pdepend
143 + * @group pdepend::textui
144 + * @group unittest
129 145 */
130 146 public function testCommandExitsWithCliErrorIfNotArgvArrayExists()
131 147 {
141 157 * Tests that the command exits with a cli error for an empty option list.
142 158 *
143 159 * @return void
160 + * @covers PHP_Depend_TextUI_Command
161 + * @group pdepend
162 + * @group pdepend::textui
163 + * @group unittest
144 164 */
145 165 public function testCommandExitsWithCliErrorForEmptyOptionList()
146 166 {
155 175 * Tests that the command starts the text ui runner.
156 176 *
157 177 * @return void
178 + * @covers PHP_Depend_TextUI_Command
179 + * @group pdepend
180 + * @group pdepend::textui
181 + * @group unittest
158 182 */
159 183 public function testCommandStartsProcessWithDummyLogger()
160 184 {
171 195 $source
172 196 );
173 197
174 - if (file_exists($logFile)) {
175 - unlink($logFile);
176 - }
177 -
178 198 list($exitCode, $actual) = $this->_executeCommand($argv);
179 199
180 200 $this->assertEquals(PHP_Depend_TextUI_Runner::SUCCESS_EXIT, $exitCode);
181 201 $this->assertFileExists($logFile);
182 -
183 - unlink($logFile);
184 202 }
185 203
186 204 /**
187 205 * Tests that the command exits with a cli error for an unknown option.
188 206 *
189 207 * @return void
208 + * @covers PHP_Depend_TextUI_Command
209 + * @group pdepend
210 + * @group pdepend::textui
211 + * @group unittest
190 212 */
191 213 public function testCommandExitsWithCliErrorForUnknownOption()
192 214 {
200 222 * correct.
201 223 *
202 224 * @return void
225 + * @covers PHP_Depend_TextUI_Command
226 + * @group pdepend
227 + * @group pdepend::textui
228 + * @group unittest
203 229 */
204 230 public function testCommandHandlesWithoutAnnotationsOptionCorrect()
205 231 {
227 253 $code = $data['code'];
228 254 $this->assertEquals(3, $code->count());
229 255
230 - $code->rewind();
256 + foreach ($code as $package) {
257 + if ($package->getName() === 'pdepend.test') {
258 + $this->assertEquals(1, $package->getFunctions()->count());
259 + $this->assertEquals(1, $package->getClasses()->count());
231 260
232 - $package = $code->current();
233 -
234 - $this->assertEquals('pdepend.test', $package->getName());
235 -
236 - $this->assertEquals(1, $package->getFunctions()->count());
237 - $this->assertEquals(1, $package->getClasses()->count());
238 -
239 - $function = $package->getFunctions()->current();
240 - $this->assertEquals('foo', $function->getName());
241 - $this->assertEquals(0, $function->getExceptionClasses()->count());
242 -
243 - $code->next();
244 -
245 - $package = $code->current();
246 - $this->assertEquals('pdepend.test2', $package->getName());
247 -
248 - unlink($logFile);
261 + $function = $package->getFunctions()->current();
262 + $this->assertEquals('foo', $function->getName());
263 + $this->assertEquals(0, $function->getExceptionClasses()->count());
264 + } else if ($package->getName() === 'pdepend.test2') {
265 + $this->assertEquals('pdepend.test2', $package->getName());
266 + }
267 + }
249 268 }
250 269
251 270 /**
253 272 * correct.
254 273 *
255 274 * @return void
275 + * @covers PHP_Depend_TextUI_Command
276 + * @group pdepend
277 + * @group pdepend::textui
278 + * @group unittest
256 279 */
257 280 public function testCommandHandlesBadDocumentationOptionCorrect()
258 281 {
285 308
286 309 $this->assertEquals(7, $package->getClasses()->count());
287 310 $this->assertEquals(3, $package->getInterfaces()->count());
288 -
289 - unlink($logFile);
290 311 }
291 312
292 313 /**
293 314 * Tests that the command interpretes a "-d key" as "on".
294 315 *
295 316 * @return void
317 + * @covers PHP_Depend_TextUI_Command
318 + * @group pdepend
319 + * @group pdepend::textui
320 + * @group unittest
296 321 */
297 322 public function testCommandHandlesIniOptionWithoutValueToON()
298 323 {
320 345 * Tests that the text ui command handles an ini option "-d key=value" correct.
321 346 *
322 347 * @return void
348 + * @covers PHP_Depend_TextUI_Command
349 + * @group pdepend
350 + * @group pdepend::textui
351 + * @group unittest
323 352 */
324 353 public function testCommandHandlesIniOptionWithValue()
325 354 {
348 377 * config file.
349 378 *
350 379 * @return void
380 + * @covers PHP_Depend_TextUI_Command
381 + * @group pdepend
382 + * @group pdepend::textui
383 + * @group unittest
351 384 */
352 385 public function testCommandHandlesConfigurationFileCorrect()
353 386 {
440 473 * Tests that the command fails for an invalid config file.
441 474 *
442 475 * @return void
476 + * @covers PHP_Depend_TextUI_Command
477 + * @group pdepend
478 + * @group pdepend::textui
479 + * @group unittest
443 480 */
444 481 public function testCommandFailsIfAnInvalidConfigFileWasSpecified()
445 482 {
446 483 $configFile = self::createRunResourceURI('config.xml');
447 - if (file_exists($configFile) === true) {
448 - unlink($configFile);
449 - }
450 484
451 485 $argv = array('--configuration=' . $configFile, __FILE__);
452 486