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);
 }
 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());
 }
 public function testParseReportsSkippsClassesWithParserExceptions()
 {
     $parser = $this->getMock('PHPRealCoverage\\Parser\\ClassParser');
     $parser->expects($this->any())->method('parse')->will($this->throwException(new ParserException()));
     $reader = new ParsingCoverageReader($parser);
     ob_start();
     $classes = $reader->parseReport($this->generateCoverageForFixture());
     ob_end_clean();
     $this->assertEquals(0, count($classes));
 }