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 = '.+?'; $val = '.+?';
$explanations[] = sprintf('Attribute "%s" present', $attr); $explanations[] = sprintf('Attribute "%s" present', $attr);
} elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) { } elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$quotes = '["\']';
$val = str_replace( $val = str_replace(
array('.*', '.+'), array('.*', '.+'),
array('.*?', '.+?'), array('.*?', '.+?'),
$matches[1] $matches[1]
); );
$quotes = $val !== $matches[1] ? '["\']' : '["\']?';
$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val); $explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
} else { } else {
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val); $explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);