lithium\test\Unit::assertClassHasStaticAttribute()
Assert that a class does have a given static attribute.
$this->assertClassHasStaticAttribute('_methodFilters', '\lithium\core\StaticObjectDeprecated'); // succeeds
$this->assertClassHasStaticAttribute('foobar', '\lithium\core\StaticObjectDeprecated'); // fails
Parameters
-
mixed
$attributeName
-
string
$class
-
string|boolean
$message
Returns
booleantrue
if the assertion succeeded, false
otherwise.
Source
public function assertClassHasStaticAttribute($attributeName, $class, $message = '{:message}') {
$object = new ReflectionClass($class);
if ($object->hasProperty($attributeName)) {
$attribute = $object->getProperty($attributeName);
return $this->assert($attribute->isStatic(), $message, [
'expected' => $attributeName,
'result' => $object->getProperties()
]);
}
return $this->assert(false, $message, [
'expected' => $attributeName,
'result' => $object->getProperties()
]);
}