|
@@ 972-999 (lines=28) @@
|
| 969 |
|
* @covers PHPUnit_Framework_Constraint::count |
| 970 |
|
* @covers PHPUnit_Framework_TestFailure::exceptionToString |
| 971 |
|
*/ |
| 972 |
|
public function testConstraintIsIdentical() |
| 973 |
|
{ |
| 974 |
|
$a = new stdClass; |
| 975 |
|
$b = new stdClass; |
| 976 |
|
|
| 977 |
|
$constraint = PHPUnit_Framework_Assert::identicalTo($a); |
| 978 |
|
|
| 979 |
|
$this->assertFalse($constraint->evaluate($b, '', true)); |
| 980 |
|
$this->assertTrue($constraint->evaluate($a, '', true)); |
| 981 |
|
$this->assertEquals('is identical to an object of class "stdClass"', $constraint->toString()); |
| 982 |
|
$this->assertEquals(1, count($constraint)); |
| 983 |
|
|
| 984 |
|
try { |
| 985 |
|
$constraint->evaluate($b); |
| 986 |
|
} catch (PHPUnit_Framework_ExpectationFailedException $e) { |
| 987 |
|
$this->assertEquals(<<<EOF |
| 988 |
|
Failed asserting that two variables reference the same object. |
| 989 |
|
|
| 990 |
|
EOF |
| 991 |
|
, |
| 992 |
|
PHPUnit_Framework_TestFailure::exceptionToString($e) |
| 993 |
|
); |
| 994 |
|
|
| 995 |
|
return; |
| 996 |
|
} |
| 997 |
|
|
| 998 |
|
$this->fail(); |
| 999 |
|
} |
| 1000 |
|
|
| 1001 |
|
/** |
| 1002 |
|
* @covers PHPUnit_Framework_Constraint_IsIdentical |
|
@@ 1070-1099 (lines=30) @@
|
| 1067 |
|
* @covers PHPUnit_Framework_Assert::logicalNot |
| 1068 |
|
* @covers PHPUnit_Framework_TestFailure::exceptionToString |
| 1069 |
|
*/ |
| 1070 |
|
public function testConstraintIsNotIdentical() |
| 1071 |
|
{ |
| 1072 |
|
$a = new stdClass; |
| 1073 |
|
$b = new stdClass; |
| 1074 |
|
|
| 1075 |
|
$constraint = PHPUnit_Framework_Assert::logicalNot( |
| 1076 |
|
PHPUnit_Framework_Assert::identicalTo($a) |
| 1077 |
|
); |
| 1078 |
|
|
| 1079 |
|
$this->assertTrue($constraint->evaluate($b, '', true)); |
| 1080 |
|
$this->assertFalse($constraint->evaluate($a, '', true)); |
| 1081 |
|
$this->assertEquals('is not identical to an object of class "stdClass"', $constraint->toString()); |
| 1082 |
|
$this->assertEquals(1, count($constraint)); |
| 1083 |
|
|
| 1084 |
|
try { |
| 1085 |
|
$constraint->evaluate($a); |
| 1086 |
|
} catch (PHPUnit_Framework_ExpectationFailedException $e) { |
| 1087 |
|
$this->assertEquals(<<<EOF |
| 1088 |
|
Failed asserting that two variables don't reference the same object. |
| 1089 |
|
|
| 1090 |
|
EOF |
| 1091 |
|
, |
| 1092 |
|
$this->trimnl(PHPUnit_Framework_TestFailure::exceptionToString($e)) |
| 1093 |
|
); |
| 1094 |
|
|
| 1095 |
|
return; |
| 1096 |
|
} |
| 1097 |
|
|
| 1098 |
|
$this->fail(); |
| 1099 |
|
} |
| 1100 |
|
|
| 1101 |
|
/** |
| 1102 |
|
* @covers PHPUnit_Framework_Constraint_IsIdentical |
|
@@ 3015-3043 (lines=29) @@
|
| 3012 |
|
* @covers PHPUnit_Framework_Constraint::count |
| 3013 |
|
* @covers PHPUnit_Framework_TestFailure::exceptionToString |
| 3014 |
|
*/ |
| 3015 |
|
public function testConstraintSplObjectStorageContains() |
| 3016 |
|
{ |
| 3017 |
|
$object = new StdClass; |
| 3018 |
|
$constraint = new PHPUnit_Framework_Constraint_TraversableContains($object); |
| 3019 |
|
$this->assertStringMatchesFormat('contains stdClass Object &%s ()', $constraint->toString()); |
| 3020 |
|
|
| 3021 |
|
$storage = new SplObjectStorage; |
| 3022 |
|
$this->assertFalse($constraint->evaluate($storage, '', true)); |
| 3023 |
|
|
| 3024 |
|
$storage->attach($object); |
| 3025 |
|
$this->assertTrue($constraint->evaluate($storage, '', true)); |
| 3026 |
|
|
| 3027 |
|
try { |
| 3028 |
|
$constraint->evaluate(new SplObjectStorage); |
| 3029 |
|
} catch (PHPUnit_Framework_ExpectationFailedException $e) { |
| 3030 |
|
$this->assertStringMatchesFormat( |
| 3031 |
|
<<<EOF |
| 3032 |
|
Failed asserting that a traversable contains stdClass Object &%x (). |
| 3033 |
|
|
| 3034 |
|
EOF |
| 3035 |
|
, |
| 3036 |
|
PHPUnit_Framework_TestFailure::exceptionToString($e) |
| 3037 |
|
); |
| 3038 |
|
|
| 3039 |
|
return; |
| 3040 |
|
} |
| 3041 |
|
|
| 3042 |
|
$this->fail(); |
| 3043 |
|
} |
| 3044 |
|
|
| 3045 |
|
/** |
| 3046 |
|
* @covers PHPUnit_Framework_Constraint_TraversableContains |