Learning Laravel174 Chapter 60: Testing 176 Examples 176 Introduction 176 Test without middleware and with a fresh database 176 Database transactions for mutliple database connection 177 Testing setup, using in memory rollback all the change during the tests. For testing multiple database connections, you need to set $connectionsToTransact properties use Illuminate\Foundation\Testing\DatabaseMigrations; class ExampleTest 1) BASIC SIMPLE WAY Database-driven applications often need data pre-seeded into the system for testing and demo purposes. To make such data, first create the seeder class ProductTableSeeder use Faker\Factory0 码力 | 216 页 | 1.58 MB | 1 年前3
Laravel 5.0 Documentation
Templates i. Blade Templating ii. Other Blade Control Structures iii. Extending Blade xxi. Unit Testing i. Introduction ii. Defining & Running Tests iii. Test Environment iv. Calling Routes From Tests a RedirectResponse instance. The simplest method is to use the redirect helper method. When testing, it is not common to mock the creation of a redirect response, so using the helper method is almost implementation. We are also able to easily "mock", or create a dummy implementation of the mailer when testing our application. A deep understanding of the Laravel service container is essential to building0 码力 | 242 页 | 1.44 MB | 1 年前3
Laravel 5.6 中文文档配置值以占位符的方式放置 在 .env.example 文件中,这样其他开发者就会很清楚运行你的应用需要配置哪些环境变量。 还可以创建一个 .env.testing 文件,该文件会在运行 PHPUnit 测试或执行带有 --env=testing 选项的 Artisan 命令时覆盖从 .env 文件读取的 值。 注:.env 文件中的所有变量都可以被外部环境变量覆盖,例如服务器级别或系统级别的环境变量。 App\Podcast; use Tests\TestCase; use Facades\App\Contracts\Publisher; use Illuminate\Foundation\Testing\RefreshDatabase; class PodcastTest extends TestCase { use RefreshDatabase; /** the local environment... @elseenv('testing') // The application is in the testing environment... @else // The application is not in the local or testing environment... @endenv 视图 创建视图0 码力 | 377 页 | 14.56 MB | 1 年前3
Laravel 3.2 Documentation................................................................................ 20 CLI Route Testing ................................................................................................ ..................................................................................... 73 Unit Testing ................................................................................................ update your local copy from the repository and run migrations. Now you're up to date, too! Unit-Testing is an important part of Laravel. Laravel itself sports hundreds of tests to help ensure that new0 码力 | 139 页 | 1.13 MB | 1 年前3
Laravel 6.0 中文文档占位符的方式放 置在 .env.example 文件中,这样其他开发者就会很清楚运行你的应 用需要配置哪些环境变量。 还可以创建一个 .env.testing 文件,该文件会在运行 PHPUnit 测 试或执行带有 --env=testing 选项的 Artisan 命令时覆盖 从 .env 文件读取的值。 本文档由学院君提供 学院君致力于提供优质 Laravel 中文学习资源:https://xueyuanjun App\Podcast; use Tests\TestCase; use Facades\App\Contracts\Publisher; use Illuminate\Foundation\Testing\RefreshDatabase; class PodcastTest extends TestCase { use RefreshDatabase; /** * A test example in the local environment... @elseenv('testing') // The application is in the testing environmen t... @else // The application is not in the local or testing e nvironment... @endenv 相关文章推荐: Blade0 码力 | 1442 页 | 14.66 MB | 1 年前3
Laravel 5.2 中文文档指令来声明变量和要执行的 PHP 代码: @setup $now = new DateTime(); $environment = isset($env) ? $env : "testing"; @endsetup 还可以使用@include 来引入外部 PHP 文件: @include('vendor/autoload.php'); 确认任务 如果你想要在服务器 来运行测试。 1.1 测试环境 运行测试的时候,Laravel 自动设置配置环境为 testing。Laravel 在测试时自动配置 session 和 cache 驱动为数组驱动,这意味着测试时不会持久化存储 session 和 cache。 如果需要的话你也可以创建其它测试环境配置。testing 环境变量可以在 phpunit.xml 文 件中配置。 1.2 定义&运行测试 命令即可: Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class UserTest extends0 码力 | 377 页 | 4.56 MB | 1 年前3
Laravel 5.1 中文文档指令来声明变量和要执行的 PHP 代码: @setup $now = new DateTime(); $environment = isset($env) ? $env : "testing"; @endsetup 还可以使用@include 来引入外部 PHP 文件: @include('vendor/autoload.php'); 确认任务 如果你想要在服务器上 来运行测试。 1.1 测试环境 运行测试的时候,Laravel 自动设置配置环境为 testing。Laravel 在测试时自动配置 session 和 cache 驱动为数组驱动,这意味着测试时不会持久化存储 session 和 cache。 如果需要的话你可以自由创建其它测试环境配置。testing 环境变量可以在 phpunit.xml 文 件中配置。 1.2 定义&运行测试 要创建一个测试用例,只需简单在 tests 目录下包含的 ExampleTest.php 文件: Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseTransactions; class ExampleTest extends TestCase{ 本文档由 Laravel0 码力 | 307 页 | 3.46 MB | 1 年前3
Laravel 5.3 中文文档行 测 试 的 时 候 , Laravel 会 自 动 设 置 环 境 为 testing 。 Laravel 在 测 试 时 自 动 配 置 session 和 cache 驱动为数组驱动,这意味着测试时不会持久化存储 session 和 cache。 如果需要的话你也可以创建其它测试环境配置。testing 环境变量可以在 phpunit.xml 文件中配 置,但是要确保在运行命令之前使用 Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class UserTest tests 目录下包含的 ExampleTest.php 文件: Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseTransactions; class ExampleTest extends TestCase{ /**0 码力 | 691 页 | 9.37 MB | 1 年前3
共 8 条
- 1













