PHPUnit_Framework_Constraint_ArrayHasKey::evaluate PHP 메소드

evaluate() 공개 메소드

Evaluates the constraint for parameter $other. Returns TRUE if the constraint is met, FALSE otherwise.
public evaluate ( mixed $other ) : boolean
$other mixed Value or object to evaluate.
리턴 boolean
    public function evaluate($other)
    {
        return array_key_exists($this->key, $other);
    }

Usage Example

예제 #1
0
 public function testConstraintArrayHasKey()
 {
     $constraint = new PHPUnit_Framework_Constraint_ArrayHasKey(0);
     $this->assertFalse($constraint->evaluate(array()));
     $this->assertEquals('has key <integer:0>', $constraint->toString());
     try {
         $constraint->fail(array(), '');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("Failed asserting that \nArray\n(\n)\n has key <integer:0>.", $e->getDescription());
         return;
     }
     $this->fail();
 }
All Usage Examples Of PHPUnit_Framework_Constraint_ArrayHasKey::evaluate