Example #1
0
<?php

error_reporting(E_ERROR | E_WARNING);
try {
    require 'util.php';
    $type = $_GET['type'];
    $cate = get_par("cate");
    $list = get_test_cate_list();
    if ($type == 'addTest') {
        $text = get_par('text');
        $ld = get_par('ld');
        $rd = get_par('rd');
        $tpl = get_par('tpl');
        $class = $list[$cate];
        $add = get_par('add');
        $clsOptions = get_cls_options($cate);
        $properties = array("ld" => $ld, "rd" => $rd, "tpl" => $tpl);
        $options = array();
        if ($clsOptions['properties']) {
            foreach ($clsOptions['properties'] as $name => $value) {
                if ($value === true || $value === false) {
                    $properties[$name] = !!get_par($name);
                } else {
                    $properties[$name] = get_par($name);
                }
            }
        }
        if ($clsOptions['options']) {
            foreach ($clsOptions['options'] as $name => $value) {
                if ($value === true || $value === false) {
                    $options[$name] = !!get_par($name);
Example #2
0
function retest_case($cate, $md5)
{
    $list = get_test_cate_list();
    $class = $list[$cate];
    $file = dirname(__FILE__) . "/Case/" . $cate . ".json";
    if (file_exists($file)) {
        $content = file_get_contents($file);
        $json = json_decode($content, true);
        $item = $json[$md5];
        if ($item) {
            require_once dirname(dirname(__FILE__)) . "/src/Fl.class.php";
            Fl::loadClass($class);
            $instance = new $class($item['text']);
            $properties = $item['properties'];
            $options = $item['options'];
            if (!$options) {
                $options = array();
            }
            if ($properties) {
                foreach ($properties as $name => $value) {
                    $instance->{$name} = $value;
                }
            }
            foreach (array('tpl', 'ld', 'rd') as $name) {
                if ($item[$name]) {
                    $instance->{$name} = $item[$name];
                }
            }
            try {
                $output = $instance->run($options);
            } catch (Fl_Exception $e) {
                $output = $e->message;
            }
            return $output;
        }
    }
    return '';
}