classHasStaticAttribute() public static méthode

Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher object.
public static classHasStaticAttribute ( string $attributeName ) : PHPUnit_Framework_Constraint_ClassHasStaticAttribute
$attributeName string
Résultat PHPUnit_Framework_Constraint_ClassHasStaticAttribute
 /**
  * @covers PHPUnit_Framework_Constraint_ClassHasStaticAttribute
  * @covers PHPUnit_Framework_Constraint_Not
  * @covers PHPUnit_Framework_Assert::classHasStaticAttribute
  * @covers PHPUnit_Framework_Assert::logicalNot
  */
 public function testConstraintClassNotHasStaticAttribute2()
 {
     $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::classHasStaticAttribute('notExistingAttribute'));
     try {
         $constraint->fail('ClassWithNonPublicAttributes', 'custom message', TRUE);
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that class \"ClassWithNonPublicAttributes\" does not have static attribute \"notExistingAttribute\".", $e->getDescription());
         return;
     }
     $this->fail();
 }
Exemple #2
0
/**
 * Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher
 * object.
 *
 * @param  string $attributeName
 * @return PHPUnit_Framework_Constraint_ClassHasStaticAttribute
 * @since  Method available since Release 3.1.0
 */
function classHasStaticAttribute($attributeName)
{
    return PHPUnit_Framework_Assert::classHasStaticAttribute($attributeName);
}
    /**
     * @covers PHPUnit_Framework_Constraint_ClassHasStaticAttribute
     * @covers PHPUnit_Framework_Constraint_Not
     * @covers PHPUnit_Framework_Assert::classHasStaticAttribute
     * @covers PHPUnit_Framework_Assert::logicalNot
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
     */
    public function testConstraintClassNotHasStaticAttribute2()
    {
        $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::classHasStaticAttribute('privateStaticAttribute'));
        try {
            $constraint->evaluate('ClassWithNonPublicAttributes', 'custom message');
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
            $this->assertEquals(<<<EOF
custom message
Failed asserting that class "ClassWithNonPublicAttributes" does not have static attribute "privateStaticAttribute".

EOF
, PHPUnit_Framework_TestFailure::exceptionToString($e));
            return;
        }
        $this->fail();
    }