PaginatedKnpLabsUserFacadeTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 6
dl 0
loc 43
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testFetchAllAccessibleRepos() 0 4 1
A getTokenAuthenticatedApiClient() 0 6 1
A provideTestUser() 0 7 1
1
<?php
2
3
namespace tests\DevBoardLib\GithubApiFacade\User;
4
5
use DevBoardLib\GithubApiFacade\Client\KnpLabsClientFactory;
6
use DevBoardLib\GithubApiFacade\User\PaginatedKnpLabsUserFacade;
7
use Mockery as m;
8
9
/**
10
 * Class PaginatedKnpLabsUserFacadeTest.
11
 */
12
class PaginatedKnpLabsUserFacadeTest extends \PHPUnit_Framework_TestCase
13
{
14
    private $facade;
15
16
    public function setUp()
17
    {
18
        parent::setUp();
19
20
        $this->facade = new PaginatedKnpLabsUserFacade(
21
            $this->getTokenAuthenticatedApiClient()
22
        );
23
    }
24
25
    /**
26
     * @group GithubIntegration
27
     * @group Live
28
     */
29
    public function testFetchAllAccessibleRepos()
30
    {
31
        self::assertCount(5, $this->facade->fetchAllAccessibleRepos());
32
    }
33
34
    /**
35
     * @return \Github\Client
36
     */
37
    private function getTokenAuthenticatedApiClient()
38
    {
39
        $factory = new KnpLabsClientFactory();
40
41
        return $factory->createTokenAuthenticatedClient($this->provideTestUser());
42
    }
43
44
    /**
45
     * @return \DevBoardLib\GithubApiFacade\Auth\GithubAccessToken
46
     */
47
    private function provideTestUser()
48
    {
49
        $user = m::mock('DevBoardLib\GithubApiFacade\Auth\GithubAccessToken');
50
        $user->shouldReceive('getGithubAccessToken')->andReturn(getenv('GITHUB_ACCESS_TOKEN'));
51
52
        return $user;
53
    }
54
}
55