コード例 #1
0
ファイル: UtilTest.php プロジェクト: aiddroid/utilphp
 public function test_maybe_serialize()
 {
     $obj = new stdClass();
     $obj->prop1 = 'Hello';
     $obj->prop2 = 'World';
     $this->assertEquals('This is a string', util::maybe_serialize('This is a string'));
     $this->assertEquals(5.81, util::maybe_serialize(5.81));
     $this->assertEquals('a:0:{}', util::maybe_serialize(array()));
     $this->assertEquals('O:8:"stdClass":2:{s:5:"prop1";s:5:"Hello";s:5:"prop2";s:5:"World";}', util::maybe_serialize($obj));
     $this->assertEquals('a:4:{i:0;s:4:"test";i:1;s:4:"blah";s:5:"hello";s:5:"world";s:5:"array";O:8:"stdClass":2:{s:5:"prop1";s:5:"Hello";s:5:"prop2";s:5:"World";}}', util::maybe_serialize(array('test', 'blah', 'hello' => 'world', 'array' => $obj)));
 }