diff --git a/tests/Integration/Database/DatabaseCacheStoreTest.php b/tests/Integration/Database/DatabaseCacheStoreTest.php new file mode 100644 index 000000000000..f7384e63ca42 --- /dev/null +++ b/tests/Integration/Database/DatabaseCacheStoreTest.php @@ -0,0 +1,70 @@ +string('key')->primary(); + $table->mediumText('value'); + $table->integer('expiration'); + }); + + + Schema::create('cache_locks', function (Blueprint $table) { + $table->string('key')->primary(); + $table->string('owner'); + $table->integer('expiration'); + }); + } + + protected function destroyDatabaseMigrations() + { + Schema::dropIfExists('cache'); + Schema::dropIfExists('cache_locks'); + } + + public function testValueCanBePut() + { + $store = $this->getStore(); + + $store->put('foo', 'bar', 60); + + $this->assertSame('bar', $store->get('foo')); + } + + public function testValueCanBeUpdate() + { + $store = $this->getStore(); + + $store->put('foo', 'bar', 60); + $store->put('foo', 'new-bar', 60); + + $this->assertSame('new-bar', $store->get('foo')); + } + + public function testValueCanBeUpdateInTransaction() + { + $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'); + } +}