1--TEST-- 2Check for serialization handler 3--SKIPIF-- 4<?php 5if (!extension_loaded('session')) { 6 exit('skip session extension not loaded'); 7} 8 9ob_start(); 10phpinfo(INFO_MODULES); 11$str = ob_get_clean(); 12 13$array = explode("\n", $str); 14$array = preg_grep('/^igbinary session support.*yes/', $array); 15if (!$array) { 16 exit('skip igbinary session handler not available'); 17} 18 19 20--FILE-- 21<?php 22 23$output = ''; 24 25function open($path, $name) { 26 return true; 27} 28 29function close() { 30 return true; 31} 32 33function read($id) { 34 global $output; 35 $output .= "read\n"; 36 return pack('H*', '0000000214011103666f6f0601'); 37} 38 39function write($id, $data) { 40 global $output; 41 $output .= "wrote: "; 42 $output .= substr(bin2hex($data), 8). "\n"; 43 return true; 44} 45 46function destroy($id) { 47 return true; 48} 49 50function gc($time) { 51 return true; 52} 53 54class Foo { 55} 56 57class Bar { 58} 59 60ini_set('session.serialize_handler', 'igbinary'); 61 62session_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(); 69var_dump($v); 70$_SESSION['test'] = "foobar"; 71 72session_write_close(); 73 74echo $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 TESTING.md for further information on 85 * writing regression tests 86 */ 87?> 88--EXPECT-- 89bool(true) 90read 91wrote: 14021103666f6f06011104746573741106666f6f626172 92