mockFilledRequest example

use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class RouteProcessorTest extends TestCase
{
    private const TEST_CONTROLLER = 'App\Controller\SomeController::someMethod';
    private const TEST_ROUTE = 'someRouteName';
    private const TEST_PARAMS = ['param1' => 'value1'];

    public function testProcessor()
    {
        $request = $this->mockFilledRequest();
        $processor = new RouteProcessor();
        $processor->addRouteData($this->getRequestEvent($request));

        $record = $processor(['extra' => []]);

        $this->assertArrayHasKey('requests', $record['extra']);
        $this->assertCount(1, $record['extra']['requests']);
        $this->assertEquals(
            ['controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE, 'route_params' => self::TEST_PARAMS],
            $record['extra']['requests'][0]
        );
    }
Home | Imprint | This part of the site doesn't use cookies.