|
@@ 1454-1478 (lines=25) @@
|
| 1451 |
|
* @covers PHPUnit_Framework_Constraint::count |
| 1452 |
|
* @covers PHPUnit_Framework_TestFailure::exceptionToString |
| 1453 |
|
*/ |
| 1454 |
|
public function testConstraintIsNull() |
| 1455 |
|
{ |
| 1456 |
|
$constraint = PHPUnit_Framework_Assert::isNull(); |
| 1457 |
|
|
| 1458 |
|
$this->assertFalse($constraint->evaluate(0, '', true)); |
| 1459 |
|
$this->assertTrue($constraint->evaluate(null, '', true)); |
| 1460 |
|
$this->assertEquals('is null', $constraint->toString()); |
| 1461 |
|
$this->assertEquals(1, count($constraint)); |
| 1462 |
|
|
| 1463 |
|
try { |
| 1464 |
|
$constraint->evaluate(0); |
| 1465 |
|
} catch (PHPUnit_Framework_ExpectationFailedException $e) { |
| 1466 |
|
$this->assertEquals(<<<EOF |
| 1467 |
|
Failed asserting that 0 is null. |
| 1468 |
|
|
| 1469 |
|
EOF |
| 1470 |
|
, |
| 1471 |
|
PHPUnit_Framework_TestFailure::exceptionToString($e) |
| 1472 |
|
); |
| 1473 |
|
|
| 1474 |
|
return; |
| 1475 |
|
} |
| 1476 |
|
|
| 1477 |
|
$this->fail(); |
| 1478 |
|
} |
| 1479 |
|
|
| 1480 |
|
/** |
| 1481 |
|
* @covers PHPUnit_Framework_Constraint_IsNull |
|
@@ 1515-1541 (lines=27) @@
|
| 1512 |
|
* @covers PHPUnit_Framework_Constraint::count |
| 1513 |
|
* @covers PHPUnit_Framework_TestFailure::exceptionToString |
| 1514 |
|
*/ |
| 1515 |
|
public function testConstraintIsNotNull() |
| 1516 |
|
{ |
| 1517 |
|
$constraint = PHPUnit_Framework_Assert::logicalNot( |
| 1518 |
|
PHPUnit_Framework_Assert::isNull() |
| 1519 |
|
); |
| 1520 |
|
|
| 1521 |
|
$this->assertFalse($constraint->evaluate(null, '', true)); |
| 1522 |
|
$this->assertTrue($constraint->evaluate(0, '', true)); |
| 1523 |
|
$this->assertEquals('is not null', $constraint->toString()); |
| 1524 |
|
$this->assertEquals(1, count($constraint)); |
| 1525 |
|
|
| 1526 |
|
try { |
| 1527 |
|
$constraint->evaluate(null); |
| 1528 |
|
} catch (PHPUnit_Framework_ExpectationFailedException $e) { |
| 1529 |
|
$this->assertEquals(<<<EOF |
| 1530 |
|
Failed asserting that null is not null. |
| 1531 |
|
|
| 1532 |
|
EOF |
| 1533 |
|
, |
| 1534 |
|
PHPUnit_Framework_TestFailure::exceptionToString($e) |
| 1535 |
|
); |
| 1536 |
|
|
| 1537 |
|
return; |
| 1538 |
|
} |
| 1539 |
|
|
| 1540 |
|
$this->fail(); |
| 1541 |
|
} |
| 1542 |
|
|
| 1543 |
|
/** |
| 1544 |
|
* @covers PHPUnit_Framework_Constraint_IsNull |