Skip to content

Commit

Permalink
Add setter check
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Apr 6, 2021
1 parent a085bea commit 57f6226
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/Model/AuditManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ public function __construct(ContainerInterface $container)

public function setReader(string $serviceId, array $classes): void
{
$reader = $this->container->get($serviceId);
if (!$reader instanceof AuditReaderInterface) {
throw new \InvalidArgumentException(sprintf(
'Service "%s" MUST implement interface "%s".',
$serviceId,
AuditReaderInterface::class,
));
}

$this->readers[$serviceId] = $classes;
}

Expand Down
16 changes: 7 additions & 9 deletions tests/Twig/Extension/CanonicalizeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
final class CanonicalizeExtensionTest extends TestCase
{
/**
* @var RequestStack
* @var Request
*/
private $requestStack;
private $request;

/**
* @var CanonicalizeExtension
Expand All @@ -35,9 +35,10 @@ final class CanonicalizeExtensionTest extends TestCase

protected function setUp(): void
{
$this->requestStack = new RequestStack();
$this->requestStack->push(new Request());
$this->twigExtension = new CanonicalizeExtension($this->requestStack);
$this->request = new Request();
$requestStack = new RequestStack();
$requestStack->push($this->request);
$this->twigExtension = new CanonicalizeExtension($requestStack);
}

/**
Expand Down Expand Up @@ -242,9 +243,6 @@ public function select2LocalesProvider()

private function changeLocale(string $locale): void
{
$request = $this->requestStack->getCurrentRequest();
\assert(null !== $request);

$request->setLocale($locale);
$this->request->setLocale($locale);
}
}

0 comments on commit 57f6226

Please sign in to comment.