Inheritance: extends Controller
Ejemplo n.º 1
0
 function addBatch()
 {
     $users = str_getcsv($_POST['users']);
     $saved = TRUE;
     $testid = $this->session->userdata('testid');
     $test = new Test();
     $test->get_by_id($testid);
     $this->load->helper("pinyin");
     foreach ($users as $user) {
         $u = new User();
         $u->uStudId = $user[0];
         $u->uName = str_replace(' ', '', $user[1]);
         //$u->uPassword = $user[0];//密码等于用户的学号
         $pinyin = get_pinyin($u->uName);
         $u->uPassword = str_replace('_', '', $pinyin);
         //用拼音作为密码
         $u->uType = 'student';
         if (!$u->save()) {
             $saved = FALSE;
             break;
         }
         $test->save($u);
     }
     return 'saved';
 }
Ejemplo n.º 2
0
 function testTable()
 {
     $tb = Test::table();
     $new_data = ['nickname' => 'z3'];
     $tb->insert($new_data);
     $this->assertEquals(1, $tb->count());
     $this->assertEquals([['nickname' => 'z3']], $tb->selectData());
     $update = $tb->update(['nickname' => 'w5']);
     $this->assertEquals(1, $update);
     $this->assertEquals([['nickname' => 'w5']], $tb->selectData());
     $tb_new = clone $tb;
     $tb_new->where('nickname=%s', 'w5');
     //$this->assertEquals('SELEC', $tb->buildSelect());
     $this->assertEquals([['nickname' => 'w5']], $tb_new->selectData());
     $tb_new->clearWhere();
     $tb_new->andWhere(['nickname' => 'w5']);
     //$this->assertEquals('SELEC', $tb->buildSelect());
     $this->assertEquals([['nickname' => 'w5']], $tb_new->selectData());
     $this->assertEquals(1, $tb_new->update(['nickname' => 'z3']));
     $this->assertEquals([['nickname' => 'z3']], $tb->selectData());
     $obj_list = $tb->select();
     $obj = $obj_list[0];
     /* @var $obj Test */
     $this->assertEquals('z3', $obj->nickname);
     $tb->delete();
     $test = new Test();
     $test->nickname = 'hehe';
     $this->assertEquals(TRUE, $test->save());
     $this->assertEquals('hehe', Test::table()->selectData()[0]['nickname']);
     $test->delete();
     $this->assertEquals([], $tb->selectData());
     $this->assertEquals('SELECT * FROM test Test', $tb->buildSelect());
     $this->assertEquals('SELECT * FROM test Test LIMIT 10', $tb->buildSelect(10));
     $this->assertEquals('SELECT * FROM test Test LIMIT 10 OFFSET 10', $tb->buildSelect(10, 10));
 }
Ejemplo n.º 3
0
 function getTest()
 {
     $t = new Test();
     foreach ($t->get_by_id(2)->topic->get() as $o) {
         echo $o->to_json();
     }
 }
Ejemplo n.º 4
0
 public function testModelShort()
 {
     $_REQUEST['__url'] = 'home';
     $this->ob();
     $test = new Test();
     $this->assertTrue($test->test());
 }
Ejemplo n.º 5
0
function foo()
{
    $obj = new Test();
    $obj->f2();
    $obj->privateData = 2;
    $obj = new Base();
}
Ejemplo n.º 6
0
 public static function requestMethod(Test $instance, $before, $after)
 {
     $instance->server('request_method', $before);
     PHPUnit_Framework_Assert::assertTrue($instance->curl->response === $before);
     $instance->server('request_method', $after);
     PHPUnit_Framework_Assert::assertTrue($instance->curl->response === $after);
 }
function doTest()
{
    $obj = new Test();
    $obj->readConst();
    unset($obj);
    var_dump(Test::TEST);
}
Ejemplo n.º 8
0
 public function testTest()
 {
     $test = new Test();
     //		$test->assertEquals(1, 0, '失敗を確認');
     $dat = $test->loadDat('test.dat');
     $test->assertEquals('test', $dat);
 }
Ejemplo n.º 9
0
/**
 *
 * User: Tabota Oleg (sForge.ru)
 * Date: 18.11.12 14:17
 * File name: test.php
 */
function test()
{
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
    CModule::IncludeModule("iblock");
    $kupon = new Test();
    $kupon->setStoks();
    return "";
}
Ejemplo n.º 10
0
 public function testError()
 {
     $ex = new \Exception('hi');
     $test = new Test();
     $result = $test->error($ex, 3);
     $this->assertEquals(['message' => 'hi'], $result->getData());
     $this->assertEquals(3, $result->getStatus());
 }
Ejemplo n.º 11
0
 public function baz(Test $other)
 {
     echo $other->foo . "\n";
     // We can change the private property:
     $other->foo = 'hello';
     var_dump($other->foo);
     // We can also call the private method:
     $other->bar();
 }
Ejemplo n.º 12
0
 public function actionAdmin()
 {
     $model = new Test('search');
     $model->unsetAttributes();
     if (isset($_GET['Test'])) {
         $model->setAttributes($_GET['Test']);
     }
     $this->render('admin', array('model' => $model));
 }
Ejemplo n.º 13
0
/**
 * Output test results formatted for CLI or web
 * @param   Test $test
 */
function showResults(Test $test)
{
    $err = false;
    $f3 = Base::instance();
    if (PHP_SAPI == 'cli') {
        // Command line
        foreach ($test->results() as $result) {
            if ($result['status']) {
                if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                    echo "PASS";
                } else {
                    echo "", 'PASS', "";
                }
                echo ": ", $result['text'], "\n";
            } else {
                if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                    echo "FAIL";
                } else {
                    echo "", 'FAIL', "";
                }
                echo ": ", $result['text'], " - ", $result['source'], "\n";
                $err = true;
            }
        }
        if ($err) {
            echo "One or more tests failed. Last error:\n";
            echo $f3->get("ERROR.text"), " at " . $f3->get("ERROR.trace.0.file"), ":", $f3->get("ERROR.trace.0.line"), "\n";
            register_shutdown_function(function () {
                exit(2);
            });
        }
    } else {
        // Web page
        foreach ($test->results() as $result) {
            if ($result['status']) {
                echo '<code style="color: darkgreen;">PASS</code>: ', $result['text'], "<br>\n";
            } else {
                echo '<code style="color: red;">FAIL</code>: ', $result['text'], " - ", $result["source"], "<br>\n";
                $err = true;
            }
        }
        if ($err) {
            echo "<p>One or more tests failed. Last error:<br>\n";
            echo $f3->get("ERROR.text"), " at " . $f3->get("ERROR.trace.0.file"), ":", $f3->get("ERROR.trace.0.line"), "</p>\n";
            if ($f3->get("DEBUG") >= 3) {
                foreach ($f3->get("ERROR.trace") as $line) {
                    echo "<b>", $line["file"], "</b><br>";
                    echo $line["line"], ": ", $line["class"], $line["type"], $line["function"], "(", implode(", ", $line["args"]), ")<br>";
                }
            }
            register_shutdown_function(function () {
                exit(2);
            });
        }
    }
}
Ejemplo n.º 14
0
 function test()
 {
     $item_id = $_GET['id'];
     $test = new Test();
     $test->createFromItem($item_id);
     $test->questions = $test->getAllQuestions();
     $this->set('test', $test);
     $this->set('page_title', 'SlideWiki - List of questions for ' . $test->title);
     $this->set('page_keywords', 'SlideWiki, questions');
 }
Ejemplo n.º 15
0
 public function testToItem()
 {
     /*{{{*/
     $item = array('id' => 1001, 'name' => 'vine', 'link' => 'http://vine.com');
     $test = new Test();
     $test->setColumnsValues($item);
     $item = $test->toItem();
     $this->assertEquals($item['id'], 1001);
     $this->assertEquals($item['name'], 'vine');
     $this->assertEquals(isset($item['link']), false);
 }
Ejemplo n.º 16
0
 function lists($id = 0)
 {
     if (!$id) {
         $id = $this->session->userdata("testid");
     }
     $test = new Test();
     $test->get_by_id((int) $id);
     $t = $test->topic->get();
     $this->session->set_userdata(array('testid' => $id));
     //datamapper的json扩展真是强大
     echo $t->all_to_json();
 }
Ejemplo n.º 17
0
 private function query()
 {
     foreach ($this->test->variantKeys() as $variantKey) {
         $numP = $this->test->countParticipants($variantKey);
         $this->totalParticipants += $numP;
         $this->variantTotals[$variantKey] = $numP;
         foreach ($this->test->eventKeys() as $eventKey) {
             $numEvents = $this->test->countEvents($variantKey, $eventKey);
             $this->eventTotals[$variantKey][$eventKey] = $numEvents;
             $this->events[$eventKey] = $eventKey;
         }
     }
 }
Ejemplo n.º 18
0
 /**
  * Given a test, run the Codeception test.
  *
  * @param  Test $test Current test to Run.
  * @return Test $test Updated test with log and result.
  */
 public function run($site, $test)
 {
     // Get the full command path to run the test.
     $command = TerminalController::getCommandPath($site, $test->type, $test->filename);
     // Attempt to set the correct writes to Codeceptions Log path.
     //@chmod($this->getLogPath(), 0777);
     // Run the helper function (as it's not specific to Codeception)
     // which returns the result of running the terminal command into an array.
     $output = TerminalController::run_terminal_command($command);
     // Add the log to the test which also checks to see if there was a pass/fail.
     $test->setLog($output);
     return $test;
 }
Ejemplo n.º 19
0
 public function actionTest()
 {
     // $tests = Test::model()->findAll();
     // $names="";
     // foreach ($tests as $test)
     //    {
     //   	  $names=$names.$test->name."</br>";
     //    }
     //        $this->render("test",array("names"=>$names));
     //
     $new = new Test();
     $new->name = "imya";
     $new->text = "rrrr";
     $new->save();
 }
Ejemplo n.º 20
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Test::create(['name' => $faker->word, 'category_id' => $faker->randomNumber(1, 5)]);
     }
 }
Ejemplo n.º 21
0
 public function hello2()
 {
     $this->hello();
     // Check if $this mean also inheritance methods
     parent::hello();
     // Check if it work in spite of it is not static method
 }
Ejemplo n.º 22
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Test::create([]);
     }
 }
Ejemplo n.º 23
0
 public function save()
 {
     if (UserSession::getInstance()->getAccessLevel() < 3) {
         die("<h1>Forbidden resource for you.</h1>");
     }
     $model = new Test();
     $model->setFields($this->params);
     $modelId = $model->get("tst_id");
     if (!isset($modelId)) {
         $status = $this->saveNew($model);
         return $status;
     } else {
         $status = $this->update($model);
         return $status;
     }
 }
Ejemplo n.º 24
0
function get_test_record($specimen_id, $test_type_id)
{
    $query_string = "SELECT * FROM test " . "WHERE specimen_id={$specimen_id} AND test_type_id={$test_type_id} ";
    $record = query_associative_one($query_string);
    $test_entry = Test::getObject($record);
    return $test_entry;
}
Ejemplo n.º 25
0
 private function addAssertionToCurrentTest(Assertion $assertion)
 {
     if (empty($this->current_test)) {
         $this->start_new_test($assertion->getName());
     }
     $this->current_test->addAssertion($assertion);
 }
Ejemplo n.º 26
0
 public static function get_instance()
 {
     if (self::$prod_list == NULL) {
         self::$prod_list = new Test();
     }
     return self::$prod_list;
 }
Ejemplo n.º 27
0
 public function _get()
 {
     $test = new Test('test 1');
     $test->add_var()->add_var();
     $test->set('var3', 200);
     $var_list = $test->get_var_data();
     $page = new View('main', 'layouts', VPATH);
     $sidebar = new View('sidebar', 'layouts', VPATH);
     $content = new View('content', 'loading', VPATH);
     $header = new View('header', 'loading', VPATH);
     $content->merge($test->get_var_data());
     $page->set("sidebar", $sidebar->package());
     $page->set("header", $header->package());
     $page->set("content", $content->package());
     $page->render();
 }
Ejemplo n.º 28
0
function get_records_to_print($lab_config, $patient_id)
{
    global $date_from, $date_to;
    $retval = array();
    if (isset($_REQUEST['ip']) && $_REQUEST['ip'] == 0) {
        # Do not include pending tests
        $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.result <> '' " . "AND t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} ";
        if (isset($_REQUEST['yf'])) {
            $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') ";
        }
        $query_string .= "ORDER BY sp.date_collected DESC";
    } else {
        # Include pending tests
        $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} ";
        if (isset($_REQUEST['yf'])) {
            $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') ";
        }
        $query_string .= "ORDER BY sp.date_collected DESC";
    }
    $resultset = query_associative_all($query_string, $row_count);
    if (count($resultset) == 0 || $resultset == null) {
        return $retval;
    }
    foreach ($resultset as $record) {
        $test = Test::getObject($record);
        $hide_patient_name = TestType::toHidePatientName($test->testTypeId);
        if ($hide_patient_name == 1) {
            $hidePatientName = 1;
        }
        $specimen = get_specimen_by_id($test->specimenId);
        $retval[] = array($test, $specimen, $hide_patient_name);
    }
    return $retval;
}
Ejemplo n.º 29
0
 public function index()
 {
     Log::debug('aaa');
     //Test::get();
     Test::query()->select('*')->get();
     return View::make('pages.test.index');
 }
Ejemplo n.º 30
0
 function delete_delete($data)
 {
     $sql = Test::find($data->id);
     $retorno = $sql->to_json();
     $sql->delete();
     return '{"result": [' . $retorno . ']}';
 }