move supported languages logic to service (#2701)
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
namespace App\Tests\EventSubscriber;
|
||||
|
||||
use App\EventSubscriber\RedirectToLocaleSubscriber;
|
||||
use App\Utils\LanguageService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
@@ -24,7 +25,7 @@ class RedirectToLocaleSubscriberTest extends TestCase
|
||||
public function testConstruct()
|
||||
{
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$sut = new RedirectToLocaleSubscriber($urlGenerator, 'de|en', 'en');
|
||||
$sut = new RedirectToLocaleSubscriber($urlGenerator, new LanguageService('de|en'));
|
||||
|
||||
self::assertEquals([KernelEvents::REQUEST => ['onKernelRequest']], RedirectToLocaleSubscriber::getSubscribedEvents());
|
||||
|
||||
@@ -37,13 +38,4 @@ class RedirectToLocaleSubscriberTest extends TestCase
|
||||
|
||||
$sut->onKernelRequest($event);
|
||||
}
|
||||
|
||||
public function testConstructWithUnknownDefaultLocale()
|
||||
{
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
$this->expectExceptionMessage('The default locale ("en") must be one of "de|it".');
|
||||
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$sut = new RedirectToLocaleSubscriber($urlGenerator, 'de|it', 'en');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user