<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 測試 - [簡介](#introduction) - [測試環境](#environment) - [定義并運行測試](#creating-and-running-tests) <a name="introduction"></a> ## 簡介 Laravel 天生就具有測試的基因。事實上,Laravel 默認就支持用 PHPUnit 來做測試,并為你的應用程序配置好了 `phpunit.xml` 文件。框架還提供了一些便利的輔助函數,讓你可以更直觀的測試應用程序。 在 `tests` 目錄中有提供一個 `ExampleTest.php` 的示例文件。安裝新的 Laravel 應用程序之后,只需在命令行上運行 `phpunit` 就可以進行測試。 <a name="environment"></a> ## 測試環境 在運行測試時,Laravel 會自動將環境變量設置為 `testing`,并將 Session 及緩存以 `array` 的形式存儲,也就是說在測試時不會持久化任何 Session 或緩存數據。 你可以隨意創建其它必要的測試環境配置。`testing` 環境的變量可以在 `phpunit.xml` 文件中被修改,但是在運行測試之前,請確保使用 `config:clear` Artisan 命令來清除配置信息的緩存。 <a name="creating-and-running-tests"></a> ## 定義并運行測試 可以使用 `make:test` Artisan 命令,創建一個測試案例: php artisan make:test UserTest 此命令會放置一個新的 `UserTest` 類至你的 `tests` 目錄。接著就可以像平常使用 PHPUnit 一樣來定義測試方法。要運行測試只需要在終端上運行 `phpunit` 命令即可: <?php use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class UserTest extends TestCase { /** * 基本的測試樣例。 * * @return void */ public function testExample() { $this->assertTrue(true); } } > {note} 如果要在你的類自定義自己的 `setUp` 方法,請確保調用了 `parent::setUp`。 ## 譯者署名 | 用戶名 | 頭像 | 職能 | 簽名 | |---|---|---|---| | [@JobsLong](https://phphub.org/users/56) | <img class="avatar-66 rm-style" src="http://i4.buimg.com/567571/a3dc28a55fdb2b7a.png"> | 翻譯 | 個人主頁:[http://jobslong.com](http://jobslong.com) |
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看