You are here

public static function PHPUnit_Framework_Assert::assertObjectHasAttribute in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/Assert.php \PHPUnit_Framework_Assert::assertObjectHasAttribute()

Asserts that an object has a specified attribute.

@since Method available since Release 3.0.0

Parameters

string $attributeName:

object $object:

string $message:

8 calls to PHPUnit_Framework_Assert::assertObjectHasAttribute()
Framework_AssertTest::testAssertObjectHasAttribute in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertObjectHasAttribute
Framework_AssertTest::testAssertObjectHasAttributeThrowsException in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertObjectHasAttribute @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testAssertObjectHasAttributeThrowsException2 in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertObjectHasAttribute @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testAssertObjectHasAttributeThrowsExceptionIfAttributeNameIsNotValid in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertObjectHasAttribute @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testObjectHasOnTheFlyAttribute in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertObjectHasAttribute

... See full list

File

vendor/phpunit/phpunit/src/Framework/Assert.php, line 1106

Class

PHPUnit_Framework_Assert
A set of assert methods.

Code

public static function assertObjectHasAttribute($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_ObjectHasAttribute($attributeName);
  self::assertThat($object, $constraint, $message);
}