The attribute name is passed in the constructor.
Author: Sebastian Bergmann (sebastian@phpunit.de)
Inheritance: extends PHPUnit_Framework_Constraint_ClassHasAttribute
Example #1
0
 public function testFailureObjectHasAttribute2()
 {
     $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute('foo');
     try {
         $constraint->fail(new stdClass(), 'custom message');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that object of class \"stdClass\" has attribute \"foo\".\n", PHPUnit_Framework_TestFailure::exceptionToString($e));
         return;
     }
     $this->fail();
 }
Example #2
0
 public function testConstraintObjectHasAttribute2()
 {
     $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute('foo');
     try {
         $constraint->fail(new stdClass(), 'custom message');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that \nstdClass Object\n(\n)\n has attribute \"foo\".", $e->getDescription());
         return;
     }
     $this->fail();
 }
Example #3
0
 public function testConstraintObjectHasAttribute()
 {
     $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute('foo');
     $this->assertFalse($constraint->evaluate(new stdClass()));
     $this->assertEquals('has attribute "foo"', $constraint->toString());
     try {
         $constraint->fail(new stdClass(), '');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("Failed asserting that \nstdClass Object\n(\n)\n has attribute \"foo\".", $e->getDescription());
         return;
     }
     $this->fail();
 }