/** * testLoaderNotReturnsDisabledAnalyzerInstances * * @return void * @covers PHP_Depend_Metrics_AnalyzerLoader * @group pdepend * @group pdepend::metrics * @group unittest */ public function testLoaderNotReturnsDisabledAnalyzerInstances() { $analyzer = $this->getMock('PHP_Depend_Metrics_AnalyzerI'); $analyzer->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); $reflection = $this->getMock('ReflectionObject', array('newInstance'), array($analyzer)); $reflection->expects($this->once())->method('newInstance')->will($this->returnValue($analyzer)); $locator = $this->getMock('PHP_Depend_Metrics_AnalyzerClassLocator'); $locator->expects($this->once())->method('findAll')->will($this->returnValue(array($reflection))); $loader = new PHP_Depend_Metrics_AnalyzerLoader(array('PHP_Depend_Metrics_AnalyzerI')); $loader->setClassLocator($locator); $this->assertEquals(0, iterator_count($loader->getIterator())); }
/** * Creates a {@link PHP_Depend_Metrics_AnalyzerLoader} instance that will be * used to create all analyzers required for the actually registered logger * instances. * * @param array $options The command line options recieved for this run. * * @return PHP_Depend_Metrics_AnalyzerLoader */ private function _createAnalyzerLoader(array $options) { $analyzerSet = array(); foreach ($this->_loggers as $logger) { foreach ($logger->getAcceptedAnalyzers() as $type) { // Check for type existence if (in_array($type, $analyzerSet) === false) { $analyzerSet[] = $type; } } } $loader = new PHP_Depend_Metrics_AnalyzerLoader($analyzerSet, $options); $loader->setClassLocator(new PHP_Depend_Metrics_AnalyzerClassFileSystemLocator()); return $this->_initAnalyseListeners($loader); }