/** * Tests the generated package metrics. * * @return void */ public function testGenerateMetrics() { $visitor = new DependencyAnalyzer(); $namespaces = self::parseCodeResourceForTest(); $visitor->analyze($namespaces); $actual = array(); foreach ($namespaces as $namespace) { $actual[$namespace->getName()] = $visitor->getStats($namespace); } $this->assertEquals($this->input, $actual); }
/** * Tests that {@link \PDepend\Report\Jdepend\Xml::write()} generates the * expected document structure for the source, but without any applied * metrics. * * @return void */ public function testXmlLogWithoutMetrics() { $this->packages = self::parseCodeResourceForTest(); $this->analyzer = new DependencyAnalyzer(); $this->analyzer->analyze($this->packages); $log = new Xml(); $log->setLogFile($this->resultFile); $log->setArtifacts($this->packages); $log->log($this->analyzer); $log->close(); $fileName = 'pdepend-log' . CORE_PACKAGE . '.xml'; $this->assertXmlStringEqualsXmlString($this->getNormalizedPathXml(dirname(__FILE__) . "/_expected/{$fileName}"), file_get_contents($this->resultFile)); }
/** * Tests that the logger generates an image file. * * @return void */ public function testGeneratesImageFile() { if (extension_loaded('imagick') === false) { $this->markTestSkipped('No pecl/imagick extension.'); } $fileName = self::createRunResourceURI('jdepend-test-out.png'); if (file_exists($fileName)) { unlink($fileName); } $nodes = new ASTArtifactList($this->_createPackages(true, true)); $analyzer = new DependencyAnalyzer(); $analyzer->analyze($nodes); $logger = new Chart(); $logger->setLogFile($fileName); $logger->setArtifacts($nodes); $logger->log($analyzer); $this->assertFileNotExists($fileName); $logger->close(); $this->assertFileExists($fileName); $info = getimagesize($fileName); $this->assertEquals(390, $info[0]); $this->assertEquals(250, $info[1]); $this->assertEquals('image/png', $info['mime']); unlink($fileName); }