~ufirst/phpredis/igbinary

« back to all changes in this revision

Viewing changes to tests/igbinary_012.phpt

  • Committer: Michael Ruoss
  • Date: 2015-03-18 14:12:19 UTC
  • Revision ID: git-v1:c591bdc61de714458440ff13454bc51d94ab5f3d
new build info structure

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--TEST--
2
 
Object test
3
 
--SKIPIF--
4
 
--FILE--
5
 
<?php 
6
 
if(!extension_loaded('igbinary')) {
7
 
        dl('igbinary.' . PHP_SHLIB_SUFFIX);
8
 
}
9
 
 
10
 
function test($type, $variable, $test) {
11
 
        $serialized = igbinary_serialize($variable);
12
 
        $unserialized = igbinary_unserialize($serialized);
13
 
//      $serialized = serialize($variable);
14
 
//      $unserialized = unserialize($serialized);
15
 
 
16
 
        echo $type, "\n";
17
 
        echo substr(bin2hex($serialized), 8), "\n";
18
 
//      echo $serialized, "\n";
19
 
        echo $test || $unserialized == $variable ? 'OK' : 'ERROR';
20
 
        echo "\n";
21
 
}
22
 
 
23
 
class Obj {
24
 
        public $a;
25
 
        protected $b;
26
 
        private $c;
27
 
 
28
 
        function __construct($a, $b, $c) {
29
 
                $this->a = $a;
30
 
                $this->b = $b;
31
 
                $this->c = $c;
32
 
        }
33
 
}
34
 
 
35
 
$o = new Obj(1, 2, 3);
36
 
 
37
 
 
38
 
test('object', $o, false);
39
 
 
40
 
/*
41
 
 * you can add regression tests for your extension here
42
 
 *
43
 
 * the output of your test code has to be equal to the
44
 
 * text in the --EXPECT-- section below for the tests
45
 
 * to pass, differences between the output and the
46
 
 * expected text are interpreted as failure
47
 
 *
48
 
 * see php5/README.TESTING for further information on
49
 
 * writing regression tests
50
 
 */
51
 
?>
52
 
--EXPECT--
53
 
object
54
 
17034f626a140311016106011104002a006206021106004f626a00630603
55
 
OK