lithium\test\Unit::assertClassHasAttribute()

public method

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

boolean

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