You are here

public static function PHPUnit_Framework_Assert::assertClassHasAttribute in Zircon Profile 8

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

Asserts that a class has a specified attribute.

@since Method available since Release 3.1.0

Parameters

string $attributeName:

string $className:

string $message:

4 calls to PHPUnit_Framework_Assert::assertClassHasAttribute()
Framework_AssertTest::testAssertClassHasAttributeThrowsException in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertClassHasAttribute @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testAssertClassHasAttributeThrowsException2 in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertClassHasAttribute @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testAssertClassHasAttributeThrowsExceptionIfAttributeNameIsNotValid in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertClassHasAttribute @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testClassHasPublicAttribute in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertClassHasAttribute

File

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

Class

PHPUnit_Framework_Assert
A set of assert methods.

Code

public static function assertClassHasAttribute($attributeName, $className, $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_string($className) || !class_exists($className)) {
    throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className);
  }
  $constraint = new PHPUnit_Framework_Constraint_ClassHasAttribute($attributeName);
  self::assertThat($className, $constraint, $message);
}