Example #1
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
$th->load('src/lib/conf2kv.php');
$th->runFuncTest('conf2kv');
Example #2
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
$th->runTokenizer(15, array('TBase'));
Example #3
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());
Example #4
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
/**
 *
 */
function test_exists($path_list)
{
    $res = array();
    foreach ($path_list as $path) {
        try {
            if (\rkphplib\Dir::exists($path, true)) {
                array_push($res, 1);
            }
        } catch (Exception $e) {
            array_push($res, 0);
        }
    }
    return $res;
}
$th->load('src/Dir.class.php');
$th->callTest('test_exists', array('/etc', '/etc/apache2', '/var/lib/mysql'), array('Dir::exits()', 1, 1, 0));
Example #5
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
$th->load('src/lib/replace_tags.php');
$th->runFuncTest('replace_tags');
Example #6
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
$th->load('src/DateCalc.class.php');
$th->runFuncTest('sql2num');
$th->runFuncTest('max');
$th->runFuncTest('sqlTS');
$th->runFuncTest('sqlAddMonth');
$th->runFuncTest('date2unix');
$th->runFuncTest('dmy2unix');
$th->runFuncTest('date2dmyhis');
$th->runFuncTest('date2dmy');
$th->runFuncTest('sql_date');
$th->runFuncTest('min_sec');
$th->runFuncTest('kw');
$th->runFuncTest('hms2sec');
$th->runFuncTest('sec2hms');
$th->runFuncTest('nowstr2time');
$th->runFuncTest('nextMonth');
$th->runFuncTest('prevMonth');
$th->runFuncTest('lastDay');
$th->runFuncTest('sqlDayOfYear');
$th->runFuncTest('formatDateStr');
$th->runFuncTest('formatDateTimeStr');
Example #7
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;
Example #8
0
<?php

require_once dirname(__DIR__) . '/src/TestHelper.class.php';
$th = new rkphplib\TestHelper();
// ob_* is necessary because of Session/run.php
ob_start();
$th->runTest('Session/run.php');
$res = ob_get_contents();
ob_end_clean();
print $res;
$th->runTest('lib_conf2kv/run.php');
$th->runTest('lib_kv2conf/run.php');
$th->runTest('lib_split_str/run.php');
$th->runTest('lib_csv_explode/run.php');
$th->runTest('lib_replace_tags/run.php');
$th->runTest('DateTime/run.php');
$th->runTest('Tokenizer/run.php');
$th->runTest('Dir/run.php');
$th->runTest('TBase/run.php');
$th->result();
// ToDo ...
// run_test('MysqlDatabase/run.php');
Example #9
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
$th->load('src/lib/split_str.php');
$th->runFuncTest('split_str');
Example #10
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
$th->load('src/lib/kv2conf.php');
$th->runFuncTest('kv2conf');
Example #11
0
<?php

global $th;
if (!isset($th)) {
    require_once dirname(dirname(__DIR__)) . '/src/TestHelper.class.php';
    $th = new rkphplib\TestHelper();
}
$th->load('src/lib/csv_explode.php');
$th->runFuncTest('csv_explode');