/** * Creates the PDepend summary report for the source associated with the * calling test case. * * @return string * @since 0.10.0 */ protected function createSummaryXmlForCallingTest() { $file = self::createRunResourceURI('summary.xml'); $log = new PHP_Depend_Log_Summary_Xml(); $log->setLogFile($file); $pdepend = $this->createPDependFixture(); $pdepend->addFile(self::createCodeResourceUriForTest()); $pdepend->addLogger($log); $pdepend->analyze(); return $file; }
/** * Tests that pdepend does not die with a fatal error. * * @return void */ public function testPHPDependDoesNotDieWithErrorInterfaceDeclaredBeforeClassWithoutPackage() { $logFile = self::createRunResourceURI('summary.xml'); $fileName = self::createCodeResourceURI('bugs/073-004-inconsistent-object-graph.php'); $log = new PHP_Depend_Log_Summary_Xml(); $log->setLogFile($logFile); $pdepend = new PHP_Depend(); $pdepend->addFile($fileName); $pdepend->addLogger($log); $pdepend->setSupportBadDocumentation(); $pdepend->analyze(); }
/** * testNodeAwareAnalyzer * * @return void */ public function testNodeAwareAnalyzer() { $this->packages = self::parseCodeResourceForTest(); $input = array(array('loc' => 42), array('ncloc' => 23), array('loc' => 9), array('ncloc' => 7), array('loc' => 101), array('ncloc' => 99), array('loc' => 90), array('ncloc' => 80), array('loc' => 50), array('ncloc' => 45), array('loc' => 30), array('ncloc' => 22), array('loc' => 9), array('ncloc' => 9), array('loc' => 3), array('ncloc' => 3), array('loc' => 42), array('ncloc' => 23), array('loc' => 33), array('ncloc' => 20), array('loc' => 9), array('ncloc' => 7)); $metricsOne = array(); $metricsTwo = array(); foreach ($this->packages as $package) { $metricsOne[$package->getUUID()] = array_shift($input); $metricsTwo[$package->getUUID()] = array_shift($input); foreach ($package->getClasses() as $class) { $metricsOne[$class->getUUID()] = array_shift($input); $metricsTwo[$class->getUUID()] = array_shift($input); foreach ($class->getMethods() as $method) { $metricsOne[$method->getUUID()] = array_shift($input); $metricsTwo[$method->getUUID()] = array_shift($input); } } foreach ($package->getFunctions() as $function) { $metricsOne[$function->getUUID()] = array_shift($input); $metricsTwo[$function->getUUID()] = array_shift($input); } } $resultOne = new PHP_Depend_Log_Summary_AnalyzerNodeAwareDummy($metricsOne); $resultTwo = new PHP_Depend_Log_Summary_AnalyzerNodeAwareDummy($metricsTwo); $log = new PHP_Depend_Log_Summary_Xml(); $log->setLogFile($this->resultFile); $log->setCode($this->packages); $log->log($resultOne); $log->log($resultTwo); $log->close(); $fileName = 'node-aware-result-set.xml'; $this->assertXmlStringEqualsXmlString($this->getNormalizedPathXml(dirname(__FILE__) . "/_expected/{$fileName}"), $this->getNormalizedPathXml($this->resultFile)); }
/** * Runs PHP_Depend with the summary logger, against a source file associated * with the given test case. * * @param string $testCase Name of the calling test case. * * @return void */ private function _runForTestCase($testCase) { $uri = $this->createRunResourceURI(__FUNCTION__); $logger = new PHP_Depend_Log_Summary_Xml(); $logger->setLogFile($uri); $pdepend = new PHP_Depend(); $pdepend->addFile(self::getSourceFileForTestCase($testCase)); $pdepend->addLogger($logger); $pdepend->analyze(); $dom = new DOMDocument('1.0', 'UTF-8'); $dom->load($uri); $xpath = new DOMXPath($dom); $result = $xpath->query('//class[@name="RuntimeException"]'); $this->assertEquals(0, $result->length); }
/** * testSummaryReportDoesNotContainEmptyPackages * * @return void * @covers stdClass * @group pdepend * @group pdepend::bugs * @group regressiontest */ public function testSummaryReportDoesNotContainEmptyPackages() { $resultFile = self::createRunResourceURI(__METHOD__); $logger = new PHP_Depend_Log_Summary_Xml(); $logger->setLogFile($resultFile); $pdepend = new PHP_Depend(); $pdepend->addLogger($logger); $pdepend->addFile(self::getSourceFileForTestCase(__METHOD__)); $pdepend->analyze(); $sxml = simplexml_load_file($resultFile); $this->assertSame(array(), $sxml->xpath('//package[@name="+global"]')); }