當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Test類代碼示例

本文整理匯總了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';
 }
開發者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


注:本文中的Test類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。