1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\DevBoardLib\GithubObjectApiFacade\Repo; |
4
|
|
|
|
5
|
|
|
use DevBoardLib\GithubApiFacade\Repo\RepoFacade; |
6
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Branch\Converter\GithubBranchConverter; |
7
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Commit\Converter\GithubCommitConverter; |
8
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\CommitStatus\Converter\GithubCommitStatusConverter; |
9
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Issue\Converter\GithubIssueConverter; |
10
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter\GithubMilestoneConverter; |
11
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\PullRequest\Converter\GithubPullRequestConverter; |
12
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter\GithubRepoConverter; |
13
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Tag\Converter\GithubTagConverter; |
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Prophecy\Argument; |
16
|
|
|
|
17
|
|
|
class SimpleRepoFacadeSpec extends ObjectBehavior |
18
|
|
|
{ |
19
|
|
|
public function it_is_initializable() |
20
|
|
|
{ |
21
|
|
|
$this->shouldHaveType('DevBoardLib\GithubObjectApiFacade\Repo\SimpleRepoFacade'); |
22
|
|
|
$this->shouldHaveType('DevBoardLib\GithubApiFacade\Repo\RepoFacade'); |
23
|
|
|
$this->shouldHaveType('DevBoardLib\GithubObjectApiFacade\Repo\ObjectRepoFacade'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function let( |
27
|
|
|
RepoFacade $repoFacade, |
28
|
|
|
GithubRepoConverter $githubRepoConverter, |
29
|
|
|
GithubBranchConverter $githubBranchConverter, |
30
|
|
|
GithubTagConverter $githubTagConverter, |
31
|
|
|
GithubPullRequestConverter $githubPullRequestConverter, |
32
|
|
|
GithubCommitConverter $githubCommitConverter, |
33
|
|
|
GithubCommitStatusConverter $githubCommitStatusConverter, |
34
|
|
|
GithubIssueConverter $githubIssueConverter, |
35
|
|
|
GithubMilestoneConverter $githubMilestoneConverter |
36
|
|
|
) { |
37
|
|
|
$this->beConstructedWith( |
38
|
|
|
$repoFacade, |
39
|
|
|
$githubRepoConverter, |
40
|
|
|
$githubBranchConverter, |
41
|
|
|
$githubTagConverter, |
42
|
|
|
$githubPullRequestConverter, |
43
|
|
|
$githubCommitConverter, |
44
|
|
|
$githubCommitStatusConverter, |
45
|
|
|
$githubIssueConverter, |
46
|
|
|
$githubMilestoneConverter |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
View Code Duplication |
public function it_will_return_all_repo_milestones($repoFacade, $githubMilestoneConverter) |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$repoFacade->fetchAllMilestones()->willReturn([['milestone-data']]); |
53
|
|
|
|
54
|
|
|
$githubMilestoneConverter->convert(['milestone-data'])->willReturn('converted'); |
55
|
|
|
|
56
|
|
|
$this->fetchAllMilestones()->shouldReturn(['converted']); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
View Code Duplication |
public function it_will_return_all_repo_issues($repoFacade, $githubIssueConverter) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
$repoFacade->fetchAllIssues()->willReturn([['milestone-data']]); |
62
|
|
|
$githubIssueConverter->convert(['milestone-data'])->willReturn('converted'); |
63
|
|
|
|
64
|
|
|
$this->fetchAllIssues()->shouldReturn(['converted']); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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.