~ufirst/phpredis/igbinary

« back to all changes in this revision

Viewing changes to tests/igbinary_027.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
 
Check for serialization handler
3
 
--SKIPIF--
4
 
<?php
5
 
if (!extension_loaded('session')) {
6
 
        exit('skip session extension not loaded');
7
 
}
8
 
 
9
 
ob_start(); 
10
 
phpinfo(INFO_MODULES);
11
 
$str = ob_get_clean();
12
 
 
13
 
$array = explode("\n", $str); 
14
 
$array = preg_grep('/^igbinary session support.*yes/', $array); 
15
 
if (!$array) {
16
 
        exit('skip igbinary session handler not available');
17
 
}
18
 
 
19
 
 
20
 
--FILE--
21
 
<?php 
22
 
 
23
 
$output = '';
24
 
 
25
 
function open($path, $name) {
26
 
        return true;
27
 
}
28
 
 
29
 
function close() {
30
 
        return true;
31
 
}
32
 
 
33
 
function read($id) {
34
 
        global $output;
35
 
        $output .= "read\n";
36
 
        return pack('H*', '0000000214011103666f6f0601');
37
 
}
38
 
 
39
 
function write($id, $data) {
40
 
        global $output;
41
 
        $output .= "wrote: ";
42
 
        $output .= substr(bin2hex($data), 8). "\n";
43
 
        return true;
44
 
}
45
 
 
46
 
function destroy($id) {
47
 
        return true;
48
 
}
49
 
 
50
 
function gc($time) {
51
 
        return true;
52
 
}
53
 
 
54
 
class Foo {
55
 
}
56
 
 
57
 
class Bar {
58
 
}
59
 
 
60
 
ini_set('session.serialize_handler', 'igbinary');
61
 
 
62
 
session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
63
 
 
64
 
 
65
 
$db_object = new Foo();
66
 
$session_object = new Bar();
67
 
 
68
 
$v = session_start();
69
 
var_dump($v);
70
 
$_SESSION['test'] = "foobar";
71
 
 
72
 
session_write_close();
73
 
 
74
 
echo $output;
75
 
 
76
 
/*
77
 
 * you can add regression tests for your extension here
78
 
 *
79
 
 * the output of your test code has to be equal to the
80
 
 * text in the --EXPECT-- section below for the tests
81
 
 * to pass, differences between the output and the
82
 
 * expected text are interpreted as failure
83
 
 *
84
 
 * see php5/README.TESTING for further information on
85
 
 * writing regression tests
86
 
 */
87
 
?>
88
 
--EXPECT--
89
 
bool(true)
90
 
read
91
 
wrote: 14021103666f6f06011104746573741106666f6f626172