IncludeTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of php-token-stream.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. use PHPUnit\Framework\TestCase;
  11. class PHP_Token_IncludeTest extends TestCase
  12. {
  13. /**
  14. * @var PHP_Token_Stream
  15. */
  16. private $ts;
  17. protected function setUp()
  18. {
  19. $this->ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source3.php');
  20. }
  21. /**
  22. * @covers PHP_Token_Includes::getName
  23. * @covers PHP_Token_Includes::getType
  24. */
  25. public function testGetIncludes()
  26. {
  27. $this->assertSame(
  28. ['test4.php', 'test3.php', 'test2.php', 'test1.php'],
  29. $this->ts->getIncludes()
  30. );
  31. }
  32. /**
  33. * @covers PHP_Token_Includes::getName
  34. * @covers PHP_Token_Includes::getType
  35. */
  36. public function testGetIncludesCategorized()
  37. {
  38. $this->assertSame(
  39. [
  40. 'require_once' => ['test4.php'],
  41. 'require' => ['test3.php'],
  42. 'include_once' => ['test2.php'],
  43. 'include' => ['test1.php']
  44. ],
  45. $this->ts->getIncludes(true)
  46. );
  47. }
  48. /**
  49. * @covers PHP_Token_Includes::getName
  50. * @covers PHP_Token_Includes::getType
  51. */
  52. public function testGetIncludesCategory()
  53. {
  54. $this->assertSame(
  55. ['test4.php'],
  56. $this->ts->getIncludes(true, 'require_once')
  57. );
  58. }
  59. }