-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTestCase.php
More file actions
44 lines (33 loc) · 1.29 KB
/
TestCase.php
File metadata and controls
44 lines (33 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php declare(strict_types=1);
namespace Tests\CustomerGauge\Cognito;
use CustomerGauge\Cognito\Contracts\UserFactory;
use CustomerGauge\Cognito\Issuer;
use CustomerGauge\Cognito\Testing\TokenGenerator;
use Illuminate\Cache\ArrayStore;
use Illuminate\Cache\Repository;
use Illuminate\Container\Container;
use Illuminate\Contracts\Cache\Repository as RepositoryContract;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Tests\CustomerGauge\Cognito\Fixtures\MyUserFactory;
abstract class TestCase extends BaseTestCase
{
protected $container;
protected function setUp(): void
{
$this->container = $container = Container::getInstance();
$container->bind(Issuer::class, function () {
return new Issuer('phpunit-pool-id', 'local');
});
$container->bind(RepositoryContract::class, function () {
$repository = new Repository(new ArrayStore());
$repository->set('jwks', file_get_contents(__DIR__ .'/Fixtures/jwt.key.pub'));
return $repository;
});
$container->bind(UserFactory::class, MyUserFactory::class);
}
protected function jwtToken(array $claims): string
{
$generator = TokenGenerator::fromFile(__DIR__ . '/Fixtures/jwt.key');
return $generator->sign($claims);
}
}