Skip to content

Commit

Permalink
Adds test for SqlSupport::like
Browse files Browse the repository at this point in the history
  • Loading branch information
dansysanalyst committed Nov 26, 2021
1 parent 8e3481d commit 73f7fc8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/Feature/Helpers/SqlSupportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@
expect(SqlSupport::getDatabaseVersion())->not->toBeNull();
});

it('returns the proper "LIKE" syntax', function () {
$driver = SqlSupport::getDatabaseDriverName();

expect(SqlSupport::like())
->when(
$driver === 'mysql',
fn ($syntax) => $syntax->toBe('LIKE')
)
->when(
$driver === 'sqlite',
fn ($syntax) => $syntax->toBe('LIKE')
)
->when(
$driver === 'sqlsrv',
fn ($syntax) => $syntax->toBe('LIKE')
)
->when(
$driver === 'pgsql',
fn ($syntax) => $syntax->toBe('ILIKE')
)
->not->toBeNull();
});

it('returns sortField', function (array $data) {
expect(SqlSupport::getSortSqlByDriver('field', $data['db'], $data['version']))
->toBe($data['expected']);
Expand Down

0 comments on commit 73f7fc8

Please sign in to comment.