mglaman/drupal-test-helpers

Helpers for writing better Kernel and Unit tests for Drupal

1.0.3 2024-05-20 21:13 UTC

This package is auto-updated.

Last update: 2024-10-20 22:09:52 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()
        );
    }
}