Skip to content

Commit

Permalink
Merge branch 'main' into feat/restore-configurable-route-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Dec 7, 2023
2 parents 03c23a3 + 30aafed commit 5789f41
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Bridges/CacheBridgeAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final public function save(CacheItemInterface $item): bool
return false;
}

$value = serialize($item->get());
$value = serialize($item->getRawValue());
$key = $item->getKey();
$expires = $item->getExpiration();

Expand Down
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
8 changes: 3 additions & 5 deletions tests/Unit/Bridges/CacheBridgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,20 @@
expect($cache)
->toBeInstanceOf(CacheItemBridge::class)
->isHit()->toBeTrue()
->get()->toBeNull()
->set(42)
->get()->toBe(42);
->get()->toEqual(42);

$results = $pool->getItems();

expect($results)
->toBeArray()
->toHaveCount(0);

$results = $pool->getItems(['testing' => uniqid()]);
$results = $pool->getItems(['testing']);

expect($results['testing'])
->toBeInstanceOf(CacheItemBridge::class)
->isHit()->toBeTrue()
->get()->not()->toBe(42);
->get()->toEqual(42);

$this->app[\Illuminate\Cache\CacheManager::class]
->getStore()
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 5789f41

Please sign in to comment.