Merge branch 'session-php-serialize'
This commit is contained in:
commit
b3b10e3d2b
@ -3,10 +3,21 @@ namespace Ratchet\Session\Serialize;
|
|||||||
|
|
||||||
class PhpHandler implements HandlerInterface {
|
class PhpHandler implements HandlerInterface {
|
||||||
/**
|
/**
|
||||||
|
* Simply reverse behaviour of unserialize method.
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
function serialize(array $data) {
|
function serialize(array $data) {
|
||||||
throw new \RuntimeException("Serialize PhpHandler:serialize code not written yet, write me!");
|
$preSerialized = array();
|
||||||
|
$serialized = '';
|
||||||
|
|
||||||
|
if (count($data)) {
|
||||||
|
foreach ($data as $bucket => $bucketData) {
|
||||||
|
$preSerialized[] = $bucket . '|' . serialize($bucketData);
|
||||||
|
}
|
||||||
|
$serialized = implode('', $preSerialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,4 +33,11 @@ class PhpHandlerTest extends \PHPUnit_Framework_TestCase {
|
|||||||
public function testUnserialize($in, $expected) {
|
public function testUnserialize($in, $expected) {
|
||||||
$this->assertEquals($expected, $this->_handler->unserialize($in));
|
$this->assertEquals($expected, $this->_handler->unserialize($in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider serializedProvider
|
||||||
|
*/
|
||||||
|
public function testSerialize($serialized, $original) {
|
||||||
|
$this->assertEquals($serialized, $this->_handler->serialize($original));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user