Skip to content

Commit 67d3f82

Browse files
Jamison BryantADmad
authored andcommitted
Add a new test
1 parent abb32a2 commit 67d3f82

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/TestCase/Middleware/AuthenticationMiddlewareTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Authentication\IdentityInterface;
2525
use Authentication\Middleware\AuthenticationMiddleware;
2626
use Authentication\Test\TestCase\AuthenticationTestCase as TestCase;
27+
use Cake\Core\Container;
2728
use Cake\Core\TestSuite\ContainerStubTrait;
2829
use Cake\Http\Response;
2930
use Cake\Http\ServerRequestFactory;
@@ -667,4 +668,25 @@ public function testMiddlewareInjectsServiceIntoDIC(): void
667668
$container = $this->application->getContainer();
668669
$this->assertInstanceOf(AuthenticationService::class, $container->get(AuthenticationService::class));
669670
}
671+
672+
public function testMiddlewareInjectsServiceIntoDICCustomContainerInstance(): void
673+
{
674+
$request = ServerRequestFactory::fromGlobals(
675+
['REQUEST_URI' => '/testpath'],
676+
[],
677+
['username' => 'mariano', 'password' => 'password']
678+
);
679+
$handler = new TestRequestHandler();
680+
681+
$provider = $this->createMock(AuthenticationServiceProviderInterface::class);
682+
$provider
683+
->method('getAuthenticationService')
684+
->willReturn($this->service);
685+
$container = new Container();
686+
687+
$middleware = new AuthenticationMiddleware($provider, $container);
688+
$middleware->process($request, $handler);
689+
690+
$this->assertInstanceOf(AuthenticationService::class, $container->get(AuthenticationService::class));
691+
}
670692
}

0 commit comments

Comments
 (0)