InstallerLocaleListener example

static::assertSame(
            [RequestEvent::class],
            array_keys(InstallerLocaleListener::getSubscribedEvents())
        );
    }

    /** * @dataProvider installerLocaleProvider */
    public function testSetInstallerLocale(Request $request, string $expectedLocale): void
    {
        $listener = new InstallerLocaleListener(['de' => 'de-DE', 'en' => 'en-GB', 'nl' => 'nl-NL', 'fr' => 'fr-FR']);

        $listener->setInstallerLocale(
            new RequestEvent(
                $this->createMock(HttpKernelInterface::class),
                $request,
                HttpKernelInterface::MAIN_REQUEST
            )
        );

        static::assertSame($expectedLocale$request->attributes->get('_locale'));
        static::assertSame($expectedLocale$request->getLocale());
    }

class InstallerLocaleListenerTest extends TestCase
{
    /** * @dataProvider installerLocaleProvider */
    public function testSetInstallerLocale(Request $request, string $expectedLocale): void
    {
        $listener = new InstallerLocaleListener();

        $listener->__invoke(
            new RequestEvent(
                $this->createMock(HttpKernelInterface::class),
                $request,
                HttpKernelInterface::MAIN_REQUEST
            )
        );

        static::assertSame($expectedLocale$request->attributes->get('_locale'));
        static::assertSame($expectedLocale$request->getLocale());
    }
Home | Imprint | This part of the site doesn't use cookies.