lithium\test\Unit::assertClassNotHasAttribute()

public method

Assert that a class does not have a given attribute.

$this->assertClassNotHasAttribute('name', 'ReflectionClass'); // succeeds
$this->assertClassNotHasAttribute('__construct', 'ReflectionClass'); // fails

Parameters

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

Returns

boolean

true if the assertion succeeded, false otherwise.

Source

	public function assertClassNotHasAttribute($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()
		]);
	}