Skip to content

Commit

Permalink
Add a new test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamison Bryant committed Mar 25, 2024
1 parent ae38eda commit d9bfdb4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/TestCase/Middleware/AuthenticationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Authentication\IdentityInterface;
use Authentication\Middleware\AuthenticationMiddleware;
use Authentication\Test\TestCase\AuthenticationTestCase as TestCase;
use Cake\Core\Container;
use Cake\Core\TestSuite\ContainerStubTrait;
use Cake\Http\Response;
use Cake\Http\ServerRequestFactory;
Expand Down Expand Up @@ -667,4 +668,25 @@ public function testMiddlewareInjectsServiceIntoDIC(): void
$container = $this->application->getContainer();
$this->assertInstanceOf(AuthenticationService::class, $container->get(AuthenticationService::class));
}

public function testMiddlewareInjectsServiceIntoDICCustomContainerInstance(): void
{
$request = ServerRequestFactory::fromGlobals(
['REQUEST_URI' => '/testpath'],
[],
['username' => 'mariano', 'password' => 'password']
);
$handler = new TestRequestHandler();

$provider = $this->createMock(AuthenticationServiceProviderInterface::class);
$provider
->method('getAuthenticationService')
->willReturn($this->service);
$container = new Container();

$middleware = new AuthenticationMiddleware($provider, $container);
$middleware->process($request, $handler);

$this->assertInstanceOf(AuthenticationService::class, $container->get(AuthenticationService::class));
}
}

0 comments on commit d9bfdb4

Please sign in to comment.