merged branch drak/session_memcached_tests (PR #3338)
Commits
-------
cab1060
[HttpFoundation] Add tests for session memcache/d storage drivers.
Discussion
----------
[HttpFoundation] Add tests for session memcache/d storage drivers.
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
This commit is contained in:
commit
7401338e46
@ -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']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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('', ''));
|
||||
}
|
||||
|
Reference in New Issue
Block a user