PhpHandlerTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Ratchet\Session\Serialize;
  3. use Ratchet\Session\Serialize\PhpHandler;
  4. /**
  5. * @covers Ratchet\Session\Serialize\PhpHandler
  6. */
  7. class PhpHandlerTest extends \PHPUnit_Framework_TestCase {
  8. protected $_handler;
  9. public function setUp() {
  10. $this->_handler = new PhpHandler;
  11. }
  12. public function serializedProvider() {
  13. return array(
  14. array(
  15. '_sf2_attributes|a:2:{s:5:"hello";s:5:"world";s:4:"last";i:1332872102;}_sf2_flashes|a:0:{}'
  16. , array(
  17. '_sf2_attributes' => array(
  18. 'hello' => 'world'
  19. , 'last' => 1332872102
  20. )
  21. , '_sf2_flashes' => array()
  22. )
  23. )
  24. );
  25. }
  26. /**
  27. * @dataProvider serializedProvider
  28. */
  29. public function testUnserialize($in, $expected) {
  30. $this->assertEquals($expected, $this->_handler->unserialize($in));
  31. }
  32. /**
  33. * @dataProvider serializedProvider
  34. */
  35. public function testSerialize($serialized, $original) {
  36. $this->assertEquals($serialized, $this->_handler->serialize($original));
  37. }
  38. }