本文整理汇总了PHP中Test类的典型用法代码示例。如果您正苦于以下问题:PHP Test类的具体用法?PHP Test怎么用?PHP Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Test类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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';
}
开发者ID:htom78,项目名称:peersay,代码行数:25,代码来源:users.php
示例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));
}
开发者ID:kasonyang,项目名称:hitar,代码行数:35,代码来源:TableTest.php
示例3: getTest
function getTest()
{
$t = new Test();
foreach ($t->get_by_id(2)->topic->get() as $o) {
echo $o->to_json();
}
}
开发者ID:htom78,项目名称:peersay,代码行数:7,代码来源:ormTest.php
示例4: testModelShort
public function testModelShort()
{
$_REQUEST['__url'] = 'home';
$this->ob();
$test = new Test();
$this->assertTrue($test->test());
}
开发者ID:arzynik,项目名称:cana,代码行数:7,代码来源:ModelTest.php
示例5: foo
function foo()
{
$obj = new Test();
$obj->f2();
$obj->privateData = 2;
$obj = new Base();
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:733.php
示例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);
}
开发者ID:edwardstock,项目名称:php-curl-class,代码行数:7,代码来源:helper.inc.php
示例7: doTest
function doTest()
{
$obj = new Test();
$obj->readConst();
unset($obj);
var_dump(Test::TEST);
}
开发者ID:gleamingthecube,项目名称:php,代码行数:7,代码来源:Zend_tests_class_constant_to_reference_cached.php
示例8: testTest
public function testTest()
{
$test = new Test();
// $test->assertEquals(1, 0, '失敗を確認');
$dat = $test->loadDat('test.dat');
$test->assertEquals('test', $dat);
}
开发者ID:gammodoking,项目名称:kindle.server,代码行数:7,代码来源:TestTest.php
示例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 "";
}
开发者ID:nProfessor,项目名称:Mytb,代码行数:14,代码来源:test.php
示例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());
}
开发者ID:cs-team,项目名称:news,代码行数:8,代码来源:JSONHttpErrorTest.php
示例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();
}
开发者ID:jestintab,项目名称:zendphp,代码行数:9,代码来源:class-visible-3.php
示例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));
}
开发者ID:subhra-sekhar,项目名称:yiitest,代码行数:9,代码来源:TestController.php
示例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);
});
}
}
}
开发者ID:phemmyster,项目名称:phproject,代码行数:60,代码来源:base.php
示例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');
}
开发者ID:TBoonX,项目名称:SlideWiki,代码行数:10,代码来源:StaticController.php
示例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);
}
开发者ID:andals,项目名称:vine,代码行数:11,代码来源:EntityTest.php
示例16: lists
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();
}
开发者ID:htom78,项目名称:peersay,代码行数:12,代码来源:topics.php
示例17: run
/**
* 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;
}
开发者ID:godardth,项目名称:yii2-webception,代码行数:19,代码来源:TestController.php
示例18: actionTest
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();
}
开发者ID:bgshechka,项目名称:pos-shop,代码行数:15,代码来源:MainController.php
示例19: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Test::create(['name' => $faker->word, 'category_id' => $faker->randomNumber(1, 5)]);
}
}
开发者ID:SenhorBardell,项目名称:wordotheday,代码行数:7,代码来源:TestsTableSeeder.php
示例20: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Test::create([]);
}
}
开发者ID:jarciga,项目名称:Euler2015Alpha,代码行数:7,代码来源:TestsTableSeeder.php
注:本文中的Test类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论