@dataProvider provideFilesWithClassesWithinMultipleNamespaces @covers PHP_Token_INTERFACE::getPackage
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");
}