|
@@ 3078-3107 (lines=30) @@
|
| 3075 |
|
* @covers PHPUnit_Framework_Constraint_Attribute |
| 3076 |
|
* @covers PHPUnit_Framework_TestFailure::exceptionToString |
| 3077 |
|
*/ |
| 3078 |
|
public function testAttributeEqualTo() |
| 3079 |
|
{ |
| 3080 |
|
$object = new ClassWithNonPublicAttributes; |
| 3081 |
|
$constraint = PHPUnit_Framework_Assert::attributeEqualTo('foo', 1); |
| 3082 |
|
|
| 3083 |
|
$this->assertTrue($constraint->evaluate($object, '', true)); |
| 3084 |
|
$this->assertEquals('attribute "foo" is equal to 1', $constraint->toString()); |
| 3085 |
|
$this->assertEquals(1, count($constraint)); |
| 3086 |
|
|
| 3087 |
|
$constraint = PHPUnit_Framework_Assert::attributeEqualTo('foo', 2); |
| 3088 |
|
|
| 3089 |
|
$this->assertFalse($constraint->evaluate($object, '', true)); |
| 3090 |
|
|
| 3091 |
|
try { |
| 3092 |
|
$constraint->evaluate($object); |
| 3093 |
|
} catch (PHPUnit_Framework_ExpectationFailedException $e) { |
| 3094 |
|
$this->assertEquals( |
| 3095 |
|
<<<EOF |
| 3096 |
|
Failed asserting that attribute "foo" is equal to 2. |
| 3097 |
|
|
| 3098 |
|
EOF |
| 3099 |
|
, |
| 3100 |
|
PHPUnit_Framework_TestFailure::exceptionToString($e) |
| 3101 |
|
); |
| 3102 |
|
|
| 3103 |
|
return; |
| 3104 |
|
} |
| 3105 |
|
|
| 3106 |
|
$this->fail(); |
| 3107 |
|
} |
| 3108 |
|
|
| 3109 |
|
/** |
| 3110 |
|
* @covers PHPUnit_Framework_Assert::attributeEqualTo |
|
@@ 3144-3177 (lines=34) @@
|
| 3141 |
|
* @covers PHPUnit_Framework_Constraint_Not |
| 3142 |
|
* @covers PHPUnit_Framework_TestFailure::exceptionToString |
| 3143 |
|
*/ |
| 3144 |
|
public function testAttributeNotEqualTo() |
| 3145 |
|
{ |
| 3146 |
|
$object = new ClassWithNonPublicAttributes; |
| 3147 |
|
$constraint = PHPUnit_Framework_Assert::logicalNot( |
| 3148 |
|
PHPUnit_Framework_Assert::attributeEqualTo('foo', 2) |
| 3149 |
|
); |
| 3150 |
|
|
| 3151 |
|
$this->assertTrue($constraint->evaluate($object, '', true)); |
| 3152 |
|
$this->assertEquals('attribute "foo" is not equal to 2', $constraint->toString()); |
| 3153 |
|
$this->assertEquals(1, count($constraint)); |
| 3154 |
|
|
| 3155 |
|
$constraint = PHPUnit_Framework_Assert::logicalNot( |
| 3156 |
|
PHPUnit_Framework_Assert::attributeEqualTo('foo', 1) |
| 3157 |
|
); |
| 3158 |
|
|
| 3159 |
|
$this->assertFalse($constraint->evaluate($object, '', true)); |
| 3160 |
|
|
| 3161 |
|
try { |
| 3162 |
|
$constraint->evaluate($object); |
| 3163 |
|
} catch (PHPUnit_Framework_ExpectationFailedException $e) { |
| 3164 |
|
$this->assertEquals( |
| 3165 |
|
<<<EOF |
| 3166 |
|
Failed asserting that attribute "foo" is not equal to 1. |
| 3167 |
|
|
| 3168 |
|
EOF |
| 3169 |
|
, |
| 3170 |
|
PHPUnit_Framework_TestFailure::exceptionToString($e) |
| 3171 |
|
); |
| 3172 |
|
|
| 3173 |
|
return; |
| 3174 |
|
} |
| 3175 |
|
|
| 3176 |
|
$this->fail(); |
| 3177 |
|
} |
| 3178 |
|
|
| 3179 |
|
/** |
| 3180 |
|
* @covers PHPUnit_Framework_Assert::attributeEqualTo |