| 96 |
99 |
} |
| 97 |
100 |
|
| 98 |
101 |
/** |
|
102 |
+ * testBacktickExpressionContainsTwoChildNodes |
|
103 |
+ * |
|
104 |
+ * @return void |
|
105 |
+ * @covers PHP_Depend_Code_ASTString |
|
106 |
+ * @covers PHP_Depend_Parser::_parseString |
|
107 |
+ * @covers PHP_Depend_Parser::_parseLiteralOrString |
|
108 |
+ * @group pdepend |
|
109 |
+ * @group pdepend::ast |
|
110 |
+ */ |
|
111 |
+ public function testBacktickExpressionContainsTwoChildNodes() |
|
112 |
+ { |
|
113 |
+ $string = $this->_getFirstStringInFunction(__METHOD__); |
|
114 |
+ $this->assertEquals(2, count($string->getChildren())); |
|
115 |
+ } |
|
116 |
+ |
|
117 |
+ /** |
|
118 |
+ * testBacktickExpressionContainsExpectedCompoundVariable |
|
119 |
+ * |
|
120 |
+ * @return void |
|
121 |
+ * @covers PHP_Depend_Code_ASTString |
|
122 |
+ * @covers PHP_Depend_Parser::_parseString |
|
123 |
+ * @covers PHP_Depend_Parser::_parseLiteralOrString |
|
124 |
+ * @group pdepend |
|
125 |
+ * @group pdepend::ast |
|
126 |
+ */ |
|
127 |
+ public function testBacktickExpressionContainsExpectedCompoundVariable() |
|
128 |
+ { |
|
129 |
+ $string = $this->_getFirstStringInFunction(__METHOD__); |
|
130 |
+ $this->assertType(PHP_Depend_Code_ASTCompoundVariable::CLAZZ, $string->getChild(0)); |
|
131 |
+ } |
|
132 |
+ |
|
133 |
+ /** |
| 99 |
134 |
* Tests that an invalid literal results in the expected exception. |
| 100 |
135 |
* |
| 101 |
136 |
* @return void |
| 115 |
118 |
PHP_Depend_TokenizerI::T_CURLY_BRACE_CLOSE |
| 116 |
119 |
); |
| 117 |
120 |
|
| 118 |
|
- $this->assertEquals($sourceFile, (string) $tokenizer->getSourceFile()); |
| 119 |
|
- |
| 120 |
|
- while (($token = $tokenizer->next()) !== PHP_Depend_TokenizerI::T_EOF) { |
| 121 |
|
- $this->assertEquals($token->type, array_shift($tokens)); |
|
121 |
+ $actual = array(); |
|
122 |
+ while (is_object($token = $tokenizer->next())) { |
|
123 |
+ $actual[] = $token->type; |
| 122 |
124 |
} |
| 123 |
125 |
|
| 124 |
|
- $this->assertEquals(0, count($tokens)); |
|
126 |
+ $this->assertEquals($expected, $actual); |
| 125 |
127 |
} |
| 126 |
128 |
|
| 127 |
129 |
/** |
| 166 |
171 |
array(PHP_Depend_TokenizerI::T_CLOSE_TAG, 16) |
| 167 |
172 |
); |
| 168 |
173 |
|
| 169 |
|
- $this->assertEquals($sourceFile, (string) $tokenizer->getSourceFile()); |
| 170 |
|
- |
| 171 |
|
- while (($token = $tokenizer->next()) !== PHP_Depend_TokenizerI::T_EOF) { |
| 172 |
|
- list($tok, $line) = array_shift($tokens); |
| 173 |
|
- $this->assertEquals($tok, $token->type); |
| 174 |
|
- $this->assertEquals($line, $token->startLine); |
|
174 |
+ $actual = array(); |
|
175 |
+ while (is_object($token = $tokenizer->next())) { |
|
176 |
+ $actual[] = array($token->type, $token->startLine); |
| 175 |
177 |
} |
| 176 |
|
- |
| 177 |
|
- $this->assertEquals(0, count($tokens)); |
|
178 |
+ |
|
179 |
+ $this->assertEquals($expected, $actual); |
| 178 |
180 |
} |
| 179 |
181 |
|
| 180 |
182 |
/** |
| 241 |
249 |
PHP_Depend_TokenizerI::T_CLOSE_TAG |
| 242 |
250 |
); |
| 243 |
251 |
|
| 244 |
|
- $this->assertEquals($sourceFile, (string) $tokenizer->getSourceFile()); |
| 245 |
|
- |
| 246 |
|
- while ($tokenizer->peek() !== PHP_Depend_TokenizerI::T_EOF) { |
| 247 |
|
- $token = $tokenizer->next(); |
| 248 |
|
- $this->assertEquals(array_shift($tokens), $token->type); |
|
252 |
+ $actual = array(); |
|
253 |
+ while (is_object($token = $tokenizer->next())) { |
|
254 |
+ $actual[] = $token->type; |
| 249 |
255 |
} |
| 250 |
256 |
|
| 251 |
|
- $this->assertEquals(0, count($tokens)); |
|
257 |
+ $this->assertEquals($expected, $actual); |
| 252 |
258 |
} |
| 253 |
259 |
|
| 254 |
260 |
/** |
| 255 |
261 |
* Test case for undetected static method call added. |
| 256 |
262 |
* |
| 257 |
263 |
* @return void |
| 258 |
|
- * @group tokenizer |
|
264 |
+ * @covers PHP_Depend_Tokenizer_Internal |
|
265 |
+ * @group pdepend |
|
266 |
+ * @group pdepend::tokenizer |
|
267 |
+ * @group unittest |
| 259 |
268 |
*/ |
| 260 |
269 |
public function testInternalStaticCallBug01() |
| 261 |
270 |
{ |
| 285 |
294 |
PHP_Depend_TokenizerI::T_CURLY_BRACE_CLOSE, |
| 286 |
295 |
); |
| 287 |
296 |
|
| 288 |
|
- while (($token = $tokenizer->next()) !== PHP_Depend_TokenizerI::T_EOF) { |
| 289 |
|
- $this->assertEquals(array_shift($tokens), $token->type); |
|
297 |
+ $actual = array(); |
|
298 |
+ while (is_object($token = $tokenizer->next())) { |
|
299 |
+ $actual[] = $token->type; |
| 290 |
300 |
} |
| 291 |
301 |
|
| 292 |
|
- $this->assertEquals(0, count($tokens)); |
|
302 |
+ $this->assertEquals($expected, $actual); |
| 293 |
303 |
} |
| 294 |
304 |
|
| 295 |
305 |
/** |
| 338 |
351 |
PHP_Depend_TokenizerI::T_CURLY_BRACE_CLOSE, |
| 339 |
352 |
); |
| 340 |
353 |
|
| 341 |
|
- while (($token = $tokenizer->next()) !== PHP_Depend_TokenizerI::T_EOF) { |
| 342 |
|
- $this->assertEquals(array_shift($tokens), $token->type); |
|
354 |
+ $actual = array(); |
|
355 |
+ while (is_object($token = $tokenizer->next())) { |
|
356 |
+ $actual[] = $token->type; |
| 343 |
357 |
} |
| 344 |
358 |
|
| 345 |
|
- $this->assertEquals(0, count($tokens)); |
|
359 |
+ $this->assertEquals($expected, $actual); |
| 346 |
360 |
} |
| 347 |
361 |
|
| 348 |
362 |
/** |
| 349 |
363 |
* Test case for the inline html bug. |
| 350 |
364 |
* |
| 351 |
365 |
* @return void |
| 352 |
|
- * @group tokenizer |
|
366 |
+ * @covers PHP_Depend_Tokenizer_Internal |
|
367 |
+ * @group pdepend |
|
368 |
+ * @group pdepend::tokenizer |
|
369 |
+ * @group unittest |
| 353 |
370 |
*/ |
| 354 |
371 |
public function testTokenizerWithInlineHtmlBug24() |
| 355 |
372 |
{ |
| 395 |
412 |
array(PHP_Depend_TokenizerI::T_CURLY_BRACE_CLOSE, 17), |
| 396 |
413 |
); |
| 397 |
414 |
|
| 398 |
|
- while (($token = $tokenizer->next()) !== PHP_Depend_TokenizerI::T_EOF) { |
| 399 |
|
- $expected = array_shift($tokens); |
| 400 |
|
- |
| 401 |
|
- $this->assertEquals($expected[0], $token->type); |
| 402 |
|
- $this->assertEquals($expected[1], $token->startLine); |
|
415 |
+ $actual = array(); |
|
416 |
+ while (is_object($token = $tokenizer->next())) { |
|
417 |
+ $actual[] = array($token->type, $token->startLine); |
| 403 |
418 |
} |
| 404 |
419 |
|
| 405 |
|
- $this->assertEquals(0, count($tokens)); |
|
420 |
+ $this->assertSame($expected, $actual); |
| 406 |
421 |
} |
| 407 |
422 |
|
| 408 |
423 |
/** |
| 431 |
449 |
array(PHP_Depend_TokenizerI::T_CLOSE_TAG, 3), |
| 432 |
450 |
); |
| 433 |
451 |
|
| 434 |
|
- while (($token = $tokenizer->next()) !== PHP_Depend_TokenizerI::T_EOF) { |
| 435 |
|
- $expected = array_shift($tokens); |
| 436 |
|
- |
| 437 |
|
- $this->assertEquals($expected[0], $token->type); |
| 438 |
|
- $this->assertEquals($expected[1], $token->startLine); |
|
452 |
+ $actual = array(); |
|
453 |
+ while (is_object($token = $tokenizer->next())) { |
|
454 |
+ $actual[] = array($token->type, $token->startLine); |
| 439 |
455 |
} |
| 440 |
456 |
|
| 441 |
|
- $this->assertEquals(0, count($tokens)); |
|
457 |
+ $this->assertSame($expected, $actual); |
| 442 |
458 |
} |
| 443 |
459 |
|
| 444 |
460 |
/** |
| 445 |
461 |
* Tests the tokenizers column calculation implementation. |
| 446 |
462 |
* |
| 447 |
463 |
* @return void |
| 448 |
|
- * @group tokenizer |
|
464 |
+ * @covers PHP_Depend_Tokenizer_Internal |
|
465 |
+ * @group pdepend |
|
466 |
+ * @group pdepend::tokenizer |
|
467 |
+ * @group unittest |
| 449 |
468 |
*/ |
| 450 |
469 |
public function testTokenizerCalculatesCorrectColumnForInlinePhpIssue88() |
| 451 |
470 |
{ |
| 474 |
493 |
</html>', 7, 8, 1, 7), |
| 475 |
494 |
); |
| 476 |
495 |
|
| 477 |
|
- while (($token = $tokenizer->next()) !== PHP_Depend_TokenizerI::T_EOF) { |
| 478 |
|
- $expected = array_shift($tokens); |
| 479 |
|
- |
| 480 |
|
- $this->assertEquals($expected[0], $token->type); |
| 481 |
|
- $this->assertEquals($expected[1], $token->image); |
| 482 |
|
- $this->assertEquals($expected[2], $token->startLine); |
| 483 |
|
- $this->assertEquals($expected[3], $token->endLine); |
| 484 |
|
- $this->assertEquals($expected[4], $token->startColumn); |
| 485 |
|
- $this->assertEquals($expected[5], $token->endColumn); |
|
496 |
+ $actual = array(); |
|
497 |
+ while (is_object($token = $tokenizer->next())) { |
|
498 |
+ $actual[] = array( |
|
499 |
+ $token->type, |
|
500 |
+ $token->image, |
|
501 |
+ $token->startLine, |
|
502 |
+ $token->endLine, |
|
503 |
+ $token->startColumn, |
|
504 |
+ $token->endColumn |
|
505 |
+ ); |
| 486 |
506 |
} |
| 487 |
507 |
|
| 488 |
|
- $this->assertEquals(0, count($tokens)); |
|
508 |
+ $this->assertSame($expected, $actual); |
| 489 |
509 |
} |
| 490 |
510 |
|
| 491 |
511 |
/** |
| 492 |
512 |
* Tests the tokenizers column calculation implementation. |
| 493 |
513 |
* |
| 494 |
514 |
* @return void |
| 495 |
|
- * @group tokenizer |
|
515 |
+ * @covers PHP_Depend_Tokenizer_Internal |
|
516 |
+ * @group pdepend |
|
517 |
+ * @group pdepend::tokenizer |
|
518 |
+ * @group unittest |
| 496 |
519 |
*/ |
| 497 |
520 |
public function testTokenizerCalculatesCorrectColumnForInlinePhpInTextIssue88() |
| 498 |
521 |
{ |
| 500 |
523 |
$tokenizer = new PHP_Depend_Tokenizer_Internal(); |
| 501 |
524 |
$tokenizer->setSourceFile($sourceFile); |
| 502 |
525 |
|
| 503 |
|
- $tokens = array( |
|
526 |
+ $expected = array( |
| 504 |
527 |
array(PHP_Depend_ConstantsI::T_NO_PHP, 'Hello', 1, 1, 1, 5), |
| 505 |
528 |
array(PHP_Depend_ConstantsI::T_OPEN_TAG, '<?php', 1, 1, 7, 11), |
| 506 |
529 |
array(PHP_Depend_ConstantsI::T_ECHO, 'echo', 1, 1, 13, 16), |
| 519 |
542 |
Manuel', 3, 5, 61, 6), |
| 520 |
543 |
); |
| 521 |
544 |
|
| 522 |
|
- while (($token = $tokenizer->next()) !== PHP_Depend_TokenizerI::T_EOF) { |
| 523 |
|
- $expected = array_shift($tokens); |
| 524 |
|
- |
| 525 |
|
- $this->assertEquals($expected[0], $token->type); |
| 526 |
|
- $this->assertEquals($expected[1], $token->image); |
| 527 |
|
- $this->assertEquals($expected[2], $token->startLine); |
| 528 |
|
- $this->assertEquals($expected[3], $token->endLine); |
| 529 |
|
- $this->assertEquals($expected[4], $token->startColumn); |
| 530 |
|
- $this->assertEquals($expected[5], $token->endColumn); |
|
545 |
+ $actual = array(); |
|
546 |
+ while (is_object($token = $tokenizer->next())) { |
|
547 |
+ $actual[] = array( |
|
548 |
+ $token->type, |
|
549 |
+ $token->image, |
|
550 |
+ $token->startLine, |
|
551 |
+ $token->endLine, |
|
552 |
+ $token->startColumn, |
|
553 |
+ $token->endColumn |
|
554 |
+ ); |
| 531 |
555 |
} |
| 532 |
556 |
|
| 533 |
|
- $this->assertEquals(0, count($tokens)); |
|
557 |
+ $this->assertSame($expected, $actual); |
| 534 |
558 |
} |
| 535 |
559 |
} |
| 439 |
443 |
); |
| 440 |
444 |
|
| 441 |
445 |
if (version_compare(phpversion(), '5.3.0alpha3') < 0) { |
| 442 |
|
- $tokens = PHP_Depend_Tokenizer_PHP53NamespaceHelper::tokenize($source); |
|
446 |
+ $tempTokens = PHP_Depend_Tokenizer_PHP53NamespaceHelper::tokenize($source); |
| 443 |
447 |
} else { |
| 444 |
|
- $tokens = token_get_all($source); |
|
448 |
+ $tempTokens = token_get_all($source); |
| 445 |
449 |
} |
| 446 |
450 |
|
|
451 |
+ $tokens = array(); |
|
452 |
+ foreach ($tempTokens as $tempToken) { |
|
453 |
+ $temp = (array) $tempToken; |
|
454 |
+ $temp = $temp[0]; |
|
455 |
+ if (isset(self::$substitutes[$temp])) { |
|
456 |
+ foreach (self::$substitutes[$temp] as $token) { |
|
457 |
+ $tokens[] = $token; |
|
458 |
+ } |
|
459 |
+ } else { |
|
460 |
+ $tokens[] = $tempToken; |
|
461 |
+ } |
|
462 |
+ } |
|
463 |
+ |
|
464 |
+ |
| 447 |
465 |
reset($tokens); |
| 448 |
466 |
|
| 449 |
467 |
// Is the current token between an opening and a closing php tag? |