lithium\test\Unit::assertClassHasStaticAttribute()

public method

Assert that a class does have a given static attribute.

$this->assertClassHasStaticAttribute('_methodFilters', '\lithium\core\StaticObject'); // succeeds
$this->assertClassHasStaticAttribute('foobar', '\lithium\core\StaticObject'); // fails

Parameters

  • mixed $attributeName
  • string $class
  • string|boolean $message

Returns

boolean

true 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()
		]);
	}