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
·36 lines (31 loc) · 1.39 KB
/
CacheMemcachedConnectorTest.php
File metadata and controls
executable file
·36 lines (31 loc) · 1.39 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
<?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', ['getMemcached']);
$memcached = m::mock('stdClass');
$memcached->shouldReceive('addServer')->once()->with('localhost', 11211, 100);
$memcached->shouldReceive('getVersion')->once()->andReturn([]);
$connector->expects($this->once())->method('getMemcached')->will($this->returnValue($memcached));
$result = $connector->connect([['host' => 'localhost', 'port' => 11211, 'weight' => 100]]);
$this->assertSame($result, $memcached);
}
/**
* @expectedException RuntimeException
*/
public function testExceptionThrownOnBadConnection()
{
$connector = $this->getMock('Illuminate\Cache\MemcachedConnector', ['getMemcached']);
$memcached = m::mock('stdClass');
$memcached->shouldReceive('addServer')->once()->with('localhost', 11211, 100);
$memcached->shouldReceive('getVersion')->once()->andReturn(['255.255.255']);
$connector->expects($this->once())->method('getMemcached')->will($this->returnValue($memcached));
$result = $connector->connect([['host' => 'localhost', 'port' => 11211, 'weight' => 100]]);
}
}