Skip to content

Commit eaf50d8

Browse files
committed
fix(tests): identifying whether db supports json operations or not
1 parent da08add commit eaf50d8

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

tests/Feature/StandardIndexFilteringOperationsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,12 @@ public function getting_a_list_of_resources_filtered_by_model_datetime_field():
537537
/** @test */
538538
public function getting_a_list_of_resources_filtered_by_jsonb_array_field_inclusive(): void
539539
{
540-
if (config('database.default') === 'sqlite'){
540+
if ($this->noSupportForJsonDbOperations()) {
541541
$this->markTestSkipped('Not supported with SQLite');
542542
}
543543

544544
$matchingPost = factory(Post::class)
545-
->create(['options' => ['a', 'b', 'c']])->fresh();
545+
->create(['options' => ['a', 'b', 'c']])->fresh();
546546
factory(Post::class)->create(['publish_at' => Carbon::now()])->fresh();
547547

548548
Gate::policy(Post::class, GreenPolicy::class);
@@ -565,7 +565,7 @@ public function getting_a_list_of_resources_filtered_by_jsonb_array_field_inclus
565565
/** @test */
566566
public function getting_a_list_of_resources_filtered_by_nested_jsonb_array_field_inclusive(): void
567567
{
568-
if (config('database.default') === 'sqlite'){
568+
if ($this->noSupportForJsonDbOperations()) {
569569
$this->markTestSkipped('Not supported with SQLite');
570570
}
571571

@@ -593,12 +593,12 @@ public function getting_a_list_of_resources_filtered_by_nested_jsonb_array_field
593593
/** @test */
594594
public function getting_a_list_of_resources_filtered_by_jsonb_array_field_exclusive(): void
595595
{
596-
if (config('database.default') === 'sqlite'){
596+
if ($this->noSupportForJsonDbOperations()) {
597597
$this->markTestSkipped('Not supported with SQLite');
598598
}
599599

600600
$matchingPost = factory(Post::class)
601-
->create(['options' => ['a', 'd']])->fresh();
601+
->create(['options' => ['a', 'd']])->fresh();
602602
factory(Post::class)->create(['publish_at' => Carbon::now()])->fresh();
603603

604604
Gate::policy(Post::class, GreenPolicy::class);
@@ -621,7 +621,7 @@ public function getting_a_list_of_resources_filtered_by_jsonb_array_field_exclus
621621
/** @test */
622622
public function getting_a_list_of_resources_filtered_by_nested_jsonb_array_field_exclusive(): void
623623
{
624-
if (config('database.default') === 'sqlite'){
624+
if ($this->noSupportForJsonDbOperations()) {
625625
$this->markTestSkipped('Not supported with SQLite');
626626
}
627627

tests/Feature/TestCase.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,14 @@ protected function resolveUserModelClass(): ?string
2323
{
2424
return User::class;
2525
}
26+
27+
protected function noSupportForJsonDbOperations(): bool
28+
{
29+
if (config('database.default') === 'sqlite') {
30+
return true;
31+
}
32+
33+
return config('database.default') === 'testing' &&
34+
config('database.connections.testing.driver') === 'sqlite';
35+
}
2636
}

0 commit comments

Comments
 (0)