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