forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCacheMemcachedStoreTest.php
More file actions
executable file
·69 lines (54 loc) · 2.5 KB
/
CacheMemcachedStoreTest.php
File metadata and controls
executable file
·69 lines (54 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
class CacheMemcachedStoreTest extends PHPUnit_Framework_TestCase {
public function testGetReturnsNullWhenNotFound()
{
$memcache = $this->getMock('StdClass', array('get', 'getResultCode'));
$memcache->expects($this->once())->method('get')->with($this->equalTo('foo:bar'))->will($this->returnValue(null));
$memcache->expects($this->once())->method('getResultCode')->will($this->returnValue(1));
$store = new Illuminate\Cache\MemcachedStore($memcache, 'foo');
$this->assertNull($store->get('bar'));
}
public function testMemcacheValueIsReturned()
{
$memcache = $this->getMock('StdClass', array('get', 'getResultCode'));
$memcache->expects($this->once())->method('get')->will($this->returnValue('bar'));
$memcache->expects($this->once())->method('getResultCode')->will($this->returnValue(0));
$store = new Illuminate\Cache\MemcachedStore($memcache);
$this->assertEquals('bar', $store->get('foo'));
}
public function testSetMethodProperlyCallsMemcache()
{
$memcache = $this->getMock('Memcached', array('set'));
$memcache->expects($this->once())->method('set')->with($this->equalTo('foo'), $this->equalTo('bar'), $this->equalTo(60));
$store = new Illuminate\Cache\MemcachedStore($memcache);
$store->put('foo', 'bar', 1);
}
public function testIncrementMethodProperlyCallsMemcache()
{
$memcache = $this->getMock('Memcached', array('increment'));
$memcache->expects($this->once())->method('increment')->with($this->equalTo('foo'), $this->equalTo(5));
$store = new Illuminate\Cache\MemcachedStore($memcache);
$store->increment('foo', 5);
}
public function testDecrementMethodProperlyCallsMemcache()
{
$memcache = $this->getMock('Memcached', array('decrement'));
$memcache->expects($this->once())->method('decrement')->with($this->equalTo('foo'), $this->equalTo(5));
$store = new Illuminate\Cache\MemcachedStore($memcache);
$store->decrement('foo', 5);
}
public function testStoreItemForeverProperlyCallsMemcached()
{
$memcache = $this->getMock('Memcached', array('set'));
$memcache->expects($this->once())->method('set')->with($this->equalTo('foo'), $this->equalTo('bar'), $this->equalTo(0));
$store = new Illuminate\Cache\MemcachedStore($memcache);
$store->forever('foo', 'bar');
}
public function testForgetMethodProperlyCallsMemcache()
{
$memcache = $this->getMock('Memcached', array('delete'));
$memcache->expects($this->once())->method('delete')->with($this->equalTo('foo'));
$store = new Illuminate\Cache\MemcachedStore($memcache);
$store->forget('foo');
}
}