attributeEqualTo() public static method

Returns a PHPUnit_Framework_Constraint_IsEqual matcher object that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher object.
public static attributeEqualTo ( string $attributeName, mixed $value, float $delta, integer $maxDepth = 10, boolean $canonicalize = false, boolean $ignoreCase = false ) : PHPUnit_Framework_Constraint_Attribute
$attributeName string
$value mixed
$delta float
$maxDepth integer
$canonicalize boolean
$ignoreCase boolean
return PHPUnit_Framework_Constraint_Attribute
 /**
  * @covers PHPUnit_Framework_Assert::attributeEqualTo
  * @covers PHPUnit_Framework_Assert::logicalNot
  * @covers PHPUnit_Framework_Constraint_Attribute
  * @covers PHPUnit_Framework_Constraint_Not
  */
 public function testAttributeNotEqualTo2()
 {
     $object = new ClassWithNonPublicAttributes();
     $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::attributeEqualTo('foo', 1));
     try {
         $constraint->fail($object, 'custom message', TRUE);
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that attribute \"foo\" is not equal to <integer:1>.", $e->getDescription());
         return;
     }
     $this->fail();
 }
Esempio n. 2
0
/**
 * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object
 * that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher
 * object.
 *
 * @param  string  $attributeName
 * @param  mixed   $value
 * @param  float   $delta
 * @param  integer $maxDepth
 * @param  boolean $canonicalize
 * @param  boolean $ignoreCase
 * @return PHPUnit_Framework_Constraint_Attribute
 * @since  Method available since Release 3.1.0
 */
function attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE)
{
    return PHPUnit_Framework_Assert::attributeEqualTo($attributeName, $value, $delta, $maxDepth, $canonicalize, $ignoreCase);
}
    /**
     * @covers PHPUnit_Framework_Assert::attributeEqualTo
     * @covers PHPUnit_Framework_Assert::logicalNot
     * @covers PHPUnit_Framework_Constraint_Attribute
     * @covers PHPUnit_Framework_Constraint_Not
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
     */
    public function testAttributeNotEqualTo2()
    {
        $object = new ClassWithNonPublicAttributes();
        $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::attributeEqualTo('foo', 1));
        try {
            $constraint->evaluate($object, 'custom message');
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
            $this->assertEquals(<<<EOF
custom message
Failed asserting that attribute "foo" is not equal to 1.

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