Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 /**
  * @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();
 }