Planificacion y avances de backend

This commit is contained in:
2021-04-29 01:59:08 -04:00
parent 6e4076cf15
commit b6ea4a7ce2
21 changed files with 486 additions and 156 deletions

View File

@@ -0,0 +1,33 @@
<?php
use App\Services\Auth0Service;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Http;
class Auth0ServiceTest extends TestCase {
public function testIsNotInCache() {
Redis::shouldReceive('get')->once()->with('auth0_token')->andReturns(null);
Http::fake([
'*' => Http::response([
"access_token" => "token",
"scope" => "read:client_grants",
"expires_in" => 86400,
"token_type" => "Bearer"
])
]);
Redis::shouldReceive('set')->with('auth0_token', "token", 'EX', 86400);
$tokenService = app(Auth0Service::class);
$this->assertEquals("token", $tokenService->getToken());
}
public function testIsInCache() {
Redis::shouldReceive('get')->once()->with('auth0_token')->andReturns("token");
Redis::shouldReceive('set')->never();
Http::shouldReceive('post')->never();
$tokenService = app(Auth0Service::class);
$this->assertEquals("token", $tokenService->getToken());
}
}