From: SourceForge.net <no...@so...> - 2009-11-11 17:16:41
|
Feature Requests item #2896060, was opened at 2009-11-11 18:16 Message generated for change (Tracker Item Submitted) made by blueyed You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=547458&aid=2896060&group_id=76550 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Unit test framework Group: None Status: Open Priority: 5 Private: No Submitted By: daniel hahler (blueyed) Assigned to: Nobody/Anonymous (nobody) Summary: IgnoreWhitespaceExpectation: ignore whitespace Initial Comment: I'd like to have something like IgnoreWhitespaceExpectation (bad name probably!), which would compare values, while ignoring whitespace. My suggestion is something in line of: /** * Test for a pattern, ignoring (amout of) whitespace. * @package SimpleTest * @subpackage UnitTester */ class IgnoreWhitespaceExpectation extends PatternExpectation { /** * Sets the value to compare against. * @param string $pattern Pattern to search for. * @param string $message Customised message on failure. * @access public */ function __construct($pattern, $message = '%s') { $pattern = '~^\s*'.preg_quote($pattern, '~').'\s*$~'; $pattern = preg_replace('~\s+~', '\\s+', $pattern); parent::__construct($pattern, $message); } } This allows to use something like: $DB->expectAt(6, 'query', array(new IgnoreWhitespaceExpectation("INSERT INTO slugs (slug_title, slug_Article_ID) VALUES ('bar', '1')"))); where line breaks and leading/trailing whitespace is not important. I think this should get improved to not replace "\s+" in strings, i.e.: "SELECT 'foo bar'" should become "^\s*SELECT\s+'foo bar'\s*$" What do you think? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=547458&aid=2896060&group_id=76550 |