public hasMutation ( string $type ) : boolean | ||
$type | string | The mutation type as documented |
return | boolean |
public function hasMutation($type)
{
$typeClass = '\\Mutagenesis\\Mutation\\' . $type;
// I know, wtf?!
$mutations = array_values(array_values(array_values($this->getMutations())));
foreach ($mutations as $mutation) {
if ($mutation instanceof $typeClass) {
return true;
}
}
return false;
}
/** * @test */ public function shouldGenerateBooleanFalseMutationWhenBoolFalseDetected() { $file = new Mutable($this->root . '/bool2.php'); $file->generate(); $mutants = $file->getMutants()->all(); $mutants->rewind(); $mutant = $mutants->current(); $this->assertEquals(1, count($mutants)); $this->assertInstanceOf('\\Mutagenesis\\Mutation\\BooleanFalse', $mutant->getMutation()); $this->assertTrue($file->hasMutation('BooleanFalse')); $this->assertFalse($file->hasMutation('OperatorAddition')); }