Skip to content

Commit

Permalink
test(client): add tests for setting authenticator and handler stack r…
Browse files Browse the repository at this point in the history
…esolver

- Add test for setting Authenticator in Client class.
- Verify that NullAuthenticator can be set and retrieved correctly.
- Add test for setting handler stack resolver in Client class.
- Ensure the handler stack resolver can be set and retrieved correctly.
  • Loading branch information
guanguans committed Sep 9, 2024
1 parent ad23501 commit 8195dde
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Foundation/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use Guanguans\Notify\AnPush\Authenticator;
use Guanguans\Notify\AnPush\Messages\Message;
use Guanguans\Notify\Foundation\Authenticators\NullAuthenticator;
use Guanguans\Notify\Foundation\Client;
use Guanguans\Notify\Foundation\Concerns\AsNullUri;
use Illuminate\Support\Collection;
Expand All @@ -31,6 +32,12 @@
})->dump()->toBeInstanceOf(Client::class);
})->group(__DIR__, __FILE__);

it('can set Authenticator', function (): void {
expect(new class extends Client {})
->setAuthenticator($authenticator = new NullAuthenticator)->toBeInstanceOf(Client::class)
->getAuthenticator()->toBe($authenticator);
})->group(__DIR__, __FILE__);

it('can concurrent send messages', function (): void {
$authenticator = new Authenticator('FE3LGGYQZXRZ6A50BN66M42H0BY');
$client = new \Guanguans\Notify\AnPush\Client($authenticator);
Expand Down
6 changes: 6 additions & 0 deletions tests/Foundation/Concerns/HasHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@
expect(new Client)
->setHandlerStack(HandlerStack::create())->toBeInstanceOf(Client::class);
})->group(__DIR__, __FILE__);

it('can set handler stack resolver', function (): void {
expect(new Client)
->setHandlerStackResolver($handlerStack = HandlerStack::create())->toBeInstanceOf(Client::class)
->getHandlerStackResolver()->toBe($handlerStack);
})->group(__DIR__, __FILE__);

0 comments on commit 8195dde

Please sign in to comment.