Skip to content

Commit

Permalink
Resolve code coverage warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Dec 7, 2023
1 parent c0aa340 commit a53f05c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

/**
* @api
*
* @codeCoverageIgnore
*/
final class Events implements EventsContract
{
Expand Down
2 changes: 2 additions & 0 deletions src/Guards/AuthenticationGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public function user(): ?Authenticatable
/**
* @var ?Authenticatable $lastResponse
*/
// @codeCoverageIgnoreStart
if (class_exists('\Laravel\Telescope\Telescope')) {
static $depth = 0;
static $lastCalled = null;
Expand All @@ -304,6 +305,7 @@ public function user(): ?Authenticatable
++$depth;
$lastCalled = time();
}
// @codeCoverageIgnoreEnd

$currentUser = $this->getCredential()?->getUser();

Expand Down
5 changes: 5 additions & 0 deletions src/Guards/GuardAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ final public function processToken(
Events::dispatch($event = new TokenVerificationFailed($token, $invalidTokenException));

if ($event->throwException) {
// @codeCoverageIgnoreStart
throw $invalidTokenException;
// @codeCoverageIgnoreEnd
}

return null;
Expand All @@ -242,6 +244,9 @@ final public function sdk(
return $this->sdk->getSdk();
}

/**
* @codeCoverageIgnore
*/
final public function service(): ?InstanceEntityContract
{
return $this->sdk;
Expand Down
9 changes: 9 additions & 0 deletions src/UserProviderAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ final public function retrieveByCredentials(array $credentials): ?Authenticatabl
static $lastResponse = null;
static $lastCredentials = null;

// @codeCoverageIgnoreStart

/**
* @var ?Authenticatable $lastResponse
* @var array $lastCredentials
Expand Down Expand Up @@ -94,6 +96,8 @@ final public function retrieveByCredentials(array $credentials): ?Authenticatabl
$lastCredentials = $credentials;
}

// @codeCoverageIgnoreEnd

$lastResponse = $this->getRepository()->fromSession($credentials);

$this->withoutRecording(static fn (): bool => Cache::put('auth0_sdk_credential_lookup_' . $hash, $lastResponse, 5));
Expand Down Expand Up @@ -222,6 +226,11 @@ protected function setRepositoryName(string $repositoryName): void
$this->repositoryName = $repositoryName;
}

/**
* @codeCoverageIgnore
*
* @param callable $callback
*/
protected function withoutRecording(callable $callback): mixed
{
if (class_exists(self::TELESCOPE)) {
Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/UserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,10 @@
expect($provider->getRepository())
->toBeInstanceOf($repository::class);
});

test('retrieveByCredentials() returns `null` when an empty array is provided', function (): void {
$provider = new UserProvider(['model' => uniqid()]);
$repository = new UserRepository();

expect($provider->retrieveByCredentials([]))->toBeNull();
});

0 comments on commit a53f05c

Please sign in to comment.