IncludeTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. public function testGetIncludes()
  22. {
  23. $this->assertSame(
  24. ['test4.php', 'test3.php', 'test2.php', 'test1.php'],
  25. $this->ts->getIncludes()
  26. );
  27. }
  28. public function testGetIncludesCategorized()
  29. {
  30. $this->assertSame(
  31. [
  32. 'require_once' => ['test4.php'],
  33. 'require' => ['test3.php'],
  34. 'include_once' => ['test2.php'],
  35. 'include' => ['test1.php']
  36. ],
  37. $this->ts->getIncludes(true)
  38. );
  39. }
  40. public function testGetIncludesCategory()
  41. {
  42. $this->assertSame(
  43. ['test4.php'],
  44. $this->ts->getIncludes(true, 'require_once')
  45. );
  46. }
  47. }