Completed
Push — master ( 1f5aaf...c63d45 )
by Miro
04:10 queued 02:00
created

testFetchAllIssues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 9
rs 9.6666
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
15
     * @group Live
16
     */
17
    public function testFetchAllMilestones()
18
    {
19
        $target = new PaginatedKnpLabsRepoFacade(
20
            $this->getTokenAuthenticatedApiClient(),
21
            $this->provideTestRepo()
22
        );
23
24
        self::assertCount(4, $target->fetchAllMilestones());
25
    }
26
27
    /**
28
     * @group GithubIntegration
29
     * @group Live
30
     * @group wip
31
     */
32
    public function testFetchAllIssues()
33
    {
34
        $target = new PaginatedKnpLabsRepoFacade(
35
            $this->getTokenAuthenticatedApiClient(),
36
            $this->provideTestRepo()
37
        );
38
39
        self::assertCount(10, $target->fetchAllIssues());
40
    }
41
42
    /**
43
     * @group GithubIntegration
44
     * @group Live
45
     * @group wip
46
     */
47
    public function testFetchAllIssuesAndPullRequests()
48
    {
49
        $target = new PaginatedKnpLabsRepoFacade(
50
            $this->getTokenAuthenticatedApiClient(),
51
            $this->provideTestRepo()
52
        );
53
54
        self::assertCount(12, $target->fetchAllIssuesAndPullRequests());
55
    }
56
57
    /**
58
     * @return \Github\Client
59
     */
60
    private function getTokenAuthenticatedApiClient()
61
    {
62
        $factory = new KnpLabsClientFactory();
63
64
        return $factory->createTokenAuthenticatedClient($this->provideTestUser());
65
    }
66
67
    /**
68
     * @return m\MockInterface
69
     */
70 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...
71
    {
72
        $githubRepo = m::mock('DevBoardLib\GithubCore\Repo\GithubRepo');
73
        $githubRepo->shouldReceive('getOwner')->andReturn('devboard');
74
        $githubRepo->shouldReceive('getName')->andReturn('test-hitman');
75
76
        return $githubRepo;
77
    }
78
79
    /**
80
     * @return m\MockInterface
81
     */
82
    private function provideTestUser()
83
    {
84
        $user = m::mock('DevBoardLib\GithubApiFacade\Auth\GithubAccessToken');
85
        $user->shouldReceive('getGithubAccessToken')->andReturn(getenv('GITHUB_ACCESS_TOKEN'));
86
87
        return $user;
88
    }
89
}
90