The following UnitTest fails, when executed via Command Line and succeeds when run through Zend Studio. This should not be the case, because assertArrayHasKey
expects the second argument to be an array and the method signature contains a type hint to ensure this (which is why it fails via CLI).
This is the test case:
class AssertArrayHasKeyTest extends PHPUnit_Framework_TestCase
{
public function testTypeHintIsIgnored()
{
$notAnArray = new ArrayIterator(array('foo' => 'bar'));
$this->assertArrayHasKey('foo', $notAnArray);
}
}
At first, I assumed a change after PHP 5.2.9, that causes the array type hint to recognize objects implementing ArrayAccess as arrays. But it also happens when I use the same PHP version from CLI and ZS.
The same inconsistent behavior occurs for the following test case, just that it will fail in Zend Studio and succeeds via Command Line this time (so it's reversed):
class ExpectedExceptionTest extends PHPUnit_Framework_TestCase
{
public function testWarningIsCaught()
{
$this->setExpectedException('PHPUnit_Framework_Error_Warning');
include 'foo.php';
}
}
This is more or less the example given in the PHPUnit manual. I've tested with Notice instead of Warning, but to no avail. I can see that Notice and Warning get triggered in Zend Studio's Console Tab, so it should be catched. It makes no difference, whether I use the expectedException annotation or method call.
I've tested with ZS7 and ZS7.1 with PHPUnit v3.3.17 and PHP 5.2.9, 5.2.10 and 5.3. On the CLI I've tested with PHPUnit v3.3.17 and PHP 5.2.5 and 5.2.9.
Am I missing something or are these bugs in ZS (I'll open a ticket with Zend then)?