setExpectedException('InvalidArgumentException'); $locator = new Zend_File_ClassFileLocator('__foo__'); } public function testConstructorThrowsInvalidArgumentExceptionForNonDirectoryIteratorArgument() { $iterator = new ArrayIterator(array()); $this->setExpectedException('InvalidArgumentException'); $locator = new Zend_File_ClassFileLocator($iterator); } public function testIterationShouldReturnOnlyPhpFiles() { $locator = new Zend_File_ClassFileLocator(dirname(__FILE__)); foreach ($locator as $file) { $this->assertRegexp('/\.php$/', $file->getFilename()); } } public function testIterationShouldReturnOnlyPhpFilesContainingClasses() { $locator = new Zend_File_ClassFileLocator(dirname(__FILE__)); $found = false; foreach ($locator as $file) { if (preg_match('/locator-should-skip-this\.php$/', $file->getFilename())) { $found = true; } } $this->assertFalse($found, "Found PHP file not containing a class?"); } public function testIterationShouldReturnInterfaces() { $locator = new Zend_File_ClassFileLocator(dirname(__FILE__)); $found = false; foreach ($locator as $file) { if (preg_match('/LocatorShouldFindThis\.php$/', $file->getFilename())) { $found = true; } } $this->assertTrue($found, "Locator skipped an interface?"); } public function testIterationShouldInjectClassInFoundItems() { $locator = new Zend_File_ClassFileLocator(dirname(__FILE__)); $found = false; foreach ($locator as $file) { $this->assertTrue(isset($file->classname)); } } } if (PHPUnit_MAIN_METHOD == 'Zend_File_ClassFileLocatorTest::main') { Zend_File_ClassFileLocatorTest::main(); }