/** * testAnalyzerIgnoresFilesWithoutFileName * * @return void * @covers PHP_Depend_Metrics_NodeLoc_Analyzer * @group pdepend * @group pdepend::metrics * @group pdepend::metrics::nodeloc * @group unittest */ public function testAnalyzerIgnoresFilesWithoutFileName() { $file = new PHP_Depend_Code_File(null); $file->setUUID(42); $analyzer = new PHP_Depend_Metrics_NodeLoc_Analyzer(); $analyzer->visitFile($file); $metrics = $analyzer->getNodeMetrics($file); $this->assertEquals(array(), $metrics); }
/** * Tests that the analyzer calculates the correct interface and file * loc values. * * @return void */ public function testAnalyzerCalculatesCorrectInterfaceAndFileLoc() { $packages = self::parseTestCaseSource(__METHOD__); $analyzer = new PHP_Depend_Metrics_NodeLoc_Analyzer(); $analyzer->analyze($packages); $packages->rewind(); $interface = $packages->current()->getInterfaces()->current(); $actual = $analyzer->getNodeMetrics($interface); $expected = array('loc' => 17, 'cloc' => 7, 'eloc' => 6, 'ncloc' => 10); $this->assertEquals($expected, $actual); $actual = $analyzer->getNodeMetrics($interface->getSourceFile()); $expected = array('loc' => 21, 'cloc' => 10, 'eloc' => 8, 'ncloc' => 11); $this->assertEquals($expected, $actual); }
/** * testCalculatesExpectedLLocForDoWhileStatement * * @return void * @covers PHP_Depend_Metrics_NodeLoc_Analyzer * @group pdepend * @group pdepend::metrics * @group pdepend::metrics::nodeloc * @group unittest */ public function testCalculatesExpectedLLocForDoWhileStatement() { $packages = self::parseTestCaseSource(__METHOD__); $function = $packages->current()->getFunctions()->current(); $analyzer = new PHP_Depend_Metrics_NodeLoc_Analyzer(); $analyzer->analyze($packages); $metrics = $analyzer->getNodeMetrics($function); $this->assertEquals(3, $metrics['lloc']); }