forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerateAccessTokenTest.php
More file actions
35 lines (28 loc) · 915 Bytes
/
GenerateAccessTokenTest.php
File metadata and controls
35 lines (28 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace Tests;
use ProcessMaker\GenerateAccessToken;
use ProcessMaker\Models\User;
use RuntimeException;
class GenerateAccessTokenTest extends TestCase
{
public function setUpWithPersonalAccessClient()
{
$this->withPersonalAccessClient();
}
public function testGetNewToken()
{
$user = User::factory()->create();
$tokenRef = new GenerateAccessToken($user);
// use regex to verify JWT
$this->assertRegExp("/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+$/", $tokenRef->getToken());
}
public function testDeleteToken()
{
$user = User::factory()->create();
$this->assertEquals(0, $user->tokens()->count());
$tokenRef = new GenerateAccessToken($user);
$this->assertEquals(1, $user->tokens()->count());
$tokenRef->delete();
$this->assertEquals(0, $user->tokens()->count());
}
}