コード例 #1
0
 public function run($input, $output = 'real-coverage-html')
 {
     $report = unserialize(file_get_contents($input));
     $reader = new ParsingCoverageReader();
     $classes = $reader->parseReport($report);
     $mutator = new Mutator();
     $testRunner = new PHPUnitRunner(new MultirunTestCommand(), array('tests', 'tests'));
     $writer = new RealCoverageModifier($report);
     $proxyFactory = new ProxyFactory($classes);
     $autoloader = new ProxyAutoloader($proxyFactory);
     $autoloader->register();
     $classCounter = 0;
     /** @var ClassMetadata $class */
     foreach ($classes as $class) {
         if (!$class->isCovered()) {
             continue;
         }
         echo "\n" . (int) (++$classCounter * 100 / count($classes)) . "%: Processing " . $class->getName() . "\n";
         $this->calculateRealCoverage($class, $proxyFactory, $testRunner, $mutator);
         $writer->write($class);
     }
     $autoloader->unregister();
     echo "\n\nWriting coverage report to " . $output . "\n";
     $htmlWriter = new \PHP_CodeCoverage_Report_HTML();
     $htmlWriter->process($report, $output);
 }
コード例 #2
0
 /**
  * @dataProvider executableInformationDataProvider
  */
 public function testPopulateLineAddsExecutableInformation($tests, $executable)
 {
     $line = new CoveredLine("");
     $reader = new ParsingCoverageReader();
     $reader->populateLine($line, $tests);
     $this->assertEquals($executable, $line->isExecutable());
 }
コード例 #3
0
 public function testModifierRemovesCoverageFromUnneccessaryLines()
 {
     $coverage = $this->generateCoverageForFixture();
     $reader = new ParsingCoverageReader();
     $classes = $reader->parseReport($coverage);
     /** @var ClassMetadata $class */
     $class = $classes[0];
     $this->assertTrue($class->getLine(8)->isCovered());
     $class->getLine(8)->setNeccessary(false);
     $writer = new RealCoverageModifier($coverage);
     $writer->write($class);
     $classes = $reader->parseReport($coverage);
     $class = $classes[0];
     $this->assertFalse($class->getLine(8)->isCovered());
     $this->assertTrue($class->getLine(9)->isCovered());
     $this->assertFalse($class->getLine(10)->isCovered());
     $this->assertFalse($class->getLine(10)->isExecutable());
 }