diff --git a/composer.json b/composer.json index 8b5dca1..587d1c2 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "ray/di": "^2.15" }, "require-dev": { - "phpunit/phpunit": "^8.5", + "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3.2", "friendsofphp/php-cs-fixer": "^2.11", "phpmd/phpmd": "^2.6", diff --git a/src/Extractor/TokenExtractorResolver.php b/src/Extractor/TokenExtractorResolver.php index 1730f8a..07c15bd 100644 --- a/src/Extractor/TokenExtractorResolver.php +++ b/src/Extractor/TokenExtractorResolver.php @@ -20,6 +20,7 @@ class TokenExtractorResolver * * @var array */ + #[Extractors] public function __construct(array $extractors) { $this->extractors = $extractors; diff --git a/tests/Auth0ModuleTest.php b/tests/Auth0ModuleTest.php index b951b53..112b091 100644 --- a/tests/Auth0ModuleTest.php +++ b/tests/Auth0ModuleTest.php @@ -15,7 +15,7 @@ use Ray\Auth0Module\Extractor\AuthorizationHeaderTokenExtractor; use Ray\Auth0Module\Extractor\TokenExtractorResolver; use Ray\Auth0Module\Provider\AuthenticationClientProvider; -use Ray\Auth0Module\Provider\ManagementClientProvider; +use Ray\Auth0Module\Provider\FakeManagementClientProvider; use Ray\Di\AbstractModule; use Ray\Di\Injector; use Ray\Di\Scope; @@ -27,6 +27,7 @@ public function testModule() : void $this->module = new class extends AbstractModule { protected function configure() : void { + $this->bind(Management::class)->toProvider(FakeManagementClientProvider::class); $this->install(new Auth0Module([ 'domain' => 'AUTH0_DOMAIN', 'client_id' => 'AUTH0_CLIENT_ID', @@ -36,5 +37,6 @@ protected function configure() : void }; $injector = (new Injector($this->module, dirname(__DIR__) . '/tmp')); $this->assertInstanceOf(Authentication::class, $injector->getInstance(Authentication::class)); + $this->assertInstanceOf(Management::class, $injector->getInstance(Management::class)); } } diff --git a/tests/Fake/Provider/FakeManagementClientProvider.php b/tests/Fake/Provider/FakeManagementClientProvider.php new file mode 100644 index 0000000..95c39ad --- /dev/null +++ b/tests/Fake/Provider/FakeManagementClientProvider.php @@ -0,0 +1,41 @@ +config = $config; + } + + public function get() : Management + { +// $response = $this->authClient->client_credentials([ +// 'audience' => 'https://' . $this->config['domain'] . '/api/v2/', +// ]); + + $response = [ + 'access_token' => 'access_token', + 'domain' => 'domain' + ]; + return new Management($response['access_token'], $this->config['domain']); + } +}