lithium\test\Unit::assertObjectHasAttribute()
Assert that $object
has given attribute.
$this->assertObjectHasAttribute('__construct', 'ReflectionClass'); // succeeds
$this->assertObjectHasAttribute('name', 'ReflectionClass'); // fails
Parameters
-
string
$attributeName
-
string
$object
-
string|boolean
$message
Returns
booleantrue
if the assertion succeeded, false
otherwise.
Source
public function assertObjectHasAttribute($attributeName, $object, $message = '{:message}') {
if (!is_object($object)) {
throw new InvalidArgumentException('Second argument $object must be an object.');
}
$object = new ReflectionClass($object);
return $this->assert($object->hasProperty($attributeName), $message, [
'expected' => $attributeName,
'result' => $object->getProperties()
]);
}