From 32f7a5c3c479f71319cdabfc38fbee3fa6891ded Mon Sep 17 00:00:00 2001 From: xdevor <0.yu.zhuang@gmail.com> Date: Sun, 12 Nov 2023 16:07:17 +0800 Subject: [PATCH] Refactor db cache store integration test --- .github/workflows/databases.yml | 10 +-- .../Cache/Database/SqliteCacheStoreTest.php | 75 ------------------- .../Database/DatabaseCacheStoreTest.php | 2 +- 3 files changed, 6 insertions(+), 81 deletions(-) delete mode 100644 tests/Integration/Cache/Database/SqliteCacheStoreTest.php rename tests/Integration/{Cache => }/Database/DatabaseCacheStoreTest.php (96%) diff --git a/.github/workflows/databases.yml b/.github/workflows/databases.yml index 3eff811ae64a..20e008c66cbe 100644 --- a/.github/workflows/databases.yml +++ b/.github/workflows/databases.yml @@ -48,7 +48,7 @@ jobs: command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit tests/Integration/Database tests/Integration/Cache/Database + run: vendor/bin/phpunit tests/Integration/Database env: DB_CONNECTION: mysql DB_USERNAME: root @@ -93,7 +93,7 @@ jobs: command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit tests/Integration/Database tests/Integration/Cache/Database + run: vendor/bin/phpunit tests/Integration/Database env: DB_CONNECTION: mysql DB_USERNAME: root @@ -138,7 +138,7 @@ jobs: command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit tests/Integration/Database tests/Integration/Cache/Database + run: vendor/bin/phpunit tests/Integration/Database env: DB_CONNECTION: mysql DB_USERNAME: root @@ -184,7 +184,7 @@ jobs: command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit tests/Integration/Database tests/Integration/Cache/Database + run: vendor/bin/phpunit tests/Integration/Database env: DB_CONNECTION: pgsql DB_PASSWORD: password @@ -228,7 +228,7 @@ jobs: command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit tests/Integration/Database tests/Integration/Cache/Database + run: vendor/bin/phpunit tests/Integration/Database env: DB_CONNECTION: sqlsrv DB_DATABASE: master diff --git a/tests/Integration/Cache/Database/SqliteCacheStoreTest.php b/tests/Integration/Cache/Database/SqliteCacheStoreTest.php deleted file mode 100644 index d71980d39a9a..000000000000 --- a/tests/Integration/Cache/Database/SqliteCacheStoreTest.php +++ /dev/null @@ -1,75 +0,0 @@ -markTestSkipped('Test requires a Sqlite connection.'); - } - - $app['config']->set('database.default', 'conn1'); - - $app['config']->set('database.connections.conn1', [ - 'driver' => 'sqlite', - 'database' => ':memory:', - 'prefix' => '', - ]); - } - - protected function defineDatabaseMigrationsAfterDatabaseRefreshed() - { - $this->createCacheTables(); - } - - protected function destroyDatabaseMigrations() - { - $this->dropCacheTables(); - } - - public function testValueCanStoreNewCache() - { - $store = $this->getStore(); - - $store->put('foo', 'bar', 60); - - $this->assertSame('bar', $store->get('foo')); - } - - public function testValueCanUpdateExistCache() - { - $store = $this->getStore(); - - $store->put('foo', 'bar', 60); - $store->put('foo', 'new-bar', 60); - - $this->assertSame('new-bar', $store->get('foo')); - } - - public function testValueCanUpdateExistCacheInTransaction() - { - $store = $this->getStore(); - - $store->put('foo', 'bar', 60); - - DB::beginTransaction(); - $store->put('foo', 'new-bar', 60); - DB::commit(); - - $this->assertSame('new-bar', $store->get('foo')); - } - - protected function getStore() - { - return Cache::store('database'); - } -} diff --git a/tests/Integration/Cache/Database/DatabaseCacheStoreTest.php b/tests/Integration/Database/DatabaseCacheStoreTest.php similarity index 96% rename from tests/Integration/Cache/Database/DatabaseCacheStoreTest.php rename to tests/Integration/Database/DatabaseCacheStoreTest.php index af6b3f636343..3487b20bbd81 100644 --- a/tests/Integration/Cache/Database/DatabaseCacheStoreTest.php +++ b/tests/Integration/Database/DatabaseCacheStoreTest.php @@ -1,6 +1,6 @@