assertObjectHasAttribute()
assertObjectHasAttribute(string $attributeName, object $object[, string $message = ''])
Reports an error identified by $message if $object->attributeName does not exist.
assertObjectNotHasAttribute() is the inverse of this assertion and takes the same arguments.
Example A.40: Usage of assertObjectHasAttribute()
<?php
use PHPUnit\Framework\TestCase;
class ObjectHasAttributeTest extends TestCase
{
public function testFailure()
{
$this->assertObjectHasAttribute('foo', new stdClass);
}
}
?>
phpunit ObjectHasAttributeTest PHPUnit 5.6.0 by Sebastian Bergmann and contributors. F Time: 0 seconds, Memory: 4.75Mb There was 1 failure: 1) ObjectHasAttributeTest::testFailure Failed asserting that object of class "stdClass" has attribute "foo". /home/sb/ObjectHasAttributeTest.php:6 FAILURES! Tests: 1, Assertions: 1, Failures: 1.
Please login to continue.