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(1, $namespace->countMatchingNamespaceSegments('MyPSR4Root')); $this->assertEquals(2, $namespace->countMatchingNamespaceSegments('MyPSR4Root\\Foot')); $this->assertEquals(2, $namespace->countMatchingNamespaceSegments('MyPSR4Root\\Foot\\Baz'), 'countMatchingNamespaceSegments should only report matches against the registered namespace root. It should not attempt to resolve segments after the registered root.'); $this->assertEquals(2, $namespace->countMatchingNamespaceSegments('MyPSR4Root\\Foot\\Baz\\Foo'), 'countMatchingNamespaceSegments should only report matches against the registered namespace root. It should not attempt to resolve segments after the registered root.'); $this->assertEquals(0, $namespace->countMatchingNamespaceSegments('Cactus')); $this->assertEquals(0, $namespace->countMatchingNamespaceSegments('Cactus\\Foot')); } }