Skip to content

Commit

Permalink
tests: make sure the db connection is set to sqlite while running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandhi11 committed Apr 22, 2024
1 parent f734a14 commit 137127a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
<directory suffix=".php">src/</directory>
</include>
</source>
<php>
<env name="DB_CONNECTION" value="sqlite"/>
<ini name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
32 changes: 16 additions & 16 deletions tests/Integration/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function testScopeWhereHasTranslationDefaultParameters(): void
});

$this->assertEquals(
'select * from `examples` where exists (select * from `example_translations` where ' .
'`examples`.`id` = `example_translations`.`example_id` and `locale` = ?)',
'select * from "examples" where exists (select * from "example_translations" where ' .
'"examples"."id" = "example_translations"."example_id" and "locale" = ?)',
$query->toSql()
);

Expand All @@ -51,8 +51,8 @@ public function testScopeWhereHasTranslationWithParameters(): void
}, 'fr', '>', 2);

$this->assertEquals(
'select * from `examples` where (select count(*) from `example_translations` where ' .
'`examples`.`id` = `example_translations`.`example_id` and `locale` = ?) > 2',
'select * from "examples" where (select count(*) from "example_translations" where ' .
'"examples"."id" = "example_translations"."example_id" and "locale" = ?) > 2',
$query->toSql()
);

Expand All @@ -73,8 +73,8 @@ public function testScopeWhereHasTranslationWithCallback(): void
});

$this->assertEquals(
'select * from `examples` where exists (select * from `example_translations` where ' .
'`examples`.`id` = `example_translations`.`example_id` and `locale` = ? and `description` like ?)',
'select * from "examples" where exists (select * from "example_translations" where ' .
'"examples"."id" = "example_translations"."example_id" and "locale" = ? and "description" like ?)',
$query->toSql()
);

Expand All @@ -93,8 +93,8 @@ public function testScopeHasTranslation(): void
$query = Example::query()->HasTranslation('description', 'test', 'fr', 'like');

$this->assertEquals(
'select * from `examples` where exists (select * from `example_translations` where ' .
'`examples`.`id` = `example_translations`.`example_id` and `locale` = ? and `description` like ?)',
'select * from "examples" where exists (select * from "example_translations" where ' .
'"examples"."id" = "example_translations"."example_id" and "locale" = ? and "description" like ?)',
$query->toSql()
);

Expand All @@ -113,8 +113,8 @@ public function testScopeWhereTranslation(): void
$query = Example::query()->WhereTranslation('name', 'like', 'name1', 'fr');

$this->assertEquals(
'select * from `examples` where exists (select * from `example_translations` where ' .
'`examples`.`id` = `example_translations`.`example_id` and `locale` = ? and `name` like ?)',
'select * from "examples" where exists (select * from "example_translations" where ' .
'"examples"."id" = "example_translations"."example_id" and "locale" = ? and "name" like ?)',
$query->toSql()
);

Expand All @@ -133,8 +133,8 @@ public function testScopeWhereTranslationMixedValue(): void
$query = Example::query()->WhereTranslation('name', '>=', '2', 'fr');

$this->assertEquals(
'select * from `examples` where exists (select * from `example_translations` where ' .
'`examples`.`id` = `example_translations`.`example_id` and `locale` = ? and `name` >= ?)',
'select * from "examples" where exists (select * from "example_translations" where ' .
'"examples"."id" = "example_translations"."example_id" and "locale" = ? and "name" >= ?)',
$query->toSql()
);

Expand All @@ -153,8 +153,8 @@ public function testScopeJoinTranslation(): void
$query = Example::query()->JoinTranslation();

$this->assertEquals(
'select * from `examples` left join `example_translations` on ' .
'`example_translations`.`example_id` = `examples`.`id` where `example_translations`.`locale` = ?',
'select * from "examples" left join "example_translations" on ' .
'"example_translations"."example_id" = "examples"."id" where "example_translations"."locale" = ?',
$query->toSql()
);

Expand All @@ -173,8 +173,8 @@ public function testScopeJoinTranslationWithLocaleParameter(): void
$query = Example::query()->JoinTranslation('fr');

$this->assertEquals(
'select * from `examples` left join `example_translations` on ' .
'`example_translations`.`example_id` = `examples`.`id` where `example_translations`.`locale` = ?',
'select * from "examples" left join "example_translations" on ' .
'"example_translations"."example_id" = "examples"."id" where "example_translations"."locale" = ?',
$query->toSql()
);

Expand Down

0 comments on commit 137127a

Please sign in to comment.