IncludeTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * This file is part of the PHP_TokenStream package.
  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. /**
  11. * Tests for the PHP_Token_REQUIRE_ONCE, PHP_Token_REQUIRE
  12. * PHP_Token_INCLUDE_ONCE and PHP_Token_INCLUDE_ONCE classes.
  13. *
  14. * @package PHP_TokenStream
  15. * @subpackage Tests
  16. * @author Laurent Laville <pear@laurent-laville.org>
  17. * @copyright Sebastian Bergmann <sebastian@phpunit.de>
  18. * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
  19. * @version Release: @package_version@
  20. * @link http://github.com/sebastianbergmann/php-token-stream/
  21. * @since Class available since Release 1.0.2
  22. */
  23. class PHP_Token_IncludeTest extends PHPUnit_Framework_TestCase
  24. {
  25. protected $ts;
  26. protected function setUp()
  27. {
  28. $this->ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source3.php');
  29. }
  30. /**
  31. * @covers PHP_Token_Includes::getName
  32. * @covers PHP_Token_Includes::getType
  33. */
  34. public function testGetIncludes()
  35. {
  36. $this->assertSame(
  37. array('test4.php', 'test3.php', 'test2.php', 'test1.php'),
  38. $this->ts->getIncludes()
  39. );
  40. }
  41. /**
  42. * @covers PHP_Token_Includes::getName
  43. * @covers PHP_Token_Includes::getType
  44. */
  45. public function testGetIncludesCategorized()
  46. {
  47. $this->assertSame(
  48. array(
  49. 'require_once' => array('test4.php'),
  50. 'require' => array('test3.php'),
  51. 'include_once' => array('test2.php'),
  52. 'include' => array('test1.php')
  53. ),
  54. $this->ts->getIncludes(TRUE)
  55. );
  56. }
  57. /**
  58. * @covers PHP_Token_Includes::getName
  59. * @covers PHP_Token_Includes::getType
  60. */
  61. public function testGetIncludesCategory()
  62. {
  63. $this->assertSame(
  64. array('test4.php'),
  65. $this->ts->getIncludes(TRUE, 'require_once')
  66. );
  67. }
  68. }