Skip to content

Commit

Permalink
Merge pull request #2876 from acrobat/symfony5-compatibility-fixes
Browse files Browse the repository at this point in the history
[AllBundles] Forward compatibility fixes for symfony 5
  • Loading branch information
acrobat authored May 24, 2021
2 parents 9bea822 + 0f6dc7d commit c1e6f2c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Translation\Translator;

class AdminLocaleListenerTest extends TestCase
{
Expand All @@ -22,7 +22,7 @@ public function testListener($uri, $shouldPerformCheck, $tokenStorageCallCount)
{
$request = new Request([], [], [], [], [], ['REQUEST_URI' => $uri]);
$storage = $this->createMock(TokenStorageInterface::class);
$trans = $this->createMock(TranslatorInterface::class);
$trans = $this->createMock(Translator::class);
$adminRouteHelper = $this->createMock(AdminRouteHelper::class);
$event = $this->createMock(GetResponseEvent::class);
$token = $this->createMock(UsernamePasswordToken::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
use Kunstmaan\AdminListBundle\AdminList\Field;
use Kunstmaan\FormBundle\Entity\FormSubmission;
use Kunstmaan\NodeBundle\Entity\NodeTranslation;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Translation\TranslatorInterface as LegaceTranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* Export list configuration to list all the form submissions for a given NodeTranslation
Expand Down Expand Up @@ -46,10 +47,15 @@ class FormSubmissionExportListConfigurator implements ExportListConfiguratorInte
protected $batchSize;

/**
* @param int $batchSize
* @param LegaceTranslatorInterface|TranslatorInterface $translator
* @param int $batchSize
*/
public function __construct(EntityManagerInterface $em, NodeTranslation $nodeTranslation, TranslatorInterface $translator, $batchSize = 20)
public function __construct(EntityManagerInterface $em, NodeTranslation $nodeTranslation, /*TranslatorInterface*/ $translator, $batchSize = 20)
{
if (!$translator instanceof LegaceTranslatorInterface && !$translator instanceof TranslatorInterface) {
throw new \InvalidArgumentException(sprintf('Argument "$translator" passed to "%s" must be of the type "%s" or "%s", "%s" given', __METHOD__, LegaceTranslatorInterface::class, TranslatorInterface::class, get_class($translator)));
}

$this->nodeTranslation = $nodeTranslation;
$this->em = $em;
$this->translator = $translator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Translation\TranslatorInterface as LegaceTranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

class HostOverrideListener
{
Expand All @@ -36,10 +37,14 @@ class HostOverrideListener

public function __construct(
Session $session,
TranslatorInterface $translator,
/*TranslatorInterface*/ $translator,
DomainConfigurationInterface $domainConfiguration,
AdminRouteHelper $adminRouteHelper
) {
if (!$translator instanceof LegaceTranslatorInterface && !$translator instanceof TranslatorInterface) {
throw new \InvalidArgumentException(sprintf('Argument "$translator" passed to "%s" must be of the type "%s" or "%s", "%s" given', __METHOD__, LegaceTranslatorInterface::class, TranslatorInterface::class, get_class($translator)));
}

$this->session = $session;
$this->translator = $translator;
$this->domainConfiguration = $domainConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getConfiguration()

public function testInvalidConfiguration()
{
$this->assertConfigurationIsInvalid([[]], 'The child node "hosts" at path "kunstmaan_multi_domain" must be configured.');
$this->assertConfigurationIsInvalid([[]], '/The child (node|config) "hosts" (at path|under) "kunstmaan_multi_domain" must be configured./', true);
}

public function testProcessedValueContainsRequiredValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Translation\Translator;

class HostOverrideListenerTest extends TestCase
{
Expand Down Expand Up @@ -130,7 +131,7 @@ private function getHostOverrideListener($flashBag)
$domainConfiguration = $this->createMock('Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface');
$domainConfiguration->method('getHost')
->willReturn('override-domain.tld');
$translator = $this->createMock('Symfony\Component\Translation\TranslatorInterface');
$translator = $this->createMock(Translator::class);
$translator->method('trans')
->willReturnArgument(0);

Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/TranslatorBundle/Tests/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ imports:
framework:
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
resource: "%kernel.project_dir%/config/routing.yml"
strict_requirements: "%kernel.debug%"
form: ~
csrf_protection: ~
Expand Down

0 comments on commit c1e6f2c

Please sign in to comment.