Example #1
0
function verify_response($req, $expected)
{
    global $server;
    ob_start();
    $server->handle($req);
    $res = ob_get_contents();
    ob_end_clean();
    VS($res, $expected);
}
Example #2
0
function createSqliteTestTable($tmp_sqlite)
{
    unlink($tmp_sqlite);
    $db = new SQLite3($tmp_sqlite);
    $db->exec("CREATE TABLE foo (bar STRING)");
    $db->exec("INSERT INTO foo VALUES ('ABC')");
    $db->exec("INSERT INTO foo VALUES ('DEF')");
    VS($db->lasterrorcode(), 0);
}
Example #3
0
function test_bzerror()
{
    global $tmpfile;
    $f = fopen($tmpfile, "w");
    fwrite($f, "this is a test");
    fclose($f);
    $f = bzopen($tmpfile, "r");
    bzread($f);
    $ret = bzerror($f);
    bzclose($f);
    unlink($tmpfile);
    VS($ret, array("errno" => -5, "errstr" => "DATA_ERROR_MAGIC"));
}
Example #4
0
ob_start();
echo "test";
VS(ob_get_contents(), "test");
VS(ob_get_contents(), "test");
// verifying content stays
ob_end_clean();
ob_start();
ob_start();
echo "test";
VS(ob_get_flush(), "test");
VS(ob_get_flush(), "test");
ob_end_clean();
VS(ob_get_flush(), false);
ob_end_clean();
ob_start();
echo "test";
VS(ob_get_length(), 4);
ob_end_clean();
VS(ob_get_level(), 0);
ob_start();
VS(ob_get_level(), 1);
ob_end_clean();
VS(ob_get_level(), 0);
ob_get_status();
ob_start();
ob_start("mytolower");
$handlers = ob_list_handlers();
ob_end_clean();
ob_end_clean();
VS($handlers, array("default output handler", "mytolower"));
echo "\nok\n";
Example #5
0
function test_sql_regcase()
{
    VS(sql_regcase("Foo - bar."), "[Ff][Oo][Oo] - [Bb][Aa][Rr].");
}
Example #6
0
function test_openssl_digest()
{
    $test = "OpenSSL is also good for hashing things";
    VS(md5($test), openssl_digest($test, "md5"));
}
Example #7
0
function VERIFY($x)
{
    VS($x != false, true);
}
Example #8
0
function test_stream_socket_sendto_issue324()
{
    list($port, $address, $server) = retry_bind_server();
    $client = stream_socket_client($address);
    $s = stream_socket_accept($server);
    $text = "testing";
    VERIFY(stream_socket_sendto($client, $text, 0, ''));
    $buffer = stream_socket_recvfrom($s, 100);
    VS($buffer, $text);
}
Example #9
0
function test_stream_constants()
{
    VS(STREAM_CLIENT_CONNECT, 4);
    VS(STREAM_SERVER_LISTEN, 8);
    VS(STREAM_IPPROTO_RAW, 255);
    VS(STREAM_SOCK_SEQPACKET, 5);
}
Example #10
0
<?php

$lastday = mktime(0, 0, 0, 3, 0, 2000);
var_dump(strftime("Last day in Feb 2000 is: %d", $lastday));
function VS($x, $y)
{
    var_dump($x === $y);
    if ($x !== $y) {
        echo "Failed: {$y}\n";
    }
}
/**
 * We are not supporting negative parameters
 * lastday = f_mktime(0, 0, 0, 4, -31, 2000);
 * VS(f_strftime("Last day in Feb 2000 is: %d", lastday),
 *    "Last day in Feb 2000 is: 29");
 */
VS(date("M-d-Y", mktime(0, 0, 0, 12, 32, 1997)), "Jan-01-1998");
VS(date("M-d-Y", mktime(0, 0, 0, 13, 1, 1997)), "Jan-01-1998");
VS(date("M-d-Y", mktime(0, 0, 0, 1, 1, 1998)), "Jan-01-1998");
VS(date("M-d-Y", mktime(0, 0, 0, 1, 1, 98)), "Jan-01-1998");
VS(date("M-d-Y", mktime(0, 0, 0, 1, 1, 1900)), "Jan-01-1900");
VS(date("M-d-Y", mktime(0, 0, 0, 1, 1, 2100)), "Jan-01-2100");
VS(date("M-d-Y", mktime(0, 0, 0, 1, 1, 110)), "Jan-01-0110");
VS(date("h", mktime(9)), "09");
Example #11
0
function test_SpoofChecker_setallowedlocales()
{
    $checker = new SpoofChecker();
    $common = "Rogers";
    $japanese_kanji_hiragana = u('\\u6a4b\\u672c\\u611b\\u307f');
    $korean = u('\\ud55c\\uad6d\\ub9d0');
    $arabic = u('\\u0645\\u0631\\u062d\\u0628\\u064b\\u0627');
    $russian_cyrillic = u('\\u0417\\u0438\\u0301\\u043c\\u043d\\u0438\\u0439 ' . '\\u0432\\u0435\\u0301\\u0447\\u0435\\u0440');
    $snowman = u('\\u2603');
    $checker->setallowedlocales("en_US");
    VS($checker->issuspicious($common), false);
    VS($checker->issuspicious($japanese_kanji_hiragana), true);
    VS($checker->issuspicious($russian_cyrillic), true);
    VS($checker->issuspicious($arabic), true);
    VS($checker->issuspicious($korean), true);
    VS($checker->issuspicious($snowman), false);
    $checker->setallowedlocales("en_US, ja_JP");
    VS($checker->issuspicious($common), false);
    VS($checker->issuspicious($japanese_kanji_hiragana), false);
    VS($checker->issuspicious($russian_cyrillic), true);
    VS($checker->issuspicious($arabic), true);
    VS($checker->issuspicious($korean), true);
    VS($checker->issuspicious($snowman), false);
    $checker->setallowedlocales("en_US, ko_KR");
    VS($checker->issuspicious($common), false);
    VS($checker->issuspicious($japanese_kanji_hiragana), true);
    VS($checker->issuspicious($russian_cyrillic), true);
    VS($checker->issuspicious($arabic), true);
    VS($checker->issuspicious($korean), false);
    VS($checker->issuspicious($snowman), false);
    $checker->setallowedlocales("en_US, ar_AR");
    VS($checker->issuspicious($common), false);
    VS($checker->issuspicious($japanese_kanji_hiragana), true);
    VS($checker->issuspicious($russian_cyrillic), true);
    VS($checker->issuspicious($arabic), false);
    VS($checker->issuspicious($korean), true);
    VS($checker->issuspicious($snowman), false);
    $checker->setallowedlocales("en_US, ru_RU");
    VS($checker->issuspicious($common), false);
    VS($checker->issuspicious($japanese_kanji_hiragana), true);
    VS($checker->issuspicious($russian_cyrillic), false);
    VS($checker->issuspicious($arabic), true);
    VS($checker->issuspicious($korean), true);
    VS($checker->issuspicious($snowman), false);
}
Example #12
0
function VERIFY($x)
{
    VS($x, true);
}
Example #13
0
<?php

function VS($x, $y)
{
    var_dump($x === $y);
    if ($x !== $y) {
        echo "Failed: {$y}\n";
    }
}
$reader = new XMLReader();
$reader->xml("<?xml version=\"1.0\" encoding=\"UTF-8\"?><a y=\"\" z=\"1\"></a>");
$reader->read();
VS($reader->getattribute("x"), null);
VS($reader->getattribute("y"), "");
VS($reader->getattribute("z"), "1");