Planificacion y avances de backend
This commit is contained in:
33
backend/tests/Auth0ServiceTest.php
Normal file
33
backend/tests/Auth0ServiceTest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Lumen\Testing\DatabaseMigrations;
|
||||
use Laravel\Lumen\Testing\DatabaseTransactions;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExample()
|
||||
{
|
||||
$this->get('/');
|
||||
|
||||
$this->assertEquals(
|
||||
$this->app->version(), $this->response->getContent()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user