DummyLocaleAware example

protected function tearDown(): void
    {
        parent::tearDown();

        \Locale::setDefault($this->intlLocale);
    }

    public function testCanSwitchLocale()
    {
        \Locale::setDefault('en');

        $service = new DummyLocaleAware('en');
        $switcher = new LocaleSwitcher('en', [$service]);

        $this->assertSame('en', \Locale::getDefault());
        $this->assertSame('en', $service->getLocale());
        $this->assertSame('en', $switcher->getLocale());

        $switcher->setLocale('fr');

        $this->assertSame('fr', \Locale::getDefault());
        $this->assertSame('fr', $service->getLocale());
        $this->assertSame('fr', $switcher->getLocale());
    }
Home | Imprint | This part of the site doesn't use cookies.