mglaman/drupal-test-helpers

Helpers for writing better Kernel and Unit tests for Drupal

1.0.2 2023-06-02 04:48 UTC

This package is auto-updated.

Last update: 2024-03-31 06:39:29 UTC


README

Helpers for writing better Kernel and Unit tests for Drupal

Traits

The following traits are provided by this library for tests

RequestTrait

Provides methods to assert requests and responses within Kernel tests.

final class RequestTraitTest extends KernelTestBase
{
    use RequestTrait;

    /**
     * @var string[]
     */
    protected static $modules = ['system', 'user'];

    public function testDoRequest(): void
    {
        $this->installConfig(['system']);
        $this->doRequest(Request::create('/user/login'));
        self::assertStringContainsString(
            'Enter your  username.',
            $this->getRawContent()
        );
    }
}