PHPUnit_Framework_Assert::objectHasAttribute PHP Method

objectHasAttribute() public static method

Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object.
public static objectHasAttribute ( string $attributeName ) : PHPUnit_Framework_Constraint_ObjectHasAttribute
$attributeName string
return PHPUnit_Framework_Constraint_ObjectHasAttribute
    public static function objectHasAttribute($attributeName)
    {
        return new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName);
    }

Usage Example

 /**
  * @covers PHPUnit_Framework_Constraint_ObjectHasAttribute
  * @covers PHPUnit_Framework_Constraint_Not
  * @covers PHPUnit_Framework_Assert::objectHasAttribute
  * @covers PHPUnit_Framework_Assert::logicalNot
  */
 public function testConstraintObjectNotHasAttribute2()
 {
     $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::objectHasAttribute('foo'));
     $o = new stdClass();
     $o->foo = 'bar';
     try {
         $constraint->fail($o, 'custom message', TRUE);
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that object of class \"stdClass\" does not have attribute \"foo\".", $e->getDescription());
         return;
     }
     $this->fail();
 }
All Usage Examples Of PHPUnit_Framework_Assert::objectHasAttribute
PHPUnit_Framework_Assert