jonnybarnes.uk/tests/TokenServiceTest.php
Jonny Barnes 0a07811311 Squashed commit of the following:
commit 70d23bbd8fbdbeb3b6554e42ac4283396372f39d
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Feb 3 21:40:55 2017 +0000

    Updade to Laravel 5.4
2017-02-03 21:49:49 +00:00

43 lines
1.2 KiB
PHP

<?php
namespace App\Tests;
use BrowserKitTest;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class TokenServiceTest extends BrowserKitTest
{
protected $appurl;
public function setUp()
{
parent::setUp();
$this->appurl = config('app.url');
$this->tokenService = new \App\Services\TokenService();
}
/**
* Given the token is dependent on a random nonce, the time of creation and
* the APP_KEY, to test, we shall create a token, and then verify it.
*
* @return void
*/
public function testTokenCreationAndValidation()
{
$data = [
'me' => 'https://example.org',
'client_id' => 'https://quill.p3k.io',
'scope' => 'post'
];
$token = $this->tokenService->getNewToken($data);
$valid = $this->tokenService->validateToken($token);
$validData = [
'me' => $valid->getClaim('me'),
'client_id' => $valid->getClaim('client_id'),
'scope' => $valid->getClaim('scope')
];
$this->assertSame($data, $validData);
}
}