tonysm/turbo-laravel-test-helpers

该包已被废弃,不再维护。作者建议使用 tonysm/turbo-laravel 包。

为使用 Turbo Laravel 的应用程序提供的一些测试助手。

0.10.0 2021-06-23 02:58 UTC

This package is auto-updated.

Last update: 2021-09-24 17:35:57 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

此包为使用 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 包模板 生成的。