"<h1>japanese test</h1>
<p>これからは日本語です。</p>
<p>日本語はだいじょうぶ?</p>";
$input['second'] = 
  'Test <a href="#" onclick="alert(document.cookies)">show me</a><p>a paragraph';
// $input[] = implode('', file("./testHTML.html"));
$input[] = "Title with <b>bold long test that should be truncated. Is it? HELLO? How long does this need to be? HUH?</b>";
$input[] = "Long JP title: ぶいぶいぶいぶいぶいぶいぶいぶい ぶいいいいいいいいいいいいい いいいいいいいいいいいいいぶいいいいいいいいいいい ぼぼぼぼぼぼぼぼぼぼぼぼぼぼぼぼぼぼぼ ととととととととととととっとととととととととととっととと";
*/
$input[] = "<H1>Hallo <p>One test</p> This is <b>a test <img src=blah.gif name=test /><br>\n<div>And another</div>\n<a href='test.html'>A normal Link</a>\n<a href='javascript:alert(date())'>An illegal Link</a>\n";
$input[] = "<b>ThisIsOneExtremlyLongStringThatNeedsToBeBrokenIntoSmallerChunks";
$sDom = new InputSanitizer(array('h1', 'p', 'b', 'a'), array('href'));
print "\nStripping all HTML:\n";
run_tests();
print "\nPassing through HTML\n";
$sDom->htmlAllowedEverywhere = TRUE;
$sDom->wbr = 15;
run_tests();
function run_tests()
{
    global $sDom, $input;
    $rea = $sDom->process($input);
    foreach ($rea as $key => $value) {
        print "[{$key}]: " . $value . "\n";
    }
    print "\nTruncating:\n";
    $rea = $sDom->process($input, 20);
    foreach ($rea as $key => $value) {
        print "[{$key}]: " . strlen($value) . "\n" . $value . "\n";
    }
}
Ejemplo n.º 2
0
function result($exerid, $filename, $code, $output)
{
    if ($exerid == 1) {
        $answer = get_answer($exerid);
        if (strcmp($output, $answer) == 0) {
            return true;
        }
    } elseif ($exerid == 2) {
        $check = check_code_2($code);
        $answer = get_answer($exerid);
        $answer = trim($answer);
        if ($check == 3 && strpos($answer, $output) >= 0) {
            return true;
        }
    } elseif ($exerid == 3 || $exerid == 4 || $exerid == 5 || $exerid == 6) {
        $cases = get_testcases($exerid);
        if (run_tests($filename, $cases)) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 3
0
/* Validate the class is known */
if (!in_array($str_class, $arr_valid_classes)) {
    echo "Error:  Valid test classes are Redis, RedisArray, and RedisCluster!\n";
    exit(1);
}
/* Toggle colorization in our TestSuite class */
TestSuite::flagColorization($boo_colorize);
/* Let the user know this can take a bit of time */
echo "Note: these tests might take up to a minute. Don't worry :-)\n";
/* Depending on the classes being tested, run our tests on it */
echo "Testing class ";
if ($str_class == 'redis') {
    echo TestSuite::make_bold("Redis") . "\n";
    exit(TestSuite::run("Redis_Test", $str_filter));
} else {
    if ($str_class == 'redisarray') {
        echo TestSuite::make_bold("RedisArray") . "\n";
        global $useIndex;
        foreach (array(true, false) as $useIndex) {
            echo "\n" . ($useIndex ? "WITH" : "WITHOUT") . " per-node index:\n";
            run_tests('Redis_Array_Test', $str_filter);
            run_tests('Redis_Rehashing_Test', $str_filter);
            run_tests('Redis_Auto_Rehashing_Test', $str_filter);
            run_tests('Redis_Multi_Exec_Test', $str_filter);
            run_tests('Redis_Distributor_Test', $str_filter);
        }
    } else {
        echo TestSuite::make_bold("RedisCluster") . "\n";
        exit(TestSuite::run("Redis_Cluster_Test", $str_filter));
    }
}
Ejemplo n.º 4
0
<?php

require_once __DIR__ . '/ini_get_all_impl.inc';
run_tests("hhvm.server.graceful_shutdown_wait", null);
Ejemplo n.º 5
0
        $usServer = $this->ra->_target('{us}test');
        $deServer = $this->ra->_target('{de}test');
        $defaultServer = $this->ra->_target('unknown');
        $nodes = $this->ra->_hosts();
        $this->assertTrue($ukServer === $nodes[0]);
        $this->assertTrue($usServer === $nodes[1]);
        $this->assertTrue($deServer === $nodes[2]);
        $this->assertTrue($defaultServer === $nodes[2]);
    }
}
function run_tests($className, $str_limit)
{
    // reset rings
    global $newRing, $oldRing, $serverList;
    $newRing = array('localhost:6379', 'localhost:6380', 'localhost:6381');
    $oldRing = array();
    $serverList = array('localhost:6379', 'localhost:6380', 'localhost:6381', 'localhost:6382');
    // run
    TestSuite::run($className, $str_limit);
}
define('REDIS_ARRAY_DATA_SIZE', 1000);
global $useIndex;
foreach (array(true, false) as $useIndex) {
    $str_limit = isset($argv[1]) ? $argv[1] : NULL;
    echo "\n" . ($useIndex ? "WITH" : "WITHOUT") . " per-node index:\n";
    //run_tests('Redis_Array_Test', $str_limit);
    run_tests('Redis_Rehashing_Test', $str_limit);
    //run_tests('Redis_Auto_Rehashing_Test', $str_limit);
    //run_tests('Redis_Multi_Exec_Test', $str_limit);
    //run_tests('Redis_Distributor_Test', $str_limit);
}
                $dbman->drop_table($table);
            }
        }
        $issetup = 0;
        echo $OUTPUT->notification('Test tables dropped.', 'notifysuccess');
        break;
    case 'test':
        require_sesskey();
        if ($issetup != count($requiredtables)) {
            echo $OUTPUT->notification('Something is wrong, please delete the test tables and try again.');
        } else {
            $contexts = $DB->get_records('context');
            $numcalls = 1000;
            $basetime = run_tests('noop', $contexts, $numcalls, 0);
            run_tests('simple_get_record_by_id', $contexts, $numcalls, $basetime);
            run_tests('filter_get_active_in_context', $contexts, $numcalls, $basetime);
        }
        break;
}
if ($issetup == count($requiredtables)) {
    echo '<p>Total of ' . $DB->count_records('context') . ' contexts, ' . $DB->count_records('filter_active') . ' filter_active and ' . $DB->count_records('filter_config') . ' filter_config rows in the database.</p>';
}
$DB = $realdb;
echo $OUTPUT->container_start();
$aurl = new moodle_url($baseurl, array('action' => 'setup', 'sesskey' => sesskey()));
echo $OUTPUT->single_button($aurl, 'Set up test tables', 'get', array('disabled' => $issetup > 0));
$aurl = new moodle_url($baseurl, array('action' => 'teardown', 'sesskey' => sesskey()));
echo $OUTPUT->single_button($aurl, 'Drop test tables', 'get', array('disabled' => $issetup == 0));
$aurl = new moodle_url($baseurl, array('action' => 'test', 'sesskey' => sesskey()));
echo $OUTPUT->single_button($aurl, 'Run tests', 'get', array('disabled' => $issetup != count($requiredtables)));
echo $OUTPUT->container_end();
Ejemplo n.º 7
0
        // Get after exec, 'test1':
        $this->assertTrue($this->ra->get($key) === 'test1');
        $this->ra->watch($key);
        // After second watch, still test1.
        $this->assertTrue($this->ra->get($key) === 'test1');
        $ret = $this->ra->multi($this->ra->_target($key))->set($key, 'test2')->discard();
        // Ret after discard: NULL";
        $this->assertTrue($ret === NULL);
        // Get after discard, unchanged:
        $this->assertTrue($this->ra->get($key) === 'test1');
    }
}
function run_tests($className)
{
    // reset rings
    global $newRing, $oldRing, $serverList;
    $newRing = array('localhost:6379', 'localhost:6380', 'localhost:6381');
    $oldRing = array();
    $serverList = array('localhost:6379', 'localhost:6380', 'localhost:6381', 'localhost:6382');
    // run
    TestSuite::run($className);
}
define('REDIS_ARRAY_DATA_SIZE', 1000);
global $useIndex;
foreach (array(true, false) as $useIndex) {
    echo "\n" . ($useIndex ? "WITH" : "WITHOUT") . " per-node index:\n";
    run_tests('Redis_Array_Test');
    run_tests('Redis_Rehashing_Test');
    run_tests('Redis_Auto_Rehashing_Test');
    run_tests('Redis_Multi_Exec_Test');
}
Ejemplo n.º 8
0
}
/*
echo "tests for moodle 2.6\n";
$moodle26 = run_tests(get_commands_list("26"));
foreach($moodle26 as $k=>$v) {
    $results['26'][$k] = $v;
}

echo "tests for moodle 2.5\n";
$moodle25 = run_tests(get_commands_list("25"));
foreach($moodle25 as $k=>$v) {
    $results['25'][$k] = $v;
}
*/
echo "tests for moodle 2.7\n";
$moodle27 = run_tests(get_commands_list("27"));
foreach ($moodle27 as $k => $v) {
    $results['27'][$k] = $v;
}
sort($all_commands);
foreach ($all_commands as $command) {
    $out .= "\t<tr>\n\t\t<td><a href=\"/commands/#{$command} \">{$command}</td>\n";
    foreach ($support_versions as $moodle) {
        //if($results[$moodle][])
        // $out .=  '<td>' .$results[$moodle][$command] .'</td>';
        $result = $results[$moodle][$command];
        if ($result == "pass") {
            $out .= "\t\t<td><i class=\"fa fa-check\"></i></td>\n";
        } else {
            if ($result == "fail") {
                $out .= "\t\t<td><i class=\"fa fa-times\"></i></td>\n";
Ejemplo n.º 9
0
<?php

require_once __DIR__ . '/ini_get_all_impl.inc';
run_tests("hhvm.jit_profile_requests", "hhvm.server.force_server_name_to_header");
Ejemplo n.º 10
0
                mkdir("{$stage_path}/{$destination}", 0777, true);
            }
            copy($file, $stage_path . '/' . $destination . '/' . basename($file));
        }
    }
    if ($recurse) {
        foreach (glob(dirname($search) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
            if ($exclude && exclude($exclude, $dir)) {
                continue;
            }
            package(dirname($pattern) . '/' . basename($dir) . '/' . basename($pattern), $destination . '/' . basename($dir), $recurse - 1, $exclude);
        }
    }
}
# Run tests before continuing
if (run_tests($root) > 0) {
    die("Regression tests failed. Cowardly refusing to package\n");
}
# Create the stage folder for the install files
if (!is_dir($stage_path)) {
    mkdir($stage_path);
} else {
    $dirs = array();
    foreach (glob_recursive($stage_path . '/*') as $file) {
        if (is_dir($file)) {
            $dirs[] = $file;
        } else {
            unlink($file);
        }
    }
    sort($dirs);
Ejemplo n.º 11
0
<?php

require 'insightly.php';
function run_tests($apikey)
{
    $insightly = new Insightly($apikey);
    $insightly->test();
}
run_tests($argv[1]);
Ejemplo n.º 12
0
<?php

require_once __DIR__ . '/ini_get_all_impl.inc';
run_tests(null, "hhvm.jit_profile_record");
Ejemplo n.º 13
0
        $ukServer = $this->ra->_target('{uk}test');
        $usServer = $this->ra->_target('{us}test');
        $deServer = $this->ra->_target('{de}test');
        $defaultServer = $this->ra->_target('unknown');
        $nodes = $this->ra->_hosts();
        $this->assertTrue($ukServer === $nodes[0]);
        $this->assertTrue($usServer === $nodes[1]);
        $this->assertTrue($deServer === $nodes[2]);
        $this->assertTrue($defaultServer === $nodes[2]);
    }
}
function run_tests($className)
{
    // reset rings
    global $newRing, $oldRing, $serverList;
    $newRing = array('localhost:6379', 'localhost:6380', 'localhost:6381');
    $oldRing = array();
    $serverList = array('localhost:6379', 'localhost:6380', 'localhost:6381', 'localhost:6382');
    // run
    TestSuite::run($className);
}
define('REDIS_ARRAY_DATA_SIZE', 1000);
global $useIndex;
foreach (array(true, false) as $useIndex) {
    echo "\n" . ($useIndex ? "WITH" : "WITHOUT") . " per-node index:\n";
    run_tests('Redis_Array_Test');
    run_tests('Redis_Rehashing_Test');
    run_tests('Redis_Auto_Rehashing_Test');
    run_tests('Redis_Multi_Exec_Test');
    run_tests('Redis_Distributor_Test');
}