Inheritance: extends PHPUnit_Framework_Constraint
コード例 #1
0
 /**
  * @inheritdoc
  */
 protected function failureDescription($other)
 {
     if ($other instanceof EquatableMap) {
         return 'an equatable map ' . $this->toString();
     }
     if ($other instanceof EquatableVector) {
         return 'an equatable vector ' . $this->toString();
     }
     return parent::failureDescription($other);
 }
コード例 #2
0
 /**
  * @covers PHPUnit_Framework_Constraint_TraversableContains
  */
 public function testConstraintSplObjectStorageContains2()
 {
     $object = new StdClass();
     $constraint = new PHPUnit_Framework_Constraint_TraversableContains($object);
     try {
         $constraint->fail(new SplObjectStorage(), 'custom message');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that an iterator contains \nstdClass Object\n(\n)\n.", $e->getDescription());
         return;
     }
     $this->fail();
 }
コード例 #3
0
    /**
     * @covers PHPUnit_Framework_Constraint_TraversableContains
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
     */
    public function testConstraintSplObjectStorageContains2()
    {
        $object = new StdClass();
        $constraint = new PHPUnit_Framework_Constraint_TraversableContains($object);
        try {
            $constraint->evaluate(new SplObjectStorage(), 'custom message');
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
            $this->assertStringMatchesFormat(<<<EOF
custom message
Failed asserting that a traversable contains stdClass Object &%x ().

EOF
, PHPUnit_Framework_TestFailure::exceptionToString($e));
            return;
        }
        $this->fail();
    }
コード例 #4
0
 public function testConstraintTraversableContains2()
 {
     $constraint = new PHPUnit_Framework_Constraint_TraversableContains('foo');
     try {
         $constraint->fail(array('bar'), 'custom message');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that \nArray\n(\n    [0] => bar\n)\n contains <string:foo>.", $e->getDescription());
         return;
     }
     $this->fail();
 }
コード例 #5
0
ファイル: TestFailureTest.php プロジェクト: swk/bluebox
 public function testFailureTraversableContains2()
 {
     $constraint = new PHPUnit_Framework_Constraint_TraversableContains('foo');
     try {
         $constraint->fail(array('bar'), 'custom message');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that an array contains <string:foo>.\n", PHPUnit_Framework_TestFailure::exceptionToString($e));
         return;
     }
     $this->fail();
 }
コード例 #6
0
 public function testConstraintTraversableContains()
 {
     $constraint = new PHPUnit_Framework_Constraint_TraversableContains('foo');
     $this->assertFalse($constraint->evaluate(array('bar')));
     $this->assertTrue($constraint->evaluate(array('foo')));
     $this->assertEquals('contains <string:foo>', $constraint->toString());
     try {
         $constraint->fail(array('bar'), '');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("Failed asserting that \nArray\n(\n    [0] => bar\n)\n contains <string:foo>.", $e->getDescription());
         return;
     }
     $this->fail();
 }