Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions tests/Integration/Database/DatabaseCacheStoreTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Illuminate\Tests\Integration\Database;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class DatabaseCacheStoreTest extends DatabaseTestCase
{
protected function defineDatabaseMigrationsAfterDatabaseRefreshed()
{
Schema::create('cache', function (Blueprint $table) {
$table->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');
}
}