testFetchAllAccessibleRepos()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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