\n"; return 1; } $testMethod = 'do' . ucfirst($argv[1]); if (!method_exists($this, $testMethod)) { echo "Invalid test: '{$argv[1]}'\n"; return 2; } array_shift($argv); array_shift($argv); return $this->$testMethod($argv); } /** * @param array $args * @return integer Always returns zero. */ public function doExpireAll(array $args) { Zend_Session::setOptions(array('remember_me_seconds' => 15, 'gc_probability' => 2)); session_id($args[0]); if (isset($args[1]) && !empty($args[1])) { $s = new Zend_Session_Namespace($args[1]); } else { $s = new Zend_Session_Namespace(); } $result = ''; foreach ($s->getIterator() as $key => $val) { $result .= "$key === $val;"; } Zend_Session::expireSessionCookie(); Zend_Session::writeClose(); echo $result; return 0; } /** * @param array $args * @return integer Always returns zero. */ public function doSetArray(array $args) { $GLOBALS['fpc'] = 'set'; session_id($args[0]); $s = new Zend_Session_Namespace($args[1]); array_shift($args); $s->astring = 'happy'; // works, even for broken versions of PHP // $s->someArray = array( & $args ) ; // $args['OOOOOOOOOOOOOOOO'] = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYY'; $s->someArray = $args; $s->someArray['bee'] = 'honey'; // Repeating this line twice "solves" the problem for some versions of PHP, $s->someArray['bee'] = 'honey'; // but PHP 5.2.1 has the real fix for ZF-800. $s->someArray['ant'] = 'sugar'; $s->someArray['dog'] = 'cat'; // file_put_contents('out.sessiontest.set', (str_replace(array("\n", ' '),array(';',''), print_r($_SESSION, true))) ); $s->serializedArray = serialize($args); $result = ''; foreach ($s->getIterator() as $key => $val) { $result .= "$key === ". (print_r($val,true)) .';'; } Zend_Session::writeClose(); return 0; } /** * @param array $args * @return integer Always returns zero. */ public function doGetArray(array $args) { $GLOBALS['fpc'] = 'get'; session_id($args[0]); if (isset($args[1]) && !empty($args[1])) { $s = new Zend_Session_Namespace($args[1]); } else { $s = new Zend_Session_Namespace(); } $result = ''; foreach ($s->getIterator() as $key => $val) { $result .= "$key === ". (str_replace(array("\n", ' '),array(';',''), print_r($val, true))) .';'; } // file_put_contents('out.sesstiontest.get', print_r($s->someArray, true)); Zend_Session::writeClose(); echo $result; return 0; } } $testHelper = new Zend_Session_TestHelper(); exit($testHelper->run($argv));