forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCacheMemcachedConnectorTest.php
More file actions
executable file
·39 lines (30 loc) · 1.3 KB
/
CacheMemcachedConnectorTest.php
File metadata and controls
executable file
·39 lines (30 loc) · 1.3 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
<?php
use Mockery as m;
class CacheMemcachedConnectorTest extends PHPUnit_Framework_TestCase {
public function tearDown()
{
m::close();
}
public function testServersAreAddedCorrectly()
{
$connector = $this->getMock('Illuminate\Cache\MemcachedConnector', array('getMemcached'));
$memcached = m::mock('stdClass');
$memcached->shouldReceive('addServer')->once()->with('localhost', 11211, 100);
$memcached->shouldReceive('getVersion')->once()->andReturn(true);
$connector->expects($this->once())->method('getMemcached')->will($this->returnValue($memcached));
$result = $connector->connect(array(array('host' => 'localhost', 'port' => 11211, 'weight' => 100)));
$this->assertTrue($result === $memcached);
}
/**
* @expectedException RuntimeException
*/
public function testExceptionThrownOnBadConnection()
{
$connector = $this->getMock('Illuminate\Cache\MemcachedConnector', array('getMemcached'));
$memcached = m::mock('stdClass');
$memcached->shouldReceive('addServer')->once()->with('localhost', 11211, 100);
$memcached->shouldReceive('getVersion')->once()->andReturn(false);
$connector->expects($this->once())->method('getMemcached')->will($this->returnValue($memcached));
$result = $connector->connect(array(array('host' => 'localhost', 'port' => 11211, 'weight' => 100)));
}
}