Use alternate quoting in assertTags()

When a preg pattern contains no `.` it probably doesn't need quote
anchors.
This commit is contained in:
mark_story 2014-03-21 22:53:25 -04:00
parent f12b272758
commit a801be30d9

View file

@ -448,12 +448,13 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
$val = '.+?';
$explanations[] = sprintf('Attribute "%s" present', $attr);
} elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$quotes = '["\']';
$val = str_replace(
array('.*', '.+'),
array('.*?', '.+?'),
$matches[1]
);
$quotes = $val !== $matches[1] ? '["\']' : '["\']?';
$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
} else {
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);