Exemplo n.º 1
0
 /**
  * Creates the package structure from a test source file.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->packages = self::parseSource(dirname(__FILE__) . '/../../_code/code-5.2.x');
     $this->analyzer = new PHP_Depend_Metrics_Dependency_Analyzer();
     $this->analyzer->analyze($this->packages);
     $this->resultFile = self::createRunResourceURI('pdepend-log.xml');
 }
Exemplo n.º 2
0
 /**
  * Tests that {@link PHP_Depend_Log_Summary_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 PHP_Depend_Metrics_Dependency_Analyzer();
     $this->analyzer->analyze($this->packages);
     $log = new PHP_Depend_Log_Jdepend_Xml();
     $log->setLogFile($this->resultFile);
     $log->setCode($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));
 }
Exemplo n.º 3
0
 /**
  * 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 PHP_Depend_Code_NodeIterator($this->_createPackages(true, true));
     $analyzer = new PHP_Depend_Metrics_Dependency_Analyzer();
     $analyzer->analyze($nodes);
     $logger = new PHP_Depend_Log_Jdepend_Chart();
     $logger->setLogFile($fileName);
     $logger->setCode($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);
 }
Exemplo n.º 4
0
 /**
  * Tests the generated package metrics.
  *
  * @return void
  */
 public function testGenerateMetrics()
 {
     $visitor = new PHP_Depend_Metrics_Dependency_Analyzer();
     $packages = self::parseCodeResourceForTest();
     $visitor->analyze($packages);
     $actual = array();
     foreach ($packages as $package) {
         $actual[$package->getName()] = $visitor->getStats($package);
     }
     self::assertEquals($this->_input, $actual);
 }