Skip to content

Commit

Permalink
DataSources\ArraySource: Fixed compare function [Closed #169]
Browse files Browse the repository at this point in the history
  • Loading branch information
o5 committed Nov 12, 2014
1 parent aebc26b commit 4ac7ea2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DataSources/ArraySource.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function compare($actual, $condition, $expected)
$cond = str_replace(' ?', '', $condition);

if ($cond === 'LIKE') {
$pattern = str_replace('%', '(.|\s)*', preg_quote($expected));
$pattern = str_replace('%', '(.|\s)*', preg_quote($expected, '/'));
return (bool) preg_match("/^{$pattern}$/i", $actual);

} elseif ($cond === '=') {
Expand Down
1 change: 1 addition & 0 deletions tests/DataSources/ArraySource.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ArraySourceTest extends DataSourceTestCase
Assert::true($source->compare('Lucie', 'LIKE ?', '%Lu%'));
Assert::true($source->compare('Lucie', 'LIKE ?', '%ie'));
Assert::true($source->compare('Lucie', 'LIKE ?', 'lu%'));
Assert::true($source->compare('Lucie/Lucy', 'LIKE ?', 'Lucie/L%'));
Assert::false($source->compare('Lucie', 'LIKE ?', 'ie%'));
Assert::false($source->compare('Lucie', 'LIKE ?', '%lu'));

Expand Down

0 comments on commit 4ac7ea2

Please sign in to comment.