ZF-12492: assertHeaderContains

Issue Type: Bug Created: 2012-12-27T21:18:26.000+0000 Last Updated: 2013-01-10T11:23:47.000+0000 Status: Resolved Fix version(s): - 1.12.2 (25/Feb/13)

Reporter: Chuck Reeves (creeves1982) Assignee: Chuck Reeves (creeves1982) Tags: - Zend_Test_PHPUnit

  • test

Related issues: Attachments: - library.diff


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.


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!

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.