[HttpFoundation] Add tests for session memcache/d storage drivers.

This commit is contained in:
Drak 2012-02-12 20:05:27 +05:45
parent fc7d0110f7
commit cab1060a76
3 changed files with 7 additions and 27 deletions

View File

@ -47,11 +47,9 @@ class MemcachedSessionStorage extends AbstractSessionStorage implements SessionS
// defaults
if (!isset($memcachedOptions['serverpool'])) {
$memcachedOptions['serverpool'] = array(
$memcachedOptions['serverpool'][] = array(
'host' => '127.0.0.1',
'port' => 11211,
'timeout' => 1,
'persistent' => false,
'weight' => 1);
}
@ -59,7 +57,7 @@ class MemcachedSessionStorage extends AbstractSessionStorage implements SessionS
$this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, isset($memcachedOptions['prefix']) ? $memcachedOptions['prefix'] : 'sf2s');
$this->memcacheOptions = $memcachedOptions;
$this->memcachedOptions = $memcachedOptions;
parent::__construct($options);
}
@ -69,11 +67,7 @@ class MemcachedSessionStorage extends AbstractSessionStorage implements SessionS
*/
public function openSession($savePath, $sessionName)
{
foreach ($this->memcachedOptions['serverpool'] as $server) {
$this->addServer($server);
}
return true;
return $this->memcached->addServers($this->memcachedOptions['serverpool']);
}
/**

View File

@ -29,14 +29,6 @@ class MemcacheSessionStorageTest extends \PHPUnit_Framework_TestCase
$this->storage = null;
}
public function testConstructor()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
public function testOpenSession()
{
$this->memcache->expects($this->atLeastOnce())
@ -48,7 +40,8 @@ class MemcacheSessionStorageTest extends \PHPUnit_Framework_TestCase
public function testCloseSession()
{
$this->memcache->expects($this->once())
->method('close');
->method('close')
->will($this->returnValue(true));
$this->assertTrue($this->storage->closeSession());
}

View File

@ -29,18 +29,11 @@ class MemcacheddSessionStorageTest extends \PHPUnit_Framework_TestCase
$this->storage = null;
}
public function testConstructor()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
public function testOpenSession()
{
$this->memcached->expects($this->atLeastOnce())
->method('addServer');
->method('addServers')
->will($this->returnValue(true));
$this->assertTrue($this->storage->openSession('', ''));
}