PHPUnit_Framework_Constraint_StringContains::toString PHP Method

toString() public method

Returns a string representation of the constraint.
public toString ( ) : string
return string
    public function toString()
    {
        if ($this->ignoreCase) {
            $string = strtolower($this->string);
        } else {
            $string = $this->string;
        }
        return sprintf('contains "%s"', $string);
    }

Usage Example

コード例 #1
0
 public function testConstraintStringContains()
 {
     $constraint = new PHPUnit_Framework_Constraint_StringContains('foo');
     $this->assertFalse($constraint->evaluate('barbazbar'));
     $this->assertTrue($constraint->evaluate('barfoobar'));
     $this->assertEquals('contains "foo"', $constraint->toString());
     try {
         $constraint->fail('barbazbar', '');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals('Failed asserting that <string:barbazbar> contains "foo".', $e->getDescription());
         return;
     }
     $this->fail();
 }
PHPUnit_Framework_Constraint_StringContains