Skip to content

Commit e4ec812

Browse files
committed
Replace table by collection
1 parent 73227b6 commit e4ec812

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

tests/Cache/MongoCacheStoreTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public function setUp(): void
1919
parent::setUp();
2020

2121
DB::connection('mongodb')
22-
->getCollection($this->getCacheTableName())
22+
->getCollection($this->getCacheCollectionName())
2323
->createIndex(['key' => 1], ['unique' => true]);
2424
}
2525

2626
public function tearDown(): void
2727
{
2828
DB::connection('mongodb')
29-
->getCollection($this->getCacheTableName())
29+
->getCollection($this->getCacheCollectionName())
3030
->drop();
3131

3232
parent::tearDown();
@@ -47,7 +47,7 @@ public function testPutOperationShouldNotStoreExpired()
4747

4848
$store->put('foo', 'bar', 0);
4949

50-
$this->assertDatabaseMissing($this->getCacheTableName(), ['key' => $this->withCachePrefix('foo')]);
50+
$this->assertDatabaseMissing($this->getCacheCollectionName(), ['key' => $this->withCachePrefix('foo')]);
5151
}
5252

5353
public function testValueCanUpdateExistCache()
@@ -80,7 +80,7 @@ public function testAddOperationShouldNotStoreExpired()
8080
$result = $store->add('foo', 'bar', 0);
8181

8282
$this->assertFalse($result);
83-
$this->assertDatabaseMissing($this->getCacheTableName(), ['key' => $this->withCachePrefix('foo')]);
83+
$this->assertDatabaseMissing($this->getCacheCollectionName(), ['key' => $this->withCachePrefix('foo')]);
8484
}
8585

8686
public function testAddOperationCanStoreNewCache()
@@ -162,7 +162,7 @@ public function testGetOperationCanDeleteExpired()
162162

163163
$store->get('foo');
164164

165-
$this->assertDatabaseMissing($this->getCacheTableName(), ['key' => $this->withCachePrefix('foo')]);
165+
$this->assertDatabaseMissing($this->getCacheCollectionName(), ['key' => $this->withCachePrefix('foo')]);
166166
}
167167

168168
public function testForgetIfExpiredOperationCanDeleteExpired()
@@ -173,7 +173,7 @@ public function testForgetIfExpiredOperationCanDeleteExpired()
173173

174174
$store->forgetIfExpired('foo');
175175

176-
$this->assertDatabaseMissing($this->getCacheTableName(), ['key' => $this->withCachePrefix('foo')]);
176+
$this->assertDatabaseMissing($this->getCacheCollectionName(), ['key' => $this->withCachePrefix('foo')]);
177177
}
178178

179179
public function testForgetIfExpiredOperationShouldNotDeleteUnExpired()
@@ -184,7 +184,7 @@ public function testForgetIfExpiredOperationShouldNotDeleteUnExpired()
184184

185185
$store->forgetIfExpired('foo');
186186

187-
$this->assertDatabaseHas($this->getCacheTableName(), ['key' => $this->withCachePrefix('foo')]);
187+
$this->assertDatabaseHas($this->getCacheCollectionName(), ['key' => $this->withCachePrefix('foo')]);
188188
}
189189

190190
public function testIncrementDecrement()
@@ -210,9 +210,9 @@ protected function getStore(): Repository
210210
return $repository;
211211
}
212212

213-
protected function getCacheTableName(): string
213+
protected function getCacheCollectionName(): string
214214
{
215-
return config('cache.stores.mongodb.table');
215+
return config('cache.stores.mongodb.collection');
216216
}
217217

218218
protected function withCachePrefix(string $key): string
@@ -223,7 +223,7 @@ protected function withCachePrefix(string $key): string
223223
protected function insertToCacheTable(string $key, $value, $ttl = 60)
224224
{
225225
DB::connection('mongodb')
226-
->getCollection($this->getCacheTableName())
226+
->getCollection($this->getCacheCollectionName())
227227
->insertOne([
228228
'key' => $this->withCachePrefix($key),
229229
'value' => $value,

tests/Cache/MongoLockTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public function setUp(): void
1515
{
1616
parent::setUp();
1717

18-
DB::connection('mongodb')->getCollection('cache_locks')
18+
DB::connection('mongodb')->getCollection('foo_cache_locks')
1919
->createIndex(['name' => 1], ['unique' => true]);
2020
}
2121

2222
public function tearDown(): void
2323
{
24-
DB::connection('mongodb')->getCollection('cache_locks')->drop();
24+
DB::connection('mongodb')->getCollection('foo_cache_locks')->drop();
2525

2626
parent::tearDown();
2727
}
@@ -60,7 +60,7 @@ public function testExpiredLockCanBeRetrieved()
6060
{
6161
$lock = $this->getCache()->lock('foo');
6262
$this->assertTrue($lock->get());
63-
DB::table('cache_locks')->update(['expiration' => now()->subDays(1)->getTimestamp()]);
63+
DB::table('foo_cache_locks')->update(['expiration' => now()->subDays(1)->getTimestamp()]);
6464

6565
$otherLock = $this->getCache()->lock('foo');
6666
$this->assertTrue($otherLock->get());

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function getEnvironmentSetUp($app)
7878
$app['config']->set('cache.stores.mongodb', [
7979
'driver' => 'mongodb',
8080
'connection' => 'mongodb',
81-
'table' => 'cache',
81+
'collection' => 'foo_cache',
8282
]);
8383

8484
$app['config']->set('queue.default', 'database');

0 commit comments

Comments
 (0)