PHPUnit_Framework_Constraint_IsType::toString PHP Method

toString() public method

Returns a string representation of the constraint.
public toString ( ) : string
return string
    public function toString()
    {
        return sprintf('is of type "%s"', $this->type);
    }

Usage Example

示例#1
0
 public function testConstraintIsType()
 {
     $constraint = new PHPUnit_Framework_Constraint_IsType('string');
     $this->assertFalse($constraint->evaluate(0));
     $this->assertTrue($constraint->evaluate(''));
     $this->assertEquals('is of type "string"', $constraint->toString());
     try {
         $constraint->fail(new stdClass(), '');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("Failed asserting that \nstdClass Object\n(\n)\n is of type \"string\".", $e->getDescription());
         return;
     }
     $this->fail();
 }
PHPUnit_Framework_Constraint_IsType