Home » Testing » PHPUnit2 » Bug #7198
assertEquals in a try-catch block passes, when it should fail
Details
| Submitted | 2006-03-24 15:02 UTC |
|---|---|
| From | develop at jjkiers dot nl |
| Status | Bogus |
| Package | PHPUnit2 |
| PHP Version | 5.1.2 |
| OS | Debian GNU/Linux 3.1 (Sarge) |
| Roadmaps | (Not assigned) |
Comments
[2006-03-24 15:02 UTC] develop at jjkiers dot nl
Description:
------------
PEAR Version: 1.4.6
PHP Version: 5.1.2-1+b1
Zend Engine Version: 2.1.0
Running on: Linux 2.6.15 i686
Reproducable: Always
When I put a test in a try-catch block, the assertEquals test passes. It should fail.
* I found it out while testing a normal class. Then I created a new testcase especially to test this. See the included code sample. Due to a lack for other development machines, I was not able to test it on other machines too.
Test script:
---------------
<?php
require_once('PHPUnit2/Framework/TestCase.php');
class PT extends PHPUnit2_Framework_TestCase
{
function testPHPUnitPasses()
{
try {
$this->assertEquals(1,2);
} catch (Exception $e) {}
}
function testPHPUnitFails()
{
$this->assertEquals("a","b");
}
}
?>
Expected result:
----------------
PHPUnit 2.3.5 by Sebastian Bergmann.
FF
Time: 0.003664
There were 2 failures:
1) testPHPUnitPasses(PT)
expected same: <1> was not: <2>
/home/jjkiers/pt.php:11
2) testPHPUnitFails(PT)
expected: <a> but was: <b>
/home/jjkiers/pt.php:17
FAILURES!!!
Tests run: 2, Failures: 2, Errors: 0, Incomplete Tests: 0.
Actual result:
--------------
// First test passes. It should fail.
PHPUnit 2.3.5 by Sebastian Bergmann.
.F
Time: 0.003439
There was 1 failure:
1) testPHPUnitFails(PT)
expected: <a> but was: <b>
/home/jjkiers/pt.php:17
FAILURES!!!
Tests run: 2, Failures: 1, Errors: 0, Incomplete Tests: 0.
[2006-03-24 15:27 UTC] sebastian at php dot net
Thank you for taking the time to write to us, but this is not
a bug.
This is the expected behaviour.