| @@ 116-139 (lines=24) @@ | ||
| 113 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 114 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 115 | */ |
|
| 116 | public function testConstraintArrayNotHasKey2() |
|
| 117 | { |
|
| 118 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 119 | PHPUnit_Framework_Assert::arrayHasKey(0) |
|
| 120 | ); |
|
| 121 | ||
| 122 | try { |
|
| 123 | $constraint->evaluate(array(0), 'custom message'); |
|
| 124 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 125 | $this->assertEquals( |
|
| 126 | <<<EOF |
|
| 127 | custom message |
|
| 128 | Failed asserting that an array does not have the key 0. |
|
| 129 | ||
| 130 | EOF |
|
| 131 | , |
|
| 132 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 133 | ); |
|
| 134 | ||
| 135 | return; |
|
| 136 | } |
|
| 137 | ||
| 138 | $this->fail(); |
|
| 139 | } |
|
| 140 | ||
| 141 | /** |
|
| 142 | * @covers PHPUnit_Framework_Constraint_FileExists |
|
| @@ 373-396 (lines=24) @@ | ||
| 370 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 371 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 372 | */ |
|
| 373 | public function testConstraintNotGreaterThan2() |
|
| 374 | { |
|
| 375 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 376 | PHPUnit_Framework_Assert::greaterThan(1) |
|
| 377 | ); |
|
| 378 | ||
| 379 | try { |
|
| 380 | $constraint->evaluate(2, 'custom message'); |
|
| 381 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 382 | $this->assertEquals( |
|
| 383 | <<<EOF |
|
| 384 | custom message |
|
| 385 | Failed asserting that 2 is not greater than 1. |
|
| 386 | ||
| 387 | EOF |
|
| 388 | , |
|
| 389 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 390 | ); |
|
| 391 | ||
| 392 | return; |
|
| 393 | } |
|
| 394 | ||
| 395 | $this->fail(); |
|
| 396 | } |
|
| 397 | ||
| 398 | /** |
|
| 399 | * @covers PHPUnit_Framework_Constraint_IsEqual |
|
| @@ 508-531 (lines=24) @@ | ||
| 505 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 506 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 507 | */ |
|
| 508 | public function testConstraintNotGreaterThanOrEqual2() |
|
| 509 | { |
|
| 510 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 511 | PHPUnit_Framework_Assert::greaterThanOrEqual(1) |
|
| 512 | ); |
|
| 513 | ||
| 514 | try { |
|
| 515 | $constraint->evaluate(1, 'custom message'); |
|
| 516 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 517 | $this->assertEquals( |
|
| 518 | <<<EOF |
|
| 519 | custom message |
|
| 520 | Failed asserting that not( 1 is equal to 1 or is greater than 1 ). |
|
| 521 | ||
| 522 | EOF |
|
| 523 | , |
|
| 524 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 525 | ); |
|
| 526 | ||
| 527 | return; |
|
| 528 | } |
|
| 529 | ||
| 530 | $this->fail(); |
|
| 531 | } |
|
| 532 | ||
| 533 | /** |
|
| 534 | * @covers PHPUnit_Framework_Constraint_IsAnything |
|
| @@ 941-964 (lines=24) @@ | ||
| 938 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 939 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 940 | */ |
|
| 941 | public function testConstraintIsNotEqual2() |
|
| 942 | { |
|
| 943 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 944 | PHPUnit_Framework_Assert::equalTo(1) |
|
| 945 | ); |
|
| 946 | ||
| 947 | try { |
|
| 948 | $constraint->evaluate(1, 'custom message'); |
|
| 949 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 950 | $this->assertEquals( |
|
| 951 | <<<EOF |
|
| 952 | custom message |
|
| 953 | Failed asserting that 1 is not equal to 1. |
|
| 954 | ||
| 955 | EOF |
|
| 956 | , |
|
| 957 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 958 | ); |
|
| 959 | ||
| 960 | return; |
|
| 961 | } |
|
| 962 | ||
| 963 | $this->fail(); |
|
| 964 | } |
|
| 965 | ||
| 966 | /** |
|
| 967 | * @covers PHPUnit_Framework_Constraint_IsIdentical |
|
| @@ 1108-1132 (lines=25) @@ | ||
| 1105 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 1106 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 1107 | */ |
|
| 1108 | public function testConstraintIsNotIdentical2() |
|
| 1109 | { |
|
| 1110 | $a = new stdClass; |
|
| 1111 | ||
| 1112 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 1113 | PHPUnit_Framework_Assert::identicalTo($a) |
|
| 1114 | ); |
|
| 1115 | ||
| 1116 | try { |
|
| 1117 | $constraint->evaluate($a, 'custom message'); |
|
| 1118 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 1119 | $this->assertEquals(<<<EOF |
|
| 1120 | custom message |
|
| 1121 | Failed asserting that two variables don't reference the same object. |
|
| 1122 | ||
| 1123 | EOF |
|
| 1124 | , |
|
| 1125 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 1126 | ); |
|
| 1127 | ||
| 1128 | return; |
|
| 1129 | } |
|
| 1130 | ||
| 1131 | $this->fail(); |
|
| 1132 | } |
|
| 1133 | ||
| 1134 | /** |
|
| 1135 | * @covers PHPUnit_Framework_Constraint_IsIdentical |
|
| @@ 1141-1163 (lines=23) @@ | ||
| 1138 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 1139 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 1140 | */ |
|
| 1141 | public function testConstraintIsNotIdentical3() |
|
| 1142 | { |
|
| 1143 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 1144 | PHPUnit_Framework_Assert::identicalTo('a') |
|
| 1145 | ); |
|
| 1146 | ||
| 1147 | try { |
|
| 1148 | $constraint->evaluate('a', 'custom message'); |
|
| 1149 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 1150 | $this->assertEquals(<<<EOF |
|
| 1151 | custom message |
|
| 1152 | Failed asserting that two strings are not identical. |
|
| 1153 | ||
| 1154 | EOF |
|
| 1155 | , |
|
| 1156 | $this->trimnl(PHPUnit_Framework_TestFailure::exceptionToString($e)) |
|
| 1157 | ); |
|
| 1158 | ||
| 1159 | return; |
|
| 1160 | } |
|
| 1161 | ||
| 1162 | $this->fail(); |
|
| 1163 | } |
|
| 1164 | ||
| 1165 | /** |
|
| 1166 | * @covers PHPUnit_Framework_Constraint_IsInstanceOf |
|
| @@ 1208-1228 (lines=21) @@ | ||
| 1205 | * @covers PHPUnit_Framework_Assert::isInstanceOf |
|
| 1206 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 1207 | */ |
|
| 1208 | public function testConstraintIsInstanceOf2() |
|
| 1209 | { |
|
| 1210 | $constraint = PHPUnit_Framework_Assert::isInstanceOf('Exception'); |
|
| 1211 | ||
| 1212 | try { |
|
| 1213 | $constraint->evaluate(new stdClass, 'custom message'); |
|
| 1214 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 1215 | $this->assertEquals(<<<EOF |
|
| 1216 | custom message |
|
| 1217 | Failed asserting that stdClass Object () is an instance of class "Exception". |
|
| 1218 | ||
| 1219 | EOF |
|
| 1220 | , |
|
| 1221 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 1222 | ); |
|
| 1223 | ||
| 1224 | return; |
|
| 1225 | } |
|
| 1226 | ||
| 1227 | $this->fail(); |
|
| 1228 | } |
|
| 1229 | ||
| 1230 | /** |
|
| 1231 | * @covers PHPUnit_Framework_Constraint_IsInstanceOf |
|
| @@ 1273-1295 (lines=23) @@ | ||
| 1270 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 1271 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 1272 | */ |
|
| 1273 | public function testConstraintIsNotInstanceOf2() |
|
| 1274 | { |
|
| 1275 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 1276 | PHPUnit_Framework_Assert::isInstanceOf('stdClass') |
|
| 1277 | ); |
|
| 1278 | ||
| 1279 | try { |
|
| 1280 | $constraint->evaluate(new stdClass, 'custom message'); |
|
| 1281 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 1282 | $this->assertEquals(<<<EOF |
|
| 1283 | custom message |
|
| 1284 | Failed asserting that stdClass Object () is not an instance of class "stdClass". |
|
| 1285 | ||
| 1286 | EOF |
|
| 1287 | , |
|
| 1288 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 1289 | ); |
|
| 1290 | ||
| 1291 | return; |
|
| 1292 | } |
|
| 1293 | ||
| 1294 | $this->fail(); |
|
| 1295 | } |
|
| 1296 | ||
| 1297 | /** |
|
| 1298 | * @covers PHPUnit_Framework_Constraint_IsType |
|
| @@ 1424-1446 (lines=23) @@ | ||
| 1421 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 1422 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 1423 | */ |
|
| 1424 | public function testConstraintIsNotType2() |
|
| 1425 | { |
|
| 1426 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 1427 | PHPUnit_Framework_Assert::isType('string') |
|
| 1428 | ); |
|
| 1429 | ||
| 1430 | try { |
|
| 1431 | $constraint->evaluate('', 'custom message'); |
|
| 1432 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 1433 | $this->assertEquals(<<<EOF |
|
| 1434 | custom message |
|
| 1435 | Failed asserting that '' is not of type "string". |
|
| 1436 | ||
| 1437 | EOF |
|
| 1438 | , |
|
| 1439 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 1440 | ); |
|
| 1441 | ||
| 1442 | return; |
|
| 1443 | } |
|
| 1444 | ||
| 1445 | $this->fail(); |
|
| 1446 | } |
|
| 1447 | ||
| 1448 | /** |
|
| 1449 | * @covers PHPUnit_Framework_Constraint_IsNull |
|
| @@ 1678-1701 (lines=24) @@ | ||
| 1675 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 1676 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 1677 | */ |
|
| 1678 | public function testConstraintNotLessThan2() |
|
| 1679 | { |
|
| 1680 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 1681 | PHPUnit_Framework_Assert::lessThan(1) |
|
| 1682 | ); |
|
| 1683 | ||
| 1684 | try { |
|
| 1685 | $constraint->evaluate(0, 'custom message'); |
|
| 1686 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 1687 | $this->assertEquals( |
|
| 1688 | <<<EOF |
|
| 1689 | custom message |
|
| 1690 | Failed asserting that 0 is not less than 1. |
|
| 1691 | ||
| 1692 | EOF |
|
| 1693 | , |
|
| 1694 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 1695 | ); |
|
| 1696 | ||
| 1697 | return; |
|
| 1698 | } |
|
| 1699 | ||
| 1700 | $this->fail(); |
|
| 1701 | } |
|
| 1702 | ||
| 1703 | /** |
|
| 1704 | * @covers PHPUnit_Framework_Constraint_IsEqual |
|
| @@ 1868-1891 (lines=24) @@ | ||
| 1865 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 1866 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 1867 | */ |
|
| 1868 | public function testConstraintNotLessThanOrEqual2() |
|
| 1869 | { |
|
| 1870 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 1871 | PHPUnit_Framework_Assert::lessThanOrEqual(1) |
|
| 1872 | ); |
|
| 1873 | ||
| 1874 | try { |
|
| 1875 | $constraint->evaluate(1, 'custom message'); |
|
| 1876 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 1877 | $this->assertEquals( |
|
| 1878 | <<<EOF |
|
| 1879 | custom message |
|
| 1880 | Failed asserting that not( 1 is equal to 1 or is less than 1 ). |
|
| 1881 | ||
| 1882 | EOF |
|
| 1883 | , |
|
| 1884 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 1885 | ); |
|
| 1886 | ||
| 1887 | return; |
|
| 1888 | } |
|
| 1889 | ||
| 1890 | $this->fail(); |
|
| 1891 | } |
|
| 1892 | ||
| 1893 | /** |
|
| 1894 | * @covers PHPUnit_Framework_Constraint_ClassHasAttribute |
|
| @@ 1996-2018 (lines=23) @@ | ||
| 1993 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 1994 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 1995 | */ |
|
| 1996 | public function testConstraintClassNotHasAttribute2() |
|
| 1997 | { |
|
| 1998 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 1999 | PHPUnit_Framework_Assert::classHasAttribute('privateAttribute') |
|
| 2000 | ); |
|
| 2001 | ||
| 2002 | try { |
|
| 2003 | $constraint->evaluate('ClassWithNonPublicAttributes', 'custom message'); |
|
| 2004 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2005 | $this->assertEquals(<<<EOF |
|
| 2006 | custom message |
|
| 2007 | Failed asserting that class "ClassWithNonPublicAttributes" does not have attribute "privateAttribute". |
|
| 2008 | ||
| 2009 | EOF |
|
| 2010 | , |
|
| 2011 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 2012 | ); |
|
| 2013 | ||
| 2014 | return; |
|
| 2015 | } |
|
| 2016 | ||
| 2017 | $this->fail(); |
|
| 2018 | } |
|
| 2019 | ||
| 2020 | /** |
|
| 2021 | * @covers PHPUnit_Framework_Constraint_ClassHasStaticAttribute |
|
| @@ 2123-2145 (lines=23) @@ | ||
| 2120 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 2121 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 2122 | */ |
|
| 2123 | public function testConstraintClassNotHasStaticAttribute2() |
|
| 2124 | { |
|
| 2125 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 2126 | PHPUnit_Framework_Assert::classHasStaticAttribute('privateStaticAttribute') |
|
| 2127 | ); |
|
| 2128 | ||
| 2129 | try { |
|
| 2130 | $constraint->evaluate('ClassWithNonPublicAttributes', 'custom message'); |
|
| 2131 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2132 | $this->assertEquals(<<<EOF |
|
| 2133 | custom message |
|
| 2134 | Failed asserting that class "ClassWithNonPublicAttributes" does not have static attribute "privateStaticAttribute". |
|
| 2135 | ||
| 2136 | EOF |
|
| 2137 | , |
|
| 2138 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 2139 | ); |
|
| 2140 | ||
| 2141 | return; |
|
| 2142 | } |
|
| 2143 | ||
| 2144 | $this->fail(); |
|
| 2145 | } |
|
| 2146 | ||
| 2147 | /** |
|
| 2148 | * @covers PHPUnit_Framework_Constraint_ObjectHasAttribute |
|
| @@ 2185-2205 (lines=21) @@ | ||
| 2182 | * @covers PHPUnit_Framework_Assert::objectHasAttribute |
|
| 2183 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 2184 | */ |
|
| 2185 | public function testConstraintObjectHasAttribute2() |
|
| 2186 | { |
|
| 2187 | $constraint = PHPUnit_Framework_Assert::objectHasAttribute('privateAttribute'); |
|
| 2188 | ||
| 2189 | try { |
|
| 2190 | $constraint->evaluate(new stdClass, 'custom message'); |
|
| 2191 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2192 | $this->assertEquals(<<<EOF |
|
| 2193 | custom message |
|
| 2194 | Failed asserting that object of class "stdClass" has attribute "privateAttribute". |
|
| 2195 | ||
| 2196 | EOF |
|
| 2197 | , |
|
| 2198 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 2199 | ); |
|
| 2200 | ||
| 2201 | return; |
|
| 2202 | } |
|
| 2203 | ||
| 2204 | $this->fail(); |
|
| 2205 | } |
|
| 2206 | ||
| 2207 | /** |
|
| 2208 | * @covers PHPUnit_Framework_Constraint_ObjectHasAttribute |
|
| @@ 2250-2272 (lines=23) @@ | ||
| 2247 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 2248 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 2249 | */ |
|
| 2250 | public function testConstraintObjectNotHasAttribute2() |
|
| 2251 | { |
|
| 2252 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 2253 | PHPUnit_Framework_Assert::objectHasAttribute('privateAttribute') |
|
| 2254 | ); |
|
| 2255 | ||
| 2256 | try { |
|
| 2257 | $constraint->evaluate(new ClassWithNonPublicAttributes, 'custom message'); |
|
| 2258 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2259 | $this->assertEquals(<<<EOF |
|
| 2260 | custom message |
|
| 2261 | Failed asserting that object of class "ClassWithNonPublicAttributes" does not have attribute "privateAttribute". |
|
| 2262 | ||
| 2263 | EOF |
|
| 2264 | , |
|
| 2265 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 2266 | ); |
|
| 2267 | ||
| 2268 | return; |
|
| 2269 | } |
|
| 2270 | ||
| 2271 | $this->fail(); |
|
| 2272 | } |
|
| 2273 | ||
| 2274 | /** |
|
| 2275 | * @covers PHPUnit_Framework_Constraint_PCREMatch |
|
| @@ 2377-2399 (lines=23) @@ | ||
| 2374 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 2375 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 2376 | */ |
|
| 2377 | public function testConstraintPCRENotMatch2() |
|
| 2378 | { |
|
| 2379 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 2380 | PHPUnit_Framework_Assert::matchesRegularExpression('/foo/') |
|
| 2381 | ); |
|
| 2382 | ||
| 2383 | try { |
|
| 2384 | $constraint->evaluate('barfoobar', 'custom message'); |
|
| 2385 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2386 | $this->assertEquals(<<<EOF |
|
| 2387 | custom message |
|
| 2388 | Failed asserting that 'barfoobar' does not match PCRE pattern "/foo/". |
|
| 2389 | ||
| 2390 | EOF |
|
| 2391 | , |
|
| 2392 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 2393 | ); |
|
| 2394 | ||
| 2395 | return; |
|
| 2396 | } |
|
| 2397 | ||
| 2398 | $this->fail(); |
|
| 2399 | } |
|
| 2400 | ||
| 2401 | /** |
|
| 2402 | * @covers PHPUnit_Framework_Constraint_StringMatches |
|
| @@ 2586-2609 (lines=24) @@ | ||
| 2583 | * @covers PHPUnit_Framework_Assert::stringStartsWith |
|
| 2584 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 2585 | */ |
|
| 2586 | public function testConstraintStringStartsNotWith2() |
|
| 2587 | { |
|
| 2588 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 2589 | PHPUnit_Framework_Assert::stringStartsWith('prefix') |
|
| 2590 | ); |
|
| 2591 | ||
| 2592 | try { |
|
| 2593 | $constraint->evaluate('prefixfoo', 'custom message'); |
|
| 2594 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2595 | $this->assertEquals( |
|
| 2596 | <<<EOF |
|
| 2597 | custom message |
|
| 2598 | Failed asserting that 'prefixfoo' starts not with "prefix". |
|
| 2599 | ||
| 2600 | EOF |
|
| 2601 | , |
|
| 2602 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 2603 | ); |
|
| 2604 | ||
| 2605 | return; |
|
| 2606 | } |
|
| 2607 | ||
| 2608 | $this->fail(); |
|
| 2609 | } |
|
| 2610 | ||
| 2611 | /** |
|
| 2612 | * @covers PHPUnit_Framework_Constraint_StringContains |
|
| @@ 2715-2738 (lines=24) @@ | ||
| 2712 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 2713 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 2714 | */ |
|
| 2715 | public function testConstraintStringNotContains2() |
|
| 2716 | { |
|
| 2717 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 2718 | PHPUnit_Framework_Assert::stringContains('foo') |
|
| 2719 | ); |
|
| 2720 | ||
| 2721 | try { |
|
| 2722 | $constraint->evaluate('barfoobar', 'custom message'); |
|
| 2723 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2724 | $this->assertEquals( |
|
| 2725 | <<<EOF |
|
| 2726 | custom message |
|
| 2727 | Failed asserting that 'barfoobar' does not contain "foo". |
|
| 2728 | ||
| 2729 | EOF |
|
| 2730 | , |
|
| 2731 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 2732 | ); |
|
| 2733 | ||
| 2734 | return; |
|
| 2735 | } |
|
| 2736 | ||
| 2737 | $this->fail(); |
|
| 2738 | } |
|
| 2739 | ||
| 2740 | /** |
|
| 2741 | * @covers PHPUnit_Framework_Constraint_StringEndsWith |
|
| @@ 2842-2865 (lines=24) @@ | ||
| 2839 | * @covers PHPUnit_Framework_Assert::stringEndsWith |
|
| 2840 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 2841 | */ |
|
| 2842 | public function testConstraintStringEndsNotWith2() |
|
| 2843 | { |
|
| 2844 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 2845 | PHPUnit_Framework_Assert::stringEndsWith('suffix') |
|
| 2846 | ); |
|
| 2847 | ||
| 2848 | try { |
|
| 2849 | $constraint->evaluate('foosuffix', 'custom message'); |
|
| 2850 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2851 | $this->assertEquals( |
|
| 2852 | <<<EOF |
|
| 2853 | custom message |
|
| 2854 | Failed asserting that 'foosuffix' ends not with "suffix". |
|
| 2855 | ||
| 2856 | EOF |
|
| 2857 | , |
|
| 2858 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 2859 | ); |
|
| 2860 | ||
| 2861 | return; |
|
| 2862 | } |
|
| 2863 | ||
| 2864 | $this->fail(); |
|
| 2865 | } |
|
| 2866 | ||
| 2867 | /** |
|
| 2868 | * @covers PHPUnit_Framework_Constraint_TraversableContains |
|
| @@ 2985-3008 (lines=24) @@ | ||
| 2982 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 2983 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 2984 | */ |
|
| 2985 | public function testConstraintArrayNotContains2() |
|
| 2986 | { |
|
| 2987 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 2988 | new PHPUnit_Framework_Constraint_TraversableContains('foo') |
|
| 2989 | ); |
|
| 2990 | ||
| 2991 | try { |
|
| 2992 | $constraint->evaluate(array('foo'), 'custom message'); |
|
| 2993 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 2994 | $this->assertEquals( |
|
| 2995 | <<<EOF |
|
| 2996 | custom message |
|
| 2997 | Failed asserting that an array does not contain 'foo'. |
|
| 2998 | ||
| 2999 | EOF |
|
| 3000 | , |
|
| 3001 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 3002 | ); |
|
| 3003 | ||
| 3004 | return; |
|
| 3005 | } |
|
| 3006 | ||
| 3007 | $this->fail(); |
|
| 3008 | } |
|
| 3009 | ||
| 3010 | /** |
|
| 3011 | * @covers PHPUnit_Framework_Constraint_TraversableContains |
|
| @@ 3114-3135 (lines=22) @@ | ||
| 3111 | * @covers PHPUnit_Framework_Constraint_Attribute |
|
| 3112 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 3113 | */ |
|
| 3114 | public function testAttributeEqualTo2() |
|
| 3115 | { |
|
| 3116 | $object = new ClassWithNonPublicAttributes; |
|
| 3117 | $constraint = PHPUnit_Framework_Assert::attributeEqualTo('foo', 2); |
|
| 3118 | ||
| 3119 | try { |
|
| 3120 | $constraint->evaluate($object, 'custom message'); |
|
| 3121 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 3122 | $this->assertEquals( |
|
| 3123 | <<<EOF |
|
| 3124 | custom message\nFailed asserting that attribute "foo" is equal to 2. |
|
| 3125 | ||
| 3126 | EOF |
|
| 3127 | , |
|
| 3128 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 3129 | ); |
|
| 3130 | ||
| 3131 | return; |
|
| 3132 | } |
|
| 3133 | ||
| 3134 | $this->fail(); |
|
| 3135 | } |
|
| 3136 | ||
| 3137 | /** |
|
| 3138 | * @covers PHPUnit_Framework_Assert::attributeEqualTo |
|
| @@ 3186-3209 (lines=24) @@ | ||
| 3183 | * @covers PHPUnit_Framework_Constraint_Not |
|
| 3184 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 3185 | */ |
|
| 3186 | public function testAttributeNotEqualTo2() |
|
| 3187 | { |
|
| 3188 | $object = new ClassWithNonPublicAttributes; |
|
| 3189 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 3190 | PHPUnit_Framework_Assert::attributeEqualTo('foo', 1) |
|
| 3191 | ); |
|
| 3192 | ||
| 3193 | try { |
|
| 3194 | $constraint->evaluate($object, 'custom message'); |
|
| 3195 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 3196 | $this->assertEquals( |
|
| 3197 | <<<EOF |
|
| 3198 | custom message\nFailed asserting that attribute "foo" is not equal to 1. |
|
| 3199 | ||
| 3200 | EOF |
|
| 3201 | , |
|
| 3202 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 3203 | ); |
|
| 3204 | ||
| 3205 | return; |
|
| 3206 | } |
|
| 3207 | ||
| 3208 | $this->fail(); |
|
| 3209 | } |
|
| 3210 | ||
| 3211 | /** |
|
| 3212 | * @covers PHPUnit_Framework_Constraint_IsEmpty |
|