tonysm / turbo-laravel-test-helpers
0.10.0
2021-06-23 02:58 UTC
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0
- symfony/css-selector: ^5.2
- symfony/dom-crawler: ^5.2
- tonysm/turbo-laravel: ^0.10
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.3
README
此包为使用 Turbo Laravel 的应用程序添加了几个宏和断言助手。由于它有不同的依赖项,因此单独构建。
安装
您可以通过 composer 安装此包。
composer require tonysm/turbo-laravel-test-helpers --dev
使用
将特质添加到您的测试用例中。这将使 $this->turbo()
方法可用。这将添加正确的标题到您的响应中,如下所示
use Tonysm\TurboLaravelTestHelpers\Testing\InteractsWithTurbo; class ExampleTest extends TestCase { use InteractsWithTurbo; /** @test */ public function turbo_stream_test() { $response = $this->turbo()->post('my-route'); $response->assertTurboStream(); // Checks if one of the Turbo Stream responses matches this criteria. $response->assertHasTurboStream($target = 'users', $action = 'append'); // Checks if there is no Turbo Stream tag for the criteria. $response->assertDoesntHaveTurboStream($target = 'empty_users', $action = 'remove'); } /** @test */ public function turbo_native_shows() { $response = $this->turboNative()->get('my-route'); $response->assertSee('Only rendered in Turbo Native'); } }
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现任何安全问题,请通过电子邮件 tonysm@hey.com 而不是使用问题跟踪器。
致谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。
Laravel 包模板
此包是使用 Laravel 包模板 生成的。