| @@ 147-171 (lines=25) @@ | ||
| 144 | * @covers PHPUnit_Framework_Constraint::count |
|
| 145 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 146 | */ |
|
| 147 | public function testConstraintFileExists() |
|
| 148 | { |
|
| 149 | $constraint = PHPUnit_Framework_Assert::fileExists(); |
|
| 150 | ||
| 151 | $this->assertFalse($constraint->evaluate('foo', '', true)); |
|
| 152 | $this->assertEquals('file exists', $constraint->toString()); |
|
| 153 | $this->assertEquals(1, count($constraint)); |
|
| 154 | ||
| 155 | try { |
|
| 156 | $constraint->evaluate('foo'); |
|
| 157 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 158 | $this->assertEquals( |
|
| 159 | <<<EOF |
|
| 160 | Failed asserting that file "foo" exists. |
|
| 161 | ||
| 162 | EOF |
|
| 163 | , |
|
| 164 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 165 | ); |
|
| 166 | ||
| 167 | return; |
|
| 168 | } |
|
| 169 | ||
| 170 | $this->fail(); |
|
| 171 | } |
|
| 172 | ||
| 173 | /** |
|
| 174 | * @covers PHPUnit_Framework_Constraint_FileExists |
|
| @@ 338-364 (lines=27) @@ | ||
| 335 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 336 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 337 | */ |
|
| 338 | public function testConstraintNotGreaterThan() |
|
| 339 | { |
|
| 340 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 341 | PHPUnit_Framework_Assert::greaterThan(1) |
|
| 342 | ); |
|
| 343 | ||
| 344 | $this->assertTrue($constraint->evaluate(1, '', true)); |
|
| 345 | $this->assertEquals('is not greater than 1', $constraint->toString()); |
|
| 346 | $this->assertEquals(1, count($constraint)); |
|
| 347 | ||
| 348 | try { |
|
| 349 | $constraint->evaluate(2); |
|
| 350 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 351 | $this->assertEquals( |
|
| 352 | <<<EOF |
|
| 353 | Failed asserting that 2 is not greater than 1. |
|
| 354 | ||
| 355 | EOF |
|
| 356 | , |
|
| 357 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 358 | ); |
|
| 359 | ||
| 360 | return; |
|
| 361 | } |
|
| 362 | ||
| 363 | $this->fail(); |
|
| 364 | } |
|
| 365 | ||
| 366 | /** |
|
| 367 | * @covers PHPUnit_Framework_Constraint_GreaterThan |
|
| @@ 471-497 (lines=27) @@ | ||
| 468 | * @covers PHPUnit_Framework_Assert::logicalNot |
|
| 469 | * @covers PHPUnit_Framework_TestFailure::exceptionToString |
|
| 470 | */ |
|
| 471 | public function testConstraintNotGreaterThanOrEqual() |
|
| 472 | { |
|
| 473 | $constraint = PHPUnit_Framework_Assert::logicalNot( |
|
| 474 | PHPUnit_Framework_Assert::greaterThanOrEqual(1) |
|
| 475 | ); |
|
| 476 | ||
| 477 | $this->assertFalse($constraint->evaluate(1, '', true)); |
|
| 478 | $this->assertEquals('not( is equal to 1 or is greater than 1 )', $constraint->toString()); |
|
| 479 | $this->assertEquals(2, count($constraint)); |
|
| 480 | ||
| 481 | try { |
|
| 482 | $constraint->evaluate(1); |
|
| 483 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
|
| 484 | $this->assertEquals( |
|
| 485 | <<<EOF |
|
| 486 | Failed asserting that not( 1 is equal to 1 or is greater than 1 ). |
|
| 487 | ||
| 488 | EOF |
|
| 489 | , |
|
| 490 | PHPUnit_Framework_TestFailure::exceptionToString($e) |
|
| 491 | ); |
|
| 492 | ||
| 493 | return; |
|
| 494 | } |
|
| 495 | ||
| 496 | $this->fail(); |
|
| 497 | } |
|
| 498 | ||
| 499 | /** |
|
| 500 | * @covers PHPUnit_Framework_Constraint_IsEqual |
|