cvs: pear /HTTP_Session2/tests test-session.phpt test-session2.phpt

[email protected] ("Till Klampaeckel") Thu, 08 May 2008 11:23:46 -0000
Newsgroups php.pear.cvs
Message-ID <cvstill1210245826@cvsserver>
till		Thu May  8 11:23:46 2008 UTC

  Added files:                 
    /pear/HTTP_Session2/tests	test-session.phpt test-session2.phpt 
  Log:
  * new tests (set, read):
   * test-session.phpt - vanilla test for php sessions
   * test-session2.phpt - test for HTTP_Session2
  
  
  

http://cvs.php.net/viewvc.cgi/pear/HTTP_Session2/tests/test-session.phpt?view=markup&rev=1.1
Index: pear/HTTP_Session2/tests/test-session.phpt
+++ pear/HTTP_Session2/tests/test-session.phpt
--TEST--
Vanilla testing session write and read
--FILE--
<?php
$_tmp = dirname(__FILE__) . '/tmp';
$_id  = 1234;

if (!file_exists($_tmp)) {
    mkdir($_tmp);
}
ini_set('session.save_path', $_tmp);
session_id($_id);

session_start();

$nCount = 0;
while(++$nCount <= 2) {
    if (!isset($_SESSION['test'])) {
        var_dump("Setting..");
        $_SESSION['test'] = 'foobar';
    } else {
        var_dump("Retrieving..");
        var_dump($_SESSION['test']);
    }
}
--CLEAN--
<?php
$_tmp = dirname(__FILE__) . '/tmp';
$_id  = 1234;

unlink($_tmp . '/' . 'sess_' . $_id);
rmdir($_tmp);
--EXPECT--
string(9) "Setting.."
string(12) "Retrieving.."
string(6) "foobar"


http://cvs.php.net/viewvc.cgi/pear/HTTP_Session2/tests/test-session2.phpt?view=markup&rev=1.1
Index: pear/HTTP_Session2/tests/test-session2.phpt
+++ pear/HTTP_Session2/tests/test-session2.phpt
--TEST--
HTTP_Session2 testing session write and read
--FILE--
<?php
$_tmp = dirname(__FILE__) . '/tmp';
$_id  = 1234;

require_once 'HTTP/Session2.php';

if (!file_exists($_tmp)) {
    mkdir($_tmp);
}
ini_set('session.save_path', $_tmp);

HTTP_Session2::useCookies(false);
HTTP_Session2::start('testSession');
HTTP_Session2::id($_id);

$nCount = 0;
while(++$nCount <= 2) {
    $_var = HTTP_Session2::get('test', 'bar');
    if ($_var == 'bar') {
        var_dump("Setting..");
        HTTP_Session2::set('test', 'foobar');
    } else {
        var_dump("Retrieving..");
        var_dump(HTTP_Session2::get('test'));
    }
}
--CLEAN--
<?php
$_tmp = dirname(__FILE__) . '/tmp';
$_id  = 1234;

unlink($_tmp . '/' . 'sess_' . $_id);
rmdir($_tmp);
--EXPECT--
string(9) "Setting.."
string(12) "Retrieving.."
string(6) "foobar"