lithium\test\Unit::assertObjectHasAttribute()

public method

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

boolean

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