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() |
|
|
|
|
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
|
|
|
|
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.