public function __construct(Mutation $mutation, FileGenerator $generator, CoverageData $coverage, $baseDirectory) { $this->mutation = $mutation; try { $this->tests = $coverage->getTestClasses($mutation->getFile(), $mutation->getLine()); $this->testMethods = $coverage->getTestMethods($mutation->getFile(), $mutation->getLine()); } catch (NoCoveringTestsException $e) { $this->tests = []; $this->testMethods = []; } $this->file = $generator->generateFile($mutation); $this->baseDirectory = $baseDirectory; $this->diff = Diff::getInstance(); }
/** * @param CoverageData $coverage * @param MutableIterator $mutables */ public function run(CoverageData $coverage, MutableIterator $mutables, IncrementalCache $cache = null) { $this->mutableCount = count($mutables); $this->onStartRun(); $collector = new Collector(); $partition = new PartitionBuilder(); /** * MUTATION TESTING! */ foreach ($mutables as $index => $mutable) { if (!is_null($cache)) { $cache->setResultCollector($collector); $cache->getFileCollector()->collect($mutable->getFilename()); } $mutations = $mutable->generate()->getMutations(); $partition->addMutations($mutable, $index, $mutations); $this->onProcessedMutable($mutable); $mutable->cleanup(); } $this->onMutationsGenerated(); foreach ($partition->getPartitions($this->threadCount) as $batch) { $this->runBatch($collector, $coverage, $batch, $cache); } $coverage->cleanup(); $this->onEndRun($collector); $this->mutantGenerator->cleanup(); }