Skip to content

Commit

Permalink
Merge branch 'master' into disable-sort-when-limit-is-explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark authored Oct 18, 2024
2 parents b297d21 + 2ad813e commit 712ee0b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/Common/FixtureTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
trait FixtureTrait
{
protected static $fixtures = [
['number' => 1, 'email' => 'foo@bar', 'balance' => 10.25, 'born_at' => null],
['number' => 1, 'email' => 'foo@bar\\baz', 'balance' => 10.25, 'born_at' => null],
['number' => 2, 'email' => 'bar@foo', 'balance' => 1.0, 'born_at' => null],
['number' => 3, 'email' => 'seed@beat', 'balance' => 100.0, 'born_at' => null],
['number' => 4, 'email' => 'the@best', 'balance' => 500.0, 'born_at' => null],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@ abstract class BaseReaderWithLikeTestCase extends BaseReaderTestCase
public static function dataWithReader(): array
{
return [
'case matches' => ['email', 'seed@', [2]],
'case does not match' => ['email', 'SEED@', [2]],
'wildcard is not supported' => ['email', '%st', []],
'search: starts with, same case, case sensitive: null' => ['email', 'seed@', null, [2]],
'search: ends with, same case, case sensitive: null' => ['email', '@beat', null, [2]],
'search: contains, same case, case sensitive: null' => ['email', 'ed@be', null, [2]],
'search: contains, same case, case sensitive: false' => ['email', 'ed@be', false, [2]],
'search: contains, different case, case sensitive: false' => ['email', 'SEED@', false, [2]],
'wildcard is not supported, %' => ['email', '%st', null, []],
'wildcard is not supported, _' => ['email', '____@___t', null, []],
'search: contains backslash' => ['email', 'foo@bar\\baz', null, [0]],
];
}

#[DataProvider('dataWithReader')]
public function testWithReader(string $field, string $value, array $expectedFixtureIndexes): void
{
$reader = $this->getReader()->withFilter(new Like($field, $value));
public function testWithReader(
string $field,
string $value,
bool|null $caseSensitive,
array $expectedFixtureIndexes,
): void {
$reader = $this->getReader()->withFilter(new Like($field, $value, $caseSensitive));
$this->assertFixtures($expectedFixtureIndexes, $reader->read());
}
}
10 changes: 10 additions & 0 deletions tests/Reader/Iterable/ReaderWithFilter/ReaderWithLikeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@
final class ReaderWithLikeTest extends BaseReaderWithLikeTestCase
{
use ReaderTrait;

public static function dataWithReader(): array
{
$data = parent::dataWithReader();
$data['search: contains, same case, case sensitive: true'] = ['email', 'ed@be', true, [2]];
$data['search: contains, different case, case sensitive: null'] = ['email', 'SEED@', null, [2]];
$data['search: contains, different case, case sensitive: true'] = ['email', 'SEED@', true, []];

return $data;
}
}

0 comments on commit 712ee0b

Please sign in to comment.