PHPUnit_Framework_Assert::assertObjectNotHasAttribute PHP Method

assertObjectNotHasAttribute() public static method

Asserts that an object does not have a specified attribute.
public static assertObjectNotHasAttribute ( string $attributeName, object $object, string $message = '' )
$attributeName string
$object object
$message string
    public static function assertObjectNotHasAttribute($attributeName, $object, $message = '')
    {
        if (!is_string($attributeName)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
        }
        if (!preg_match('/[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/', $attributeName)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name');
        }
        if (!is_object($object)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object');
        }
        $constraint = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName));
        static::assertThat($object, $constraint, $message);
    }

Usage Example

Esempio n. 1
0
 public function testCreate()
 {
     $directory = new FooDirectory($this->getMongoDB());
     $model = $directory->create(['memoryOnly' => 'yes']);
     PHPUnit::assertObjectNotHasAttribute('_id', $model);
     PHPUnit::assertEquals('yes', $model['memoryOnly']);
 }
All Usage Examples Of PHPUnit_Framework_Assert::assertObjectNotHasAttribute
PHPUnit_Framework_Assert