IncludeTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. }