getTestStructure(); $this->root = vfsStream::setup('root', null, $structure); } public function getTestStructure() { return array( 'Baz' => array( 'Foo' => array( 'Fooa.php' => $this->getClassFileContents('PSR4\\Foo', 'Fooa'), 'Foob.php' => $this->getClassFileContents('PSR4\\Foo', 'Foob') ), 'Bar.php' => $this->getClassFileContents('PSR4', 'Bar'), 'Barb.php' => $this->getClassFileContents('PSR4', 'Barb') ) ); } public function getClassFileContents($namespace, $className) { $template = <<root->getChild('Baz')->path()); $this->assertEquals($namespace->countMatchingNamespaceSegments('MyPSR4Root\\Foot'), 2); $this->assertEquals($namespace->countMatchingNamespaceSegments('MyPSR4Root'), 1); $this->assertEquals($namespace->countMatchingNamespaceSegments('MyPSR4Root\\Foot\\Baz\\Foo'), 3); $this->assertEquals($namespace->countMatchingNamespaceSegments('MyPSR4Root\\Foot\\Baz'), 3); $this->assertEquals($namespace->countMatchingNamespaceSegments('Cactus'), 0); $this->assertEquals($namespace->countMatchingNamespaceSegments('Cactus\\Foot'), 0); } }