Skip to content

Commit

Permalink
Merge pull request #5 from aschempp/feature/response-context-rework
Browse files Browse the repository at this point in the history
Added failing test to show alias being overridden
  • Loading branch information
Toflar committed Jun 11, 2021
2 parents 6a1eebc + e90daf4 commit a5c9589
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core-bundle/tests/Routing/ResponseContext/ResponseContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
use Contao\CoreBundle\Routing\ResponseContext\ResponseContext;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\ServerBag;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;

Expand Down Expand Up @@ -63,6 +66,19 @@ public function testLazyServicesAreNotDuplicated(): void
$this->assertSame($original, $parent);
}

public function testLastServiceWins(): void
{
$context = new ResponseContext();

$this->assertFalse($context->has(ParameterBag::class));

$context->addLazy(ServerBag::class, static function () { return new ServerBag(); });
$context->addLazy(InputBag::class, static function () { return new InputBag(); });

$this->assertInstanceOf(ServerBag::class, $context->get(ServerBag::class));
$this->assertInstanceOf(InputBag::class, $context->get(ParameterBag::class));
}

public function testGettingANonExistentServiceThrows(): void
{
$this->expectException(\InvalidArgumentException::class);
Expand Down

0 comments on commit a5c9589

Please sign in to comment.