public function PHP_Token_InterfaceTest::testGetPackageNamespaceForFileWithMultipleNamespaces in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpunit/php-token-stream/tests/Token/InterfaceTest.php \PHP_Token_InterfaceTest::testGetPackageNamespaceForFileWithMultipleNamespaces()
@dataProvider provideFilesWithClassesWithinMultipleNamespaces @covers PHP_Token_INTERFACE::getPackage
File
- vendor/
phpunit/ php-token-stream/ tests/ Token/ InterfaceTest.php, line 139
Class
- PHP_Token_InterfaceTest
- Tests for the PHP_Token_INTERFACE class.
Code
public function testGetPackageNamespaceForFileWithMultipleNamespaces($filepath) {
$tokenStream = new PHP_Token_Stream($filepath);
$firstClassFound = false;
foreach ($tokenStream as $token) {
if ($firstClassFound === false && $token instanceof PHP_Token_INTERFACE) {
$package = $token
->getPackage();
$this
->assertSame('TestClassInBar', $token
->getName());
$this
->assertSame('Foo\\Bar', $package['namespace']);
$firstClassFound = true;
continue;
}
// Secound class
if ($token instanceof PHP_Token_INTERFACE) {
$package = $token
->getPackage();
$this
->assertSame('TestClassInBaz', $token
->getName());
$this
->assertSame('Foo\\Baz', $package['namespace']);
return;
}
}
$this
->fail("Seachring for 2 classes failed");
}