3 * This file is part of the PHP_TokenStream package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Tests for the PHP_Token_NAMESPACE class.
14 * @package PHP_TokenStream
16 * @author Sebastian Bergmann <sebastian@phpunit.de>
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.0
23 class PHP_Token_NamespaceTest extends PHPUnit_Framework_TestCase
26 * @covers PHP_Token_NAMESPACE::getName
28 public function testGetName()
30 $tokenStream = new PHP_Token_Stream(
31 TEST_FILES_PATH . 'classInNamespace.php'
34 foreach ($tokenStream as $token) {
35 if ($token instanceof PHP_Token_NAMESPACE) {
36 $this->assertSame('Foo\\Bar', $token->getName());
41 public function testGetStartLineWithUnscopedNamespace()
43 $tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
44 foreach($tokenStream as $token) {
45 if($token instanceOf PHP_Token_NAMESPACE) {
46 $this->assertSame(2, $token->getLine());
51 public function testGetEndLineWithUnscopedNamespace()
53 $tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
54 foreach($tokenStream as $token) {
55 if($token instanceOf PHP_Token_NAMESPACE) {
56 $this->assertSame(2, $token->getEndLine());
60 public function testGetStartLineWithScopedNamespace()
62 $tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
63 foreach($tokenStream as $token) {
64 if($token instanceOf PHP_Token_NAMESPACE) {
65 $this->assertSame(2, $token->getLine());
70 public function testGetEndLineWithScopedNamespace()
72 $tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
73 foreach($tokenStream as $token) {
74 if($token instanceOf PHP_Token_NAMESPACE) {
75 $this->assertSame(8, $token->getEndLine());