GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#30)
by Christian
01:28
created

AuthServiceTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 56
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testCreateSession() 0 23 1
A testCreateToken() 0 11 1
A testGetAuthUrl() 0 10 1
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\LastFm\Tests\Service;
11
12
use Core23\LastFm\Client\ApiClientInterface;
13
use Core23\LastFm\Service\AuthService;
14
use PHPUnit\Framework\TestCase;
15
16
final class AuthServiceTest extends TestCase
17
{
18
    private $client;
19
20
    protected function setUp(): void
21
    {
22
        $this->client =  $this->prophesize(ApiClientInterface::class);
23
    }
24
25
    public function testCreateSession(): void
26
    {
27
        $this->client->signedCall('auth.getSession', [
28
            'token' => 'user-token',
29
        ])
30
            ->willReturn([
31
                'session' => [
32
                    'name'       => 'FooBar',
33
                    'key'        => 'the-key',
34
                    'subscriber' => 15,
35
                ],
36
            ])
37
        ;
38
39
        $service = new AuthService($this->client->reveal());
40
41
        $result = $service->createSession('user-token');
42
43
        static::assertNotNull($result);
44
        static::assertSame('FooBar', $result->getName());
45
        static::assertSame('the-key', $result->getKey());
46
        static::assertSame(15, $result->getSubscriber());
47
    }
48
49
    public function testCreateToken(): void
50
    {
51
        $this->client->signedCall('auth.getToken')
52
            ->willReturn([
53
                'token' => 'The Token',
54
            ])
55
        ;
56
57
        $service = new AuthService($this->client->reveal());
58
        static::assertSame('The Token', $service->createToken());
59
    }
60
61
    public function testGetAuthUrl(): void
62
    {
63
        $this->client->getApiKey()
64
            ->willReturn('api-key')
65
        ;
66
67
        $service = new AuthService($this->client->reveal());
68
69
        static::assertSame('http://www.last.fm/api/auth/?api_key=api-key&cb=https://example.org', $service->getAuthUrl('https://example.org'));
70
    }
71
}
72