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'; }
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)); }
function getTest() { $t = new Test(); foreach ($t->get_by_id(2)->topic->get() as $o) { echo $o->to_json(); } }
public function testModelShort() { $_REQUEST['__url'] = 'home'; $this->ob(); $test = new Test(); $this->assertTrue($test->test()); }
function foo() { $obj = new Test(); $obj->f2(); $obj->privateData = 2; $obj = new Base(); }
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); }
public function testTest() { $test = new Test(); // $test->assertEquals(1, 0, '失敗を確認'); $dat = $test->loadDat('test.dat'); $test->assertEquals('test', $dat); }
/** * * 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 ""; }
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()); }
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(); }
public function actionAdmin() { $model = new Test('search'); $model->unsetAttributes(); if (isset($_GET['Test'])) { $model->setAttributes($_GET['Test']); } $this->render('admin', array('model' => $model)); }
/** * 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 "[0;32m", 'PASS', "[0m"; } echo ": ", $result['text'], "\n"; } else { if (defined('PHP_WINDOWS_VERSION_MAJOR')) { echo "FAIL"; } else { echo "[0;31m", 'FAIL', "[0m"; } 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); }); } } }
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'); }
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); }
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(); }
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; } } }
/** * 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; }
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(); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Test::create(['name' => $faker->word, 'category_id' => $faker->randomNumber(1, 5)]); } }
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 }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Test::create([]); } }
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; } }
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; }
private function addAssertionToCurrentTest(Assertion $assertion) { if (empty($this->current_test)) { $this->start_new_test($assertion->getName()); } $this->current_test->addAssertion($assertion); }
public static function get_instance() { if (self::$prod_list == NULL) { self::$prod_list = new Test(); } return self::$prod_list; }
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(); }
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; }
public function index() { Log::debug('aaa'); //Test::get(); Test::query()->select('*')->get(); return View::make('pages.test.index'); }
function delete_delete($data) { $sql = Test::find($data->id); $retorno = $sql->to_json(); $sql->delete(); return '{"result": [' . $retorno . ']}'; }