public function testEnablingAndDisablingTriggersNeccessaryState() { $line = new CoveredLine(""); $line->setNeccessary(true); $line->addCoverage(""); $this->assertTrue($line->isEnabled()); $line->disable(); $this->assertFalse($line->isEnabled()); $this->assertFalse($line->isNeccessary()); $this->assertTrue($line->isCovered()); $line->enable(); $this->assertTrue($line->isEnabled()); $this->assertTrue($line->isNeccessary()); $this->assertTrue($line->isCovered()); }
public function testMutatorFindsLinesThatAreOnlyNeccessaryWhenAFollowingOneExists() { $line0 = new CoveredLine('$c=0;'); $line0->addCoverage(""); $line1 = new CoveredLine('$c++;'); $line1->addCoverage(""); $this->assertTrue($line0->isEnabled()); $this->assertTrue($line1->isEnabled()); $class = $this->mockClass(array($line0, $line1)); $generator = new MutationGenerator($class); //tester will only validate if everything is enabled or line1 AND line3 are disabled $validatorCallback = function () use($line0, $line1) { if ($line0->isEnabled()) { return true; } return !$line1->isEnabled(); // line0 enabled or both disabled }; $tester = $this->mockTester($validatorCallback); $mutator = new Mutator(); $mutator->testMutations($tester, $generator); $this->assertFalse($line0->isEnabled()); $this->assertFalse($line1->isEnabled()); }