From 6fbd2902be169edb93a059225f1778196299d4ea Mon Sep 17 00:00:00 2001 From: Marcel Beerta Date: Sun, 19 Feb 2012 19:54:54 +0100 Subject: [PATCH] Improved unit tests for MemcacheSessionStorage --- .../Storage/MemcacheSessionStorageTest.php | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/MemcacheSessionStorageTest.php b/tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/MemcacheSessionStorageTest.php index a8327e0f9c..1cdbe2a3a9 100644 --- a/tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/MemcacheSessionStorageTest.php +++ b/tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/MemcacheSessionStorageTest.php @@ -32,11 +32,48 @@ class MemcacheSessionStorageTest extends \PHPUnit_Framework_TestCase public function testOpenSession() { $this->memcache->expects($this->atLeastOnce()) - ->method('addServer'); + ->method('addServer') + ->with('127.0.0.1', 11211, false, 1, 1, 15); $this->assertTrue($this->storage->open('', '')); } + public function testConstructingWithServerPool() + { + $mock = $this->getMock('Memcache'); + + $storage = new MemcacheSessionStorage($mock, array( + 'serverpool' => array( + array('host' => '127.0.0.2'), + array('host' => '127.0.0.3', + 'port' => 11212, + 'timeout' => 10, + 'persistent' => true, + 'weight' => 5, + 'retry_interval' => 39, + ), + array('host' => '127.0.0.4', + 'port' => 11211, + 'weight' => 2 + ), + ), + )); + + $matcher = $mock + ->expects($this->at(0)) + ->method('addServer') + ->with('127.0.0.2', 11211, false, 1, 1, 15); + $matcher = $mock + ->expects($this->at(1)) + ->method('addServer') + ->with('127.0.0.3', 11212, true, 5, 10, 39); + $matcher = $mock + ->expects($this->at(2)) + ->method('addServer') + ->with('127.0.0.4', 11211, false, 2, 1, 15); + $this->assertTrue($storage->open('', '')); + } + public function testCloseSession() { $this->memcache->expects($this->once())