ZF-12492: assertHeaderContains
Description
assertHeaderContains and assertNotHeaderContains Fails when match is at the beginning of the string. This is caused the the strstr function returning 0 which is being evaluated to false.
assertHeaderContains and assertNotHeaderContains Fails when match is at the beginning of the string. This is caused the the strstr function returning 0 which is being evaluated to false.
Comments
Posted by Chuck Reeves (creeves1982) on 2012-12-27T21:19:27.000+0000
Fix is simple by just doing a cast to bool:
Zend_Test_PHPUnit_Constraint_ResponseHeader::_headerContains: return (strstr($contents, $match) !== false);
Zend_Test_PHPUnit_Constraint_ResponseHeader::_notHeaderContains: return (strstr($contents, $match) === false);
Posted by Chuck Reeves (creeves1982) on 2012-12-27T21:26:32.000+0000
Corrrection to description, If '0' is used for the string it will be evaluated as false: ex $this->assertHeaderContains('Expires', '0');
Posted by Frank Brückner (frosch) on 2012-12-28T10:07:11.000+0000
Hi Chuck, can you add a patch and an unit test?
Posted by Chuck Reeves (creeves1982) on 2012-12-28T14:07:36.000+0000
Working on it now
Posted by Chuck Reeves (creeves1982) on 2012-12-28T14:53:37.000+0000
Here are the patches for the tests and fix
Posted by Frank Brückner (frosch) on 2012-12-28T16:01:19.000+0000
Thanks! I will check and commit this.
Posted by Frank Brückner (frosch) on 2013-01-10T11:23:47.000+0000
Fixed on trunk (25204) and release-1.12 (25205)
Thanks to Chuck!