draw/tester-bundle

Installs: 37 332

Dependents: 7

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.10.17 2024-04-17 19:21 UTC

This package is auto-updated.

Last update: 2024-04-17 19:22:03 UTC


README

This bundle integrate the Draw Tester Component.

To use the HttpTesterTrait in a KernelTestCase you must simply do this:

<?php namespace App\Tests;

use Draw\Bundle\TesterBundle\Http\BrowserFactoryInterface;
use Draw\Bundle\TesterBundle\Http\HttpTesterTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\BrowserKit\AbstractBrowser;

class TestCase extends KernelTestCase implements BrowserFactoryInterface
{
    use HttpTesterTrait;
    
    public function createBrowser(): AbstractBrowser
    {
       return static::bootKernel()->getContainer()->get('test.client');
    }
}

As you can see we are using the HttpTesterTrait of the Bundle instead of the Component. This is because it as the implementation of the implementation of the createHttpTesterClient method.

Also you can see that we are booting a new kernel every time. It's to make sure we are using a new container on each request like the behaviour of a normal client request will do.