Completed
Push — master ( ae399a...84a10b )
by Miro
05:50
created

PaginatedKnpLabsRepoFacadeTest::provideTestRepo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 8
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
namespace tests\DevBoardLib\GithubApiFacade\Repo;
3
4
use DevBoardLib\GithubApiFacade\Client\KnpLabsClientFactory;
5
use DevBoardLib\GithubApiFacade\Repo\PaginatedKnpLabsRepoFacade;
6
use Mockery as m;
7
8
/**
9
 * Class PaginatedKnpLabsRepoFacadeTest.
10
 */
11
class PaginatedKnpLabsRepoFacadeTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @group GithubIntegration Live
15
     */
16
    public function testFetchAllMilestones()
17
    {
18
        $target = new PaginatedKnpLabsRepoFacade(
19
            $this->getTokenAuthenticatedApiClient(),
20
            $this->provideTestRepo()
21
        );
22
23
        self::assertCount(3, $target->fetchAllMilestones());
24
    }
25
26
    /**
27
     * @group GithubIntegration Live
28
     */
29
    public function testFetchAllIssues()
30
    {
31
        $target = new PaginatedKnpLabsRepoFacade(
32
            $this->getTokenAuthenticatedApiClient(),
33
            $this->provideTestRepo()
34
        );
35
36
        self::assertCount(11, $target->fetchAllIssues());
37
    }
38
39
    /**
40
     * @return \Github\Client
41
     */
42
    private function getTokenAuthenticatedApiClient()
43
    {
44
        $factory = new KnpLabsClientFactory();
45
46
        return $factory->createTokenAuthenticatedClient($this->provideTestUser());
47
    }
48
49
    /**
50
     * @return m\MockInterface
51
     */
52 View Code Duplication
    private function provideTestRepo()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        $githubRepo = m::mock('DevBoardLib\GithubCore\Repo\GithubRepo');
55
        $githubRepo->shouldReceive('getOwner')->andReturn('devboard');
56
        $githubRepo->shouldReceive('getName')->andReturn('test-hitman');
57
58
        return $githubRepo;
59
    }
60
61
    /**
62
     * @return m\MockInterface
63
     */
64
    private function provideTestUser()
65
    {
66
        $user = m::mock('DevBoardLib\GithubApiFacade\Auth\GithubAccessToken');
67
        $user->shouldReceive('getGithubAccessToken')->andReturn(getenv('GITHUB_ACCESS_TOKEN'));
68
69
        return $user;
70
    }
71
}
72