Completed
Push — master ( cd5f41...3e5383 )
by Miro
03:08
created

SimpleUserFacadeTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 28.85 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 7
dl 15
loc 52
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testfetchAllAccessibleRepos() 15 15 2
A createFacade() 0 7 1
A getDataProvider() 0 4 1
A provideTestRepo() 0 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace tests\DevBoardLib\GithubObjectApiFacade\Repo;
4
5
use DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter\GithubRepoConverter;
6
use DevBoardLib\GithubObjectApiFacade\Repo\SimpleRepoFacade;
7
use DevBoardLib\GithubObjectApiFacade\User\SimpleUserFacade;
8
use Mockery as m;
9
use tests\DevBoardLib\GithubObjectApiFacade\SampleDataProvider;
10
11
/**
12
 * Class SimpleRepoFacadeTest.
13
 *
14
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
15
 */
16
class SimpleUserFacadeTest extends \PHPUnit_Framework_TestCase
17
{
18 View Code Duplication
    public function testfetchAllAccessibleRepos()
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...
19
    {
20
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\User\UserFacade');
21
        $wrapped->shouldReceive('fetchAllAccessibleRepos')
22
            ->andReturn($this->getDataProvider()->getMyRepositoriesAll());
23
24
        $target = $this->createFacade($wrapped);
25
26
        foreach ($target->fetchAllAccessibleRepos() as $repo) {
27
            self::assertInstanceOf(
28
                'DevBoardLib\GithubCore\Repo\GithubRepoSource',
29
                $repo
30
            );
31
        }
32
    }
33
34
    /**
35
     * @param $wrapped
36
     *
37
     * @return SimpleRepoFacade
38
     */
39
    protected function createFacade($wrapped)
40
    {
41
        return new SimpleUserFacade(
42
            $wrapped,
43
            new GithubRepoConverter()
44
        );
45
    }
46
47
    /**
48
     * @return SampleDataProvider
49
     */
50
    protected function getDataProvider()
51
    {
52
        return new SampleDataProvider();
53
    }
54
55
    /**
56
     * @return m\MockInterface
57
     */
58
    protected function provideTestRepo()
59
    {
60
        $repo   = m::mock('DevBoardLib\GithubCore\Repo\GithubRepo');
61
        $repoId = m::mock('DevBoardLib\GithubCore\Repo\GithubRepoId');
62
63
        $repo->shouldReceive('getId')->andReturn($repoId);
64
65
        return $repo;
66
    }
67
}
68