本文整理汇总了PHP中Test类的典型用法代码示例。如果您正苦于以下问题:PHP Test类的具体用法?PHP Test怎么用?PHP Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addBatch
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';
}
示例2: testTable
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));
}
示例3: getTest
function getTest()
{
$t = new Test();
foreach ($t->get_by_id(2)->topic->get() as $o) {
echo $o->to_json();
}
}
示例4: testModelShort
public function testModelShort()
{
$_REQUEST['__url'] = 'home';
$this->ob();
$test = new Test();
$this->assertTrue($test->test());
}
示例5: foo
function foo()
{
$obj = new Test();
$obj->f2();
$obj->privateData = 2;
$obj = new Base();
}
示例6: requestMethod
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);
}
示例7: doTest
function doTest()
{
$obj = new Test();
$obj->readConst();
unset($obj);
var_dump(Test::TEST);
}
示例8: testTest
public function testTest()
{
$test = new Test();
// $test->assertEquals(1, 0, '失敗を確認');
$dat = $test->loadDat('test.dat');
$test->assertEquals('test', $dat);
}
示例9: test
/**
*
* 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 "";
}
示例10: testError
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());
}
示例11: baz
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();
}
示例12: actionAdmin
public function actionAdmin()
{
$model = new Test('search');
$model->unsetAttributes();
if (isset($_GET['Test'])) {
$model->setAttributes($_GET['Test']);
}
$this->render('admin', array('model' => $model));
}
示例13: showResults
/**
* 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);
});
}
}
}
示例14: test
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');
}
示例15: testToItem
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);
}