Esempio n. 1
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
require_once dirname(dirname(__DIR__)) . '/src/Tokenizer.class.php';
$tx = new rkphplib\Tokenizer();
$th->compare('escape', [$tx->escape('abc efg'), $tx->escape('a{b}c'), $tx->escape('{:=c} {x:} {aa:bb} {:aa}')], ['abc efg', 'a{b}c', '&#123;&#58;=c&#125; &#123;x&#58;&#125; &#123;aa&#58;bb&#125; &#123;&#58;aa&#125;']);
$th->compare('unescape', [$tx->unescape('abc efg'), $tx->unescape('a{b}c'), $tx->unescape('&#123;&#58;=c&#125; &#123;x&#58;&#125; &#123;aa&#58;bb&#125; &#123;&#58;aa&#125;')], ['abc efg', 'a{b}c', '{:=c} {x:} {aa:bb} {:aa}']);
$th->runTokenizer(1, array());
Esempio n. 2
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
$th->load('src/Session.class.php');
$sess = new \rkphplib\Session();
$sess->init(['name' => 'test']);
$th->compareHash('Session init', $sess->getMetaHash(), ['script' => 'run.php']);
$th->compare('hasMeta(script)', [$sess->hasMeta('script')], [true]);
$th->compare('getMeta(docroot)', [$sess->getMeta('docroot')], ['']);
$sess->setMeta('host', 'localhost');
$th->compare('set|getMeta(host)', [$sess->getMeta('host')], ['localhost']);
$th->compare('getConf(inactive)', [$sess->getConf('inactive')], [7200]);
$th->compare('getSessionKey()', [$sess->getSessionKey()], [md5('test:docroot')]);
$sess->set('abc', 3);
$th->compare('has|get()', [$sess->has('abc'), $sess->get('abc')], [true, 3]);
$sess->setHash(['abc' => 5, 'x' => 'a']);
$th->compareHash('getHash()', $sess->getHash(), ['abc' => 5, 'x' => 'a']);
$js = <<<END
window.setInterval( function() {
\t\$.ajax({
\t\tcache: false,
\t\ttype: "GET",
\t\t\turl: "test.php"
\t\t\t
    });
}, 600000);
END;