Mutagenesis\Mutable::hasMutation PHP Method

hasMutation() public method

Check whether the current file will contain a mutation of the given type
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;
    }

Usage Example

Example #1
0
 /**
  * @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'));
 }