Skip to content

Commit

Permalink
Added unit tests for serialize, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cboden committed May 25, 2016
1 parent 1028c03 commit f5e8a18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Ratchet/Session/Serialize/PhpHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class PhpHandler implements HandlerInterface {
function serialize(array $data) {
$preSerialized = array();
$serialized = '';

if (count($data)) {
foreach ($data as $bucket => $bucketData) {
$preSerialized[] = $bucket . '|' . serialize($bucketData);
}
$serialized = implode('',$preSerialized);
$serialized = implode('', $preSerialized);
}

return $serialized;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/Session/Serialize/PhpHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ public function serializedProvider() {
public function testUnserialize($in, $expected) {
$this->assertEquals($expected, $this->_handler->unserialize($in));
}

/**
* @dataProvider serializedProvider
*/
public function testSerialize($serialized, $original) {
$this->assertEquals($serialized, $this->_handler->serialize($original));
}
}

0 comments on commit f5e8a18

Please sign in to comment.