From 57b03da3264e04ba1c9a9ad29eea2eed036c2d1d Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Sat, 17 Jul 2021 20:28:28 +0300 Subject: [PATCH 1/2] extra formatting --- src/Traits/QueryCacheModule.php | 2 +- src/Traits/QueryCacheable.php | 26 +++++++++++++------------- tests/MethodsTest.php | 1 + tests/TestCase.php | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Traits/QueryCacheModule.php b/src/Traits/QueryCacheModule.php index 1aaf1a4..9a5de79 100644 --- a/src/Traits/QueryCacheModule.php +++ b/src/Traits/QueryCacheModule.php @@ -178,7 +178,7 @@ public function flushQueryCache(array $tags = []): bool } foreach ($tags as $tag) { - self::flushQueryCacheWithTag($tag); + $this->flushQueryCacheWithTag($tag); } return true; diff --git a/src/Traits/QueryCacheable.php b/src/Traits/QueryCacheable.php index ca3f4e7..eaab077 100644 --- a/src/Traits/QueryCacheable.php +++ b/src/Traits/QueryCacheable.php @@ -46,6 +46,19 @@ protected static function getFlushQueryCacheObserver() return FlushQueryCacheObserver::class; } + /** + * Set the base cache tags that will be present + * on all queries. + * + * @return array + */ + protected function getCacheBaseTags(): array + { + return [ + (string) self::class, + ]; + } + /** * When invalidating automatically on update, you can specify * which tags to invalidate. @@ -96,17 +109,4 @@ protected function newBaseQueryBuilder() return $builder->cacheBaseTags($this->getCacheBaseTags()); } - - /** - * Set the base cache tags that will be present - * on all queries. - * - * @return array - */ - protected function getCacheBaseTags(): array - { - return [ - (string) self::class, - ]; - } } diff --git a/tests/MethodsTest.php b/tests/MethodsTest.php index 79cc7ac..5eb28ac 100644 --- a/tests/MethodsTest.php +++ b/tests/MethodsTest.php @@ -153,6 +153,7 @@ public function test_multiple_append_cache_tags() public function test_append_cache_tags_with_sub_query() { $user = factory(User::class)->create(); + factory(Post::class)->createMany([ ['user_id' => $user->id, 'name' => 'Post 1 on topic 1'], ['user_id' => $user->id, 'name' => 'Post 2 on topic 1'], diff --git a/tests/TestCase.php b/tests/TestCase.php index 9d7b4f1..e8fb87b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -43,7 +43,7 @@ public function getEnvironmentSetUp($app) $app['config']->set('database.default', 'sqlite'); $app['config']->set('database.connections.sqlite', [ 'driver' => 'sqlite', - 'database' => __DIR__.'/database.sqlite', + 'database' => __DIR__.'/database/database.sqlite', 'prefix' => '', ]); $app['config']->set( From 36449d965347e8f2f1ba36e2e2334b0ef0679b91 Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Sat, 17 Jul 2021 20:31:30 +0300 Subject: [PATCH 2/2] database.sqlite --- .github/workflows/ci.yml | 2 +- tests/TestCase.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d26bb8..a697fcc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: laravel: - 7.* - 8.* - prefer: + prefer: - 'prefer-lowest' - 'prefer-stable' include: diff --git a/tests/TestCase.php b/tests/TestCase.php index e8fb87b..37d41a7 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -64,7 +64,7 @@ public function getEnvironmentSetUp($app) */ protected function resetDatabase() { - file_put_contents(__DIR__.'/database.sqlite', null); + file_put_contents(__DIR__.'/database/database.sqlite', null); } /**