From 2ac7c9a95963528df2cf883096e48636b4ff7e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Sun, 9 Aug 2015 13:22:42 +0200 Subject: [PATCH] Fix: Use GitHub domain language --- src/Console/PullRequestCommand.php | 12 +- src/Repository/CommitRepository.php | 38 +-- src/Repository/PullRequestRepository.php | 26 +- tests/Console/PullRequestCommandTest.php | 28 +- tests/Repository/CommitRepositoryTest.php | 278 +++++++++--------- .../Repository/PullRequestRepositoryTest.php | 26 +- 6 files changed, 204 insertions(+), 204 deletions(-) diff --git a/src/Console/PullRequestCommand.php b/src/Console/PullRequestCommand.php index 8b20b34c..31472f01 100644 --- a/src/Console/PullRequestCommand.php +++ b/src/Console/PullRequestCommand.php @@ -40,14 +40,14 @@ protected function configure() ->setName('pull-request') ->setDescription('Creates a changelog from merged pull requests between references') ->addArgument( - 'vendor', + 'owner', Input\InputArgument::REQUIRED, - 'The name of the vendor, e.g., "localheinz"' + 'The owner, e.g., "localheinz"' ) ->addArgument( - 'package', + 'repository', Input\InputArgument::REQUIRED, - 'The name of the package, e.g. "github-changelog"' + 'The repository, e.g. "github-changelog"' ) ->addArgument( 'start-reference', @@ -89,8 +89,8 @@ protected function execute(Input\InputInterface $input, Output\OutputInterface $ try { $pullRequests = $this->pullRequestRepository()->items( - $input->getArgument('vendor'), - $input->getArgument('package'), + $input->getArgument('owner'), + $input->getArgument('repository'), $input->getArgument('start-reference'), $input->getArgument('end-reference') ); diff --git a/src/Repository/CommitRepository.php b/src/Repository/CommitRepository.php index 79aeaac2..8f32d0ed 100644 --- a/src/Repository/CommitRepository.php +++ b/src/Repository/CommitRepository.php @@ -18,21 +18,21 @@ public function __construct(Api\Repository\Commits $api) } /** - * @param string $vendor - * @param string $package + * @param string $owner + * @param string $repository * @param string $startReference * @param string $endReference * @return Entity\Commit[] */ - public function items($vendor, $package, $startReference, $endReference) + public function items($owner, $repository, $startReference, $endReference) { if ($startReference === $endReference) { return []; } $start = $this->show( - $vendor, - $package, + $owner, + $repository, $startReference ); @@ -41,8 +41,8 @@ public function items($vendor, $package, $startReference, $endReference) } $end = $this->show( - $vendor, - $package, + $owner, + $repository, $endReference ); @@ -50,7 +50,7 @@ public function items($vendor, $package, $startReference, $endReference) return []; } - $commits = $this->all($vendor, $package, [ + $commits = $this->all($owner, $repository, [ 'sha' => $end->sha(), ]); @@ -75,7 +75,7 @@ public function items($vendor, $package, $startReference, $endReference) if (!count($commits)) { $tail = $commit; - $commits = $this->all($vendor, $package, [ + $commits = $this->all($owner, $repository, [ 'sha' => $tail->sha(), ]); } @@ -85,16 +85,16 @@ public function items($vendor, $package, $startReference, $endReference) } /** - * @param string $vendor - * @param string $package + * @param string $owner + * @param string $repository * @param string $sha * @return Entity\Commit|null */ - public function show($vendor, $package, $sha) + public function show($owner, $repository, $sha) { $response = $this->api->show( - $vendor, - $package, + $owner, + $repository, $sha ); @@ -109,20 +109,20 @@ public function show($vendor, $package, $sha) } /** - * @param string $vendor - * @param string $package + * @param string $owner + * @param string $repository * @param array $params * @return Entity\Commit[] */ - public function all($vendor, $package, array $params = []) + public function all($owner, $repository, array $params = []) { if (!array_key_exists('per_page', $params)) { $params['per_page'] = 250; } $response = $this->api->all( - $vendor, - $package, + $owner, + $repository, $params ); diff --git a/src/Repository/PullRequestRepository.php b/src/Repository/PullRequestRepository.php index 8bbcff79..87bf99a1 100644 --- a/src/Repository/PullRequestRepository.php +++ b/src/Repository/PullRequestRepository.php @@ -24,16 +24,16 @@ public function __construct(Api\PullRequest $api, CommitRepository $commitReposi } /** - * @param string $vendor - * @param string $package + * @param string $owner + * @param string $repository * @param string $id * @return Entity\PullRequest|null */ - public function show($vendor, $package, $id) + public function show($owner, $repository, $id) { $response = $this->api->show( - $vendor, - $package, + $owner, + $repository, $id ); @@ -48,24 +48,24 @@ public function show($vendor, $package, $id) } /** - * @param string $vendor - * @param string $package + * @param string $owner + * @param string $repository * @param string $startReference * @param string $endReference * @return Entity\PullRequest[] array */ - public function items($vendor, $package, $startReference, $endReference) + public function items($owner, $repository, $startReference, $endReference) { $commits = $this->commitRepository->items( - $vendor, - $package, + $owner, + $repository, $startReference, $endReference ); $pullRequests = []; - array_walk($commits, function (Entity\Commit $commit) use (&$pullRequests, $vendor, $package) { + array_walk($commits, function (Entity\Commit $commit) use (&$pullRequests, $owner, $repository) { if (0 === preg_match('/^Merge pull request #(?P\d+)/', $commit->message(), $matches)) { return; @@ -74,8 +74,8 @@ public function items($vendor, $package, $startReference, $endReference) $id = $matches['id']; $pullRequest = $this->show( - $vendor, - $package, + $owner, + $repository, $id ); diff --git a/tests/Console/PullRequestCommandTest.php b/tests/Console/PullRequestCommandTest.php index aaa98e21..0450b483 100644 --- a/tests/Console/PullRequestCommandTest.php +++ b/tests/Console/PullRequestCommandTest.php @@ -89,14 +89,14 @@ public function providerArgument() { return [ [ - 'vendor', + 'owner', true, - 'The name of the vendor, e.g., "localheinz"', + 'The owner, e.g., "localheinz"', ], [ - 'package', + 'repository', true, - 'The name of the package, e.g. "github-changelog"', + 'The repository, e.g. "github-changelog"', ], [ 'start-reference', @@ -264,8 +264,8 @@ public function testExecuteDelegatesToPullRequestRepository() { $faker = $this->faker(); - $vendor = $faker->unique()->word; - $package = $faker->unique()->word; + $owner = $faker->unique()->userName; + $repository = $faker->unique()->slug(); $startReference = $faker->unique()->sha1; $endReference = $faker->unique()->sha1; @@ -275,8 +275,8 @@ public function testExecuteDelegatesToPullRequestRepository() ->expects($this->once()) ->method('items') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($startReference), $this->equalTo($endReference) ) @@ -287,8 +287,8 @@ public function testExecuteDelegatesToPullRequestRepository() $this->command->run( $this->input([ - 'vendor' => $vendor, - 'package' => $package, + 'owner' => $owner, + 'repository' => $repository, 'start-reference' => $startReference, 'end-reference' => $endReference, ]), @@ -332,8 +332,8 @@ public function testExecuteRendersPullRequestsWithTheTemplate() $faker = $this->faker; $arguments = [ - 'vendor' => $faker->unique()->word, - 'package' => $faker->unique()->word, + 'owner' => $faker->unique()->userName, + 'repository' => $faker->unique()->slug(), 'start-reference' => $faker->unique()->sha1, 'end-reference' => $faker->unique()->sha1, ]; @@ -369,8 +369,8 @@ public function testExecuteHandlesExceptionsThrownWhenFetchingPullRequests() $faker = $this->faker(); $arguments = [ - 'vendor' => $faker->unique()->word, - 'package' => $faker->unique()->word, + 'owner' => $faker->unique()->userName, + 'repository' => $faker->unique()->slug(), 'start-reference' => $faker->unique()->sha1, 'end-reference' => $faker->unique()->sha1, ]; diff --git a/tests/Repository/CommitRepositoryTest.php b/tests/Repository/CommitRepositoryTest.php index c55bee43..187e6411 100644 --- a/tests/Repository/CommitRepositoryTest.php +++ b/tests/Repository/CommitRepositoryTest.php @@ -19,30 +19,30 @@ public function testShowReturnsCommitEntityWithShaAndMessageOnSuccess() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $sha = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); $expectedItem = $this->commitItem(); - $api + $commitApi ->expects($this->once()) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($sha) ) ->willReturn($this->response($expectedItem)) ; - $commitRepository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); $commit = $commitRepository->show( - $vendor, - $package, + $owner, + $repository, $sha ); @@ -56,8 +56,8 @@ public function testShowReturnsNullOnFailure() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $sha = $faker->sha1; $api = $this->commitApi(); @@ -66,8 +66,8 @@ public function testShowReturnsNullOnFailure() ->expects($this->once()) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($sha) ) ->willReturn('failure') @@ -76,8 +76,8 @@ public function testShowReturnsNullOnFailure() $commitRepository = new Repository\CommitRepository($api); $commit = $commitRepository->show( - $vendor, - $package, + $owner, + $repository, $sha ); @@ -88,28 +88,28 @@ public function testAllReturnsEmptyArrayOnFailure() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $sha = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); - $api + $commitApi ->expects($this->once()) ->method('all') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->arrayHasKeyAndValue('sha', $sha) ) ->willReturn('snafu') ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $commits = $repository->all( - $vendor, - $package, + $commits = $commitRepository->all( + $owner, + $repository, [ 'sha' => $sha, ] @@ -122,30 +122,30 @@ public function testAllSetsParamsPerPageTo250() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $sha = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); $expectedItems = $this->commitItems(15); - $api + $commitApi ->expects($this->once()) ->method('all') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->arrayHasKeyAndValue('per_page', 250) ) ->willReturn($this->responseFromItems($expectedItems)) ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $repository->all( - $vendor, - $package, + $commitRepository->all( + $owner, + $repository, [ 'sha' => $sha, ] @@ -156,31 +156,31 @@ public function testAllStillAllowsSettingPerPage() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $sha = $faker->sha1; $perPage = $faker->randomNumber(); - $api = $this->commitApi(); + $commitApi = $this->commitApi(); $expectedItems = $this->commitItems(15); - $api + $commitApi ->expects($this->once()) ->method('all') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->arrayHasKeyAndValue('per_page', $perPage) ) ->willReturn($this->responseFromItems($expectedItems)) ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $repository->all( - $vendor, - $package, + $commitRepository->all( + $owner, + $repository, [ 'sha' => $sha, 'per_page' => $perPage, @@ -192,30 +192,30 @@ public function testAllReturnsArrayOfCommitEntities() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $sha = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); $expectedItems = $this->commitItems(15); - $api + $commitApi ->expects($this->once()) ->method('all') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->arrayHasKeyAndValue('sha', $sha) ) ->willReturn($this->responseFromItems($expectedItems)) ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $commits = $repository->all( - $vendor, - $package, [ + $commits = $commitRepository->all( + $owner, + $repository, [ 'sha' => $sha, ] ); @@ -240,24 +240,24 @@ public function testItemsDoesNotFetchCommitsIfStartAndEndReferencesAreTheSame() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $startReference = $faker->sha1; $endReference = $startReference; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); - $api + $commitApi ->expects($this->never()) ->method($this->anything()) ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $commits = $repository->items( - $vendor, - $package, + $commits = $commitRepository->items( + $owner, + $repository, $startReference, $endReference ); @@ -269,34 +269,34 @@ public function testItemsDoesNotFetchCommitsIfStartCommitCouldNotBeFound() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $startReference = $faker->sha1; $endReference = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); - $api + $commitApi ->expects($this->at(0)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($startReference) ) ->willReturn(null) ; - $api + $commitApi ->expects($this->never()) ->method('all') ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $commits = $repository->items( - $vendor, - $package, + $commits = $commitRepository->items( + $owner, + $repository, $startReference, $endReference ); @@ -308,45 +308,45 @@ public function testItemsDoesNotFetchCommitsIfEndCommitCouldNotBeFound() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $startReference = $faker->sha1; $endReference = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); - $api + $commitApi ->expects($this->at(0)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($startReference) ) ->willReturn($this->response($this->commitItem())) ; - $api + $commitApi ->expects($this->at(1)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($endReference) ) ->willReturn(null) ; - $api + $commitApi ->expects($this->never()) ->method('all') ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $commits = $repository->items( - $vendor, - $package, + $commits = $commitRepository->items( + $owner, + $repository, $startReference, $endReference ); @@ -358,21 +358,21 @@ public function testItemsFetchesCommitsUsingShaFromEndCommit() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $startReference = $faker->sha1; $endReference = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); $startCommit = $this->commitItem(); - $api + $commitApi ->expects($this->at(0)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($startReference) ) ->willReturn($this->response($startCommit)) @@ -380,32 +380,32 @@ public function testItemsFetchesCommitsUsingShaFromEndCommit() $endCommit = $this->commitItem(); - $api + $commitApi ->expects($this->at(1)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($endReference) ) ->willReturn($this->response($endCommit)) ; - $api + $commitApi ->expects($this->once()) ->method('all') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->arrayHasKeyAndValue('sha', $endCommit->sha) ) ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $repository->items( - $vendor, - $package, + $commitRepository->items( + $owner, + $repository, $startReference, $endReference ); @@ -415,22 +415,22 @@ public function testItemsReturnsArrayOfCommitsFromStartToEndExcludingStart() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $startReference = $faker->sha1; $endReference = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); $startCommit = $this->commitItem(); $startCommit->sha = 'start'; - $api + $commitApi ->expects($this->at(0)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($startReference) ) ->willReturn($this->response($startCommit)) @@ -439,12 +439,12 @@ public function testItemsReturnsArrayOfCommitsFromStartToEndExcludingStart() $endCommit = $this->commitItem(); $endCommit->sha = 'end'; - $api + $commitApi ->expects($this->at(1)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($endReference) ) ->willReturn($this->response($endCommit)) @@ -470,22 +470,22 @@ public function testItemsReturnsArrayOfCommitsFromStartToEndExcludingStart() $countBetween + 1 // We want the commits in-between and the last commit ); - $api + $commitApi ->expects($this->once()) ->method('all') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->arrayHasKeyAndValue('sha', $endCommit->sha) ) ->willReturn($this->responseFromItems($segment)) ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $commits = $repository->items( - $vendor, - $package, + $commits = $commitRepository->items( + $owner, + $repository, $startReference, $endReference ); @@ -507,22 +507,22 @@ public function testItemsFetchesMoreCommitsIfEndIsNotContainedInFirstBatch() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $startReference = $faker->sha1; $endReference = $faker->sha1; - $api = $this->commitApi(); + $commitApi = $this->commitApi(); $startCommit = $this->commitItem(); $startCommit->sha = 'start'; - $api + $commitApi ->expects($this->at(0)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($startReference) ) ->willReturn($this->response($startCommit)) @@ -531,12 +531,12 @@ public function testItemsFetchesMoreCommitsIfEndIsNotContainedInFirstBatch() $endCommit = $this->commitItem(); $endCommit->sha = 'end'; - $api + $commitApi ->expects($this->at(1)) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($endReference) ) ->willReturn($this->response($endCommit)) @@ -576,33 +576,33 @@ public function testItemsFetchesMoreCommitsIfEndIsNotContainedInFirstBatch() $firstSegment ); - $api + $commitApi ->expects($this->at(2)) ->method('all') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->arrayHasKeyAndValue('sha', $endCommit->sha) ) ->willReturn($this->responseFromItems($firstSegment)) ; - $api + $commitApi ->expects($this->at(3)) ->method('all') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->arrayHasKeyAndValue('sha', $firstCommitFromFirstSegment->sha) ) ->willReturn($this->responseFromItems($secondSegment)) ; - $repository = new Repository\CommitRepository($api); + $commitRepository = new Repository\CommitRepository($commitApi); - $commits = $repository->items( - $vendor, - $package, + $commits = $commitRepository->items( + $owner, + $repository, $startReference, $endReference ); diff --git a/tests/Repository/PullRequestRepositoryTest.php b/tests/Repository/PullRequestRepositoryTest.php index 069b5c3a..b60c1fc2 100644 --- a/tests/Repository/PullRequestRepositoryTest.php +++ b/tests/Repository/PullRequestRepositoryTest.php @@ -248,8 +248,8 @@ public function testItemsHandlesMergeCommitWherePullRequestWasNotFound() { $faker = $this->faker(); - $vendor = $faker->userName; - $package = $faker->slug(); + $owner = $faker->userName; + $repository = $faker->slug(); $startReference = $faker->sha1; $endReference = $faker->sha1; @@ -269,8 +269,8 @@ public function testItemsHandlesMergeCommitWherePullRequestWasNotFound() ->expects($this->once()) ->method('items') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($startReference), $this->equalTo($endReference) ) @@ -279,27 +279,27 @@ public function testItemsHandlesMergeCommitWherePullRequestWasNotFound() ]) ; - $api = $this->pullRequestApi(); + $pullRequestApi = $this->pullRequestApi(); - $api + $pullRequestApi ->expects($this->once()) ->method('show') ->with( - $this->equalTo($vendor), - $this->equalTo($package), + $this->equalTo($owner), + $this->equalTo($repository), $this->equalTo($id) ) ->willReturn(null) ; - $repository = new Repository\PullRequestRepository( - $api, + $pullRequestRepository = new Repository\PullRequestRepository( + $pullRequestApi, $commitRepository ); - $pullRequests = $repository->items( - $vendor, - $package, + $pullRequests = $pullRequestRepository->items( + $owner, + $repository, $startReference, $endReference );