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