From f4de7edc380b7f3cf5204b42f56bc8753f111480 Mon Sep 17 00:00:00 2001 From: Johan Janssens Date: Wed, 27 May 2015 01:20:31 +0200 Subject: [PATCH] #71 : Remove JGithub library --- libraries/joomla/github/account.php | 254 ---- libraries/joomla/github/commits.php | 377 ------ libraries/joomla/github/forks.php | 98 -- libraries/joomla/github/github.php | 155 --- libraries/joomla/github/hooks.php | 239 ---- libraries/joomla/github/http.php | 58 - libraries/joomla/github/index.html | 1 - libraries/joomla/github/meta.php | 59 - libraries/joomla/github/milestones.php | 240 ---- libraries/joomla/github/object.php | 125 -- libraries/joomla/github/package.php | 59 - libraries/joomla/github/package/activity.php | 30 - .../joomla/github/package/activity/events.php | 215 --- .../github/package/activity/notifications.php | 272 ---- .../github/package/activity/starring.php | 147 --- .../github/package/activity/watching.php | 215 --- .../joomla/github/package/authorization.php | 335 ----- libraries/joomla/github/package/data.php | 59 - .../joomla/github/package/data/blobs.php | 71 - .../joomla/github/package/data/commits.php | 74 -- libraries/joomla/github/package/data/refs.php | 192 --- libraries/joomla/github/package/data/tags.php | 89 -- .../joomla/github/package/data/trees.php | 117 -- libraries/joomla/github/package/gists.php | 549 -------- .../joomla/github/package/gists/comments.php | 183 --- libraries/joomla/github/package/gitignore.php | 82 -- libraries/joomla/github/package/issues.php | 514 -------- .../github/package/issues/assignees.php | 84 -- .../joomla/github/package/issues/comments.php | 209 --- .../joomla/github/package/issues/events.php | 90 -- .../joomla/github/package/issues/labels.php | 301 ----- .../github/package/issues/milestones.php | 237 ---- libraries/joomla/github/package/markdown.php | 74 -- libraries/joomla/github/package/orgs.php | 114 -- .../joomla/github/package/orgs/members.php | 236 ---- .../joomla/github/package/orgs/teams.php | 393 ------ libraries/joomla/github/package/pulls.php | 513 -------- .../joomla/github/package/pulls/comments.php | 197 --- .../joomla/github/package/repositories.php | 433 ------ .../package/repositories/collaborators.php | 125 -- .../github/package/repositories/comments.php | 179 --- .../github/package/repositories/commits.php | 122 -- .../github/package/repositories/contents.php | 206 --- .../github/package/repositories/downloads.php | 202 --- .../github/package/repositories/forks.php | 96 -- .../github/package/repositories/hooks.php | 227 ---- .../github/package/repositories/keys.php | 143 -- .../github/package/repositories/merging.php | 91 -- .../package/repositories/statistics.php | 175 --- .../github/package/repositories/statuses.php | 108 -- libraries/joomla/github/package/search.php | 132 -- libraries/joomla/github/package/users.php | 184 --- .../joomla/github/package/users/emails.php | 92 -- .../joomla/github/package/users/followers.php | 145 -- .../joomla/github/package/users/keys.php | 155 --- libraries/joomla/github/refs.php | 175 --- libraries/joomla/github/statuses.php | 107 -- .../joomla/github/JGithubAccountTest.php | 480 ------- .../joomla/github/JGithubCommitsTest.php | 627 --------- .../joomla/github/JGithubForksTest.php | 169 --- .../joomla/github/JGithubGistsTest.php | 1171 ----------------- .../joomla/github/JGithubHooksTest.php | 442 ------- .../joomla/github/JGithubHttpTest.php | 91 -- .../joomla/github/JGithubIssuesTest.php | 777 ----------- .../joomla/github/JGithubMetaTest.php | 123 -- .../joomla/github/JGithubMilestonesTest.php | 365 ----- .../joomla/github/JGithubObjectTest.php | 132 -- .../github/JGithubPackageActivityTest.php | 59 - .../JGithubPackageAuthorizationsTest.php | 557 -------- .../joomla/github/JGithubPackageGistsTest.php | 1168 ---------------- .../github/JGithubPackageGitignoreTest.php | 184 --- .../github/JGithubPackageIssuesTest.php | 794 ----------- .../github/JGithubPackageMarkdownTest.php | 124 -- .../joomla/github/JGithubPackageOrgsTest.php | 120 -- .../joomla/github/JGithubPackagePullsTest.php | 818 ------------ .../github/JGithubPackageRepositoriesTest.php | 410 ------ .../github/JGithubPackageSearchTest.php | 155 --- .../joomla/github/JGithubPackageUsersTest.php | 361 ----- .../joomla/github/JGithubPullsTest.php | 782 ----------- .../joomla/github/JGithubRefsTest.php | 274 ---- .../joomla/github/JGithubStatusesTest.php | 176 --- .../libraries/joomla/github/JGithubTest.php | 285 ---- .../joomla/github/JGithubUsersTest.php | 237 ---- .../JGithubPackageActivityEventsTest.php | 349 ----- ...GithubPackageActivityNotificationsTest.php | 415 ------ .../JGithubPackageActivityStarringTest.php | 270 ---- .../JGithubPackageActivityWatchingTest.php | 360 ----- .../data/JGithubPackageDataBlobsTest.php | 132 -- .../data/JGithubPackageDataCommitsTest.php | 157 --- .../data/JGithubPackageDataRefsTest.php | 314 ----- .../data/JGithubPackageDataTagsTest.php | 137 -- .../data/JGithubPackageDataTreesTest.php | 173 --- .../JGithubPackageIssuesAssigneesTest.php | 161 --- .../JGithubPackageIssuesCommentsTest.php | 345 ----- .../issues/JGithubPackageIssuesEventsTest.php | 148 --- .../issues/JGithubPackageIssuesLabelsTest.php | 473 ------- .../JGithubPackageIssuesMilestonesTest.php | 365 ----- .../orgs/JGithubPackageOrgsMembersTest.php | 346 ----- .../orgs/JGithubPackageOrgsTeamsTest.php | 432 ------ .../pulls/JGithubPackagePullsCommentsTest.php | 176 --- ...ubPackageRepositoriesCollaboratorsTest.php | 182 --- ...JGithubPackageRepositoriesCommentsTest.php | 180 --- ...JGithubPackageRepositoriesContentsTest.php | 195 --- ...GithubPackageRepositoriesDownloadsTest.php | 160 --- .../JGithubPackageRepositoriesForksTest.php | 169 --- .../JGithubPackageRepositoriesHooksTest.php | 470 ------- .../JGithubPackageRepositoriesKeysTest.php | 250 ---- .../JGithubPackageRepositoriesMergingTest.php | 265 ---- ...JGithubPackageRepositoriesStatusesTest.php | 199 --- .../joomla/github/stubs/JGithubObjectMock.php | 37 - .../libraries/joomla/github/stubs/gittest | 1 - .../users/JGithubPackageUsersEmailsTest.php | 120 -- .../JGithubPackageUsersFollowersTest.php | 242 ---- .../users/JGithubPackageUsersKeysTest.php | 180 --- 114 files changed, 28638 deletions(-) delete mode 100644 libraries/joomla/github/account.php delete mode 100644 libraries/joomla/github/commits.php delete mode 100644 libraries/joomla/github/forks.php delete mode 100644 libraries/joomla/github/github.php delete mode 100644 libraries/joomla/github/hooks.php delete mode 100644 libraries/joomla/github/http.php delete mode 100644 libraries/joomla/github/index.html delete mode 100644 libraries/joomla/github/meta.php delete mode 100644 libraries/joomla/github/milestones.php delete mode 100644 libraries/joomla/github/object.php delete mode 100644 libraries/joomla/github/package.php delete mode 100644 libraries/joomla/github/package/activity.php delete mode 100644 libraries/joomla/github/package/activity/events.php delete mode 100644 libraries/joomla/github/package/activity/notifications.php delete mode 100644 libraries/joomla/github/package/activity/starring.php delete mode 100644 libraries/joomla/github/package/activity/watching.php delete mode 100644 libraries/joomla/github/package/authorization.php delete mode 100644 libraries/joomla/github/package/data.php delete mode 100644 libraries/joomla/github/package/data/blobs.php delete mode 100644 libraries/joomla/github/package/data/commits.php delete mode 100644 libraries/joomla/github/package/data/refs.php delete mode 100644 libraries/joomla/github/package/data/tags.php delete mode 100644 libraries/joomla/github/package/data/trees.php delete mode 100644 libraries/joomla/github/package/gists.php delete mode 100644 libraries/joomla/github/package/gists/comments.php delete mode 100644 libraries/joomla/github/package/gitignore.php delete mode 100644 libraries/joomla/github/package/issues.php delete mode 100644 libraries/joomla/github/package/issues/assignees.php delete mode 100644 libraries/joomla/github/package/issues/comments.php delete mode 100644 libraries/joomla/github/package/issues/events.php delete mode 100644 libraries/joomla/github/package/issues/labels.php delete mode 100644 libraries/joomla/github/package/issues/milestones.php delete mode 100644 libraries/joomla/github/package/markdown.php delete mode 100644 libraries/joomla/github/package/orgs.php delete mode 100644 libraries/joomla/github/package/orgs/members.php delete mode 100644 libraries/joomla/github/package/orgs/teams.php delete mode 100644 libraries/joomla/github/package/pulls.php delete mode 100644 libraries/joomla/github/package/pulls/comments.php delete mode 100644 libraries/joomla/github/package/repositories.php delete mode 100644 libraries/joomla/github/package/repositories/collaborators.php delete mode 100644 libraries/joomla/github/package/repositories/comments.php delete mode 100644 libraries/joomla/github/package/repositories/commits.php delete mode 100644 libraries/joomla/github/package/repositories/contents.php delete mode 100644 libraries/joomla/github/package/repositories/downloads.php delete mode 100644 libraries/joomla/github/package/repositories/forks.php delete mode 100644 libraries/joomla/github/package/repositories/hooks.php delete mode 100644 libraries/joomla/github/package/repositories/keys.php delete mode 100644 libraries/joomla/github/package/repositories/merging.php delete mode 100644 libraries/joomla/github/package/repositories/statistics.php delete mode 100644 libraries/joomla/github/package/repositories/statuses.php delete mode 100644 libraries/joomla/github/package/search.php delete mode 100644 libraries/joomla/github/package/users.php delete mode 100644 libraries/joomla/github/package/users/emails.php delete mode 100644 libraries/joomla/github/package/users/followers.php delete mode 100644 libraries/joomla/github/package/users/keys.php delete mode 100644 libraries/joomla/github/refs.php delete mode 100644 libraries/joomla/github/statuses.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubAccountTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubCommitsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubForksTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubGistsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubHooksTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubHttpTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubIssuesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubMetaTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubMilestonesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubObjectTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageActivityTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageAuthorizationsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageGistsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageGitignoreTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageIssuesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageMarkdownTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageOrgsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackagePullsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageRepositoriesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageSearchTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPackageUsersTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubPullsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubRefsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubStatusesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/JGithubUsersTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityEventsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityNotificationsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityStarringTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityWatchingTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataBlobsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataCommitsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataRefsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataTagsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataTreesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesAssigneesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesCommentsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesEventsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesLabelsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesMilestonesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/orgs/JGithubPackageOrgsMembersTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/orgs/JGithubPackageOrgsTeamsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/pulls/JGithubPackagePullsCommentsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesCollaboratorsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesCommentsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesContentsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesDownloadsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesForksTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesHooksTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesKeysTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesMergingTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesStatusesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/stubs/JGithubObjectMock.php delete mode 100644 tests/unit/suites/libraries/joomla/github/stubs/gittest delete mode 100644 tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersEmailsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersFollowersTest.php delete mode 100644 tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersKeysTest.php diff --git a/libraries/joomla/github/account.php b/libraries/joomla/github/account.php deleted file mode 100644 index 63a17943d2..0000000000 --- a/libraries/joomla/github/account.php +++ /dev/null @@ -1,254 +0,0 @@ -create() - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function createAuthorisation(array $scopes = array(), $note = '', $url = '') - { - // Build the request path. - $path = '/authorizations'; - - $data = json_encode( - array('scopes' => $scopes, 'note' => $note, 'note_url' => $url) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to delete an authorisation - * - * @param integer $id ID of the authorisation to delete - * - * @deprecated use authorization->delete() - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function deleteAuthorisation($id) - { - // Build the request path. - $path = '/authorizations/' . $id; - - // Send the request. - $response = $this->client->delete($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to edit an authorisation. - * - * @param integer $id ID of the authorisation to edit - * @param array $scopes Replaces the authorisation scopes with these. - * @param array $addScopes A list of scopes to add to this authorisation. - * @param array $removeScopes A list of scopes to remove from this authorisation. - * @param string $note A note to remind you what the OAuth token is for. - * @param string $url A URL to remind you what app the OAuth token is for. - * - * @deprecated use authorization->edit() - * - * @return object - * - * @since 12.3 - * @throws DomainException - * @throws RuntimeException - */ - public function editAuthorisation($id, array $scopes = array(), array $addScopes = array(), array $removeScopes = array(), $note = '', $url = '') - { - // Check if more than one scopes array contains data - $scopesCount = 0; - - if (!empty($scopes)) - { - $scope = 'scopes'; - $scopeData = $scopes; - $scopesCount++; - } - - if (!empty($addScopes)) - { - $scope = 'add_scopes'; - $scopeData = $addScopes; - $scopesCount++; - } - - if (!empty($removeScopes)) - { - $scope = 'remove_scopes'; - $scopeData = $removeScopes; - $scopesCount++; - } - - // Only allowed to send data for one scope parameter - if ($scopesCount >= 2) - { - throw new RuntimeException('You can only send one scope key in this request.'); - } - - // Build the request path. - $path = '/authorizations/' . $id; - - $data = json_encode( - array( - $scope => $scopeData, - 'note' => $note, - 'note_url' => $url - ) - ); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get details about an authorised application for the authenticated user. - * - * @param integer $id ID of the authorisation to retrieve - * - * @deprecated use authorization->get() - * - * @return object - * - * @since 12.3 - * @note This method will only accept Basic Authentication - * @throws DomainException - */ - public function getAuthorisation($id) - { - // Build the request path. - $path = '/authorizations/' . $id; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get the authorised applications for the authenticated user. - * - * @deprecated use authorization->getList() - * - * @return object - * - * @since 12.3 - * @throws DomainException - * @note This method will only accept Basic Authentication - */ - public function getAuthorisations() - { - // Build the request path. - $path = '/authorizations'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get the rate limit for the authenticated user. - * - * @deprecated use authorization->getRateLimit() - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function getRateLimit() - { - // Build the request path. - $path = '/rate_limit'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/github/commits.php b/libraries/joomla/github/commits.php deleted file mode 100644 index d0adec4d97..0000000000 --- a/libraries/joomla/github/commits.php +++ /dev/null @@ -1,377 +0,0 @@ -commits->create() - * - * @return object - * - * @since 12.1 - */ - public function create($user, $repo, $message, $tree, array $parents = array()) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/git/commits'; - - $data = json_encode( - array('message' => $message, 'tree' => $tree, 'parents' => $parents) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to create a comment on a commit. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha The SHA of the commit to comment on. - * @param string $comment The text of the comment. - * @param integer $line The line number of the commit to comment on. - * @param string $filepath A relative path to the file to comment on within the commit. - * @param integer $position Line index in the diff to comment on. - * - * @deprecated use repositories->comments->create() - * - * @return object - * - * @since 12.1 - */ - public function createCommitComment($user, $repo, $sha, $comment, $line, $filepath, $position) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha . '/comments'; - - $data = json_encode( - array( - 'body' => $comment, - 'commit_id' => $sha, - 'line' => (int) $line, - 'path' => $filepath, - 'position' => (int) $position - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to delete a comment on a commit. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $id The ID of the comment to edit. - * - * @deprecated use repositories->comments->delete() - * - * @return object - * - * @since 12.1 - */ - public function deleteCommitComment($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/comments/' . $id; - - // Send the request. - $response = $this->client->delete($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to edit a comment on a commit. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $id The ID of the comment to edit. - * @param string $comment The text of the comment. - * - * @deprecated use repositories->comments->edit() - * - * @return object - * - * @since 12.1 - */ - public function editCommitComment($user, $repo, $id, $comment) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/comments/' . $id; - - $data = json_encode( - array( - 'body' => $comment - ) - ); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a single commit for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha The SHA of the commit to retrieve. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @deprecated use repositories->commits->get() - * - * @return array - * - * @since 12.1 - */ - public function getCommit($user, $repo, $sha, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a single comment on a commit. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the comment to retrieve - * - * @deprecated use repositories->comments->get() - * - * @return array - * - * @since 12.1 - */ - public function getCommitComment($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/comments/' . $id; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a list of comments for a single commit for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha The SHA of the commit to retrieve. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @deprecated use repositories->comments->getList() - * - * @return array - * - * @since 12.1 - */ - public function getCommitComments($user, $repo, $sha, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha . '/comments'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a diff for two commits. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $base The base of the diff, either a commit SHA or branch. - * @param string $head The head of the diff, either a commit SHA or branch. - * - * @deprecated use repositories->commits->compare() - * - * @return array - * - * @since 12.1 - */ - public function getDiff($user, $repo, $base, $head) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/compare/' . $base . '...' . $head; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list commits for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @deprecated use repositories->commits->getList() - * - * @return array - * - * @since 12.1 - */ - public function getList($user, $repo, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/commits'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a list of commit comments for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @deprecated use repositories->comments->getListRepository() - * - * @return array - * - * @since 12.1 - */ - public function getListComments($user, $repo, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/comments'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/github/forks.php b/libraries/joomla/github/forks.php deleted file mode 100644 index 62a904d6e9..0000000000 --- a/libraries/joomla/github/forks.php +++ /dev/null @@ -1,98 +0,0 @@ -forks->create() - * - * @return object - * - * @since 11.4 - * @throws DomainException - */ - public function create($user, $repo, $org = '') - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/forks'; - - if (strlen($org) > 0) - { - $data = json_encode( - array('org' => $org) - ); - } - else - { - $data = json_encode(array()); - } - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 202) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list forks for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @deprecated use repositories->forks->getList() - * - * @return array - * - * @since 11.4 - * @throws DomainException - */ - public function getList($user, $repo, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/forks'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/github/github.php b/libraries/joomla/github/github.php deleted file mode 100644 index 5cd42402c1..0000000000 --- a/libraries/joomla/github/github.php +++ /dev/null @@ -1,155 +0,0 @@ -options = isset($options) ? $options : new JRegistry; - $this->client = isset($client) ? $client : new JGithubHttp($this->options); - - // Setup the default API url if not already set. - $this->options->def('api.url', 'https://api.github.com'); - } - - /** - * Magic method to lazily create API objects - * - * @param string $name Name of property to retrieve - * - * @throws RuntimeException - * - * @since 11.3 - * @return JGithubObject GitHub API object (gists, issues, pulls, etc). - */ - public function __get($name) - { - if (false == in_array($name, $this->packages)) - { - // Check for a legacy class - if (in_array($name, $this->legacyPackages)) - { - if (false == isset($this->$name)) - { - $className = 'JGithub' . ucfirst($name); - - $this->$name = new $className($this->options, $this->client); - } - - return $this->$name; - } - - throw new RuntimeException(sprintf('%1$s - Unknown package %2$s', __METHOD__, $name)); - } - - if (false == isset($this->$name)) - { - $className = 'JGithubPackage' . ucfirst($name); - - $this->$name = new $className($this->options, $this->client); - } - - return $this->$name; - } - - /** - * Get an option from the JGitHub instance. - * - * @param string $key The name of the option to get. - * - * @return mixed The option value. - * - * @since 11.3 - */ - public function getOption($key) - { - return $this->options->get($key); - } - - /** - * Set an option for the JGitHub instance. - * - * @param string $key The name of the option to set. - * @param mixed $value The option value to set. - * - * @return JGitHub This object for method chaining. - * - * @since 11.3 - */ - public function setOption($key, $value) - { - $this->options->set($key, $value); - - return $this; - } -} diff --git a/libraries/joomla/github/hooks.php b/libraries/joomla/github/hooks.php deleted file mode 100644 index b04689d1a8..0000000000 --- a/libraries/joomla/github/hooks.php +++ /dev/null @@ -1,239 +0,0 @@ -hooks->create() - * - * @return object - * - * @since 12.3 - * @throws DomainException - * @throws RuntimeException - */ - public function create($user, $repo, $name, array $config, array $events = array('push'), $active = true) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks'; - - // Check to ensure all events are in the allowed list - foreach ($events as $event) - { - if (!in_array($event, $this->events)) - { - throw new RuntimeException('Your events array contains an unauthorized event.'); - } - } - - $data = json_encode( - array('name' => $name, 'config' => $config, 'events' => $events, 'active' => $active) - ); - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } - - /** - * Method to delete a hook - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the hook to delete. - * - * @deprecated use repositories->hooks->delete() - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function delete($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * Method to edit a hook. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the hook to edit. - * @param string $name The name of the service being called. - * @param array $config Array containing the config for the service. - * @param array $events The events the hook will be triggered for. This resets the currently set list - * @param array $addEvents Events to add to the hook. - * @param array $removeEvents Events to remove from the hook. - * @param boolean $active Flag to determine if the hook is active - * - * @deprecated use repositories->hooks->edit() - * - * @return object - * - * @since 12.3 - * @throws DomainException - * @throws RuntimeException - */ - public function edit($user, $repo, $id, $name, array $config, array $events = array('push'), array $addEvents = array(), - array $removeEvents = array(), $active = true) - { - // Check to ensure all events are in the allowed list - foreach ($events as $event) - { - if (!in_array($event, $this->events)) - { - throw new RuntimeException('Your events array contains an unauthorized event.'); - } - } - - foreach ($addEvents as $event) - { - if (!in_array($event, $this->events)) - { - throw new RuntimeException('Your active_events array contains an unauthorized event.'); - } - } - - foreach ($removeEvents as $event) - { - if (!in_array($event, $this->events)) - { - throw new RuntimeException('Your remove_events array contains an unauthorized event.'); - } - } - - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id; - - $data = json_encode( - array( - 'name' => $name, - 'config' => $config, - 'events' => $events, - 'add_events' => $addEvents, - 'remove_events' => $removeEvents, - 'active' => $active) - ); - - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), $data) - ); - } - - /** - * Method to get details about a single hook for the repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the hook to retrieve - * - * @deprecated use repositories->hooks->get() - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function get($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to list hooks for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @deprecated use repositories->hooks->getList() - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function getList($user, $repo, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to test a hook against the latest repository commit - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the hook to delete - * - * @deprecated use repositories->hooks->test() - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function test($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id . '/test'; - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode('')), - 204 - ); - } -} diff --git a/libraries/joomla/github/http.php b/libraries/joomla/github/http.php deleted file mode 100644 index e6406c3330..0000000000 --- a/libraries/joomla/github/http.php +++ /dev/null @@ -1,58 +0,0 @@ -options->def('userAgent', 'JGitHub/2.0'); - - // Set the default timeout to 120 seconds. - $this->options->def('timeout', 120); - } -} diff --git a/libraries/joomla/github/index.html b/libraries/joomla/github/index.html deleted file mode 100644 index 2efb97f319..0000000000 --- a/libraries/joomla/github/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/joomla/github/meta.php b/libraries/joomla/github/meta.php deleted file mode 100644 index b4a6f0bd82..0000000000 --- a/libraries/joomla/github/meta.php +++ /dev/null @@ -1,59 +0,0 @@ -processResponse($this->client->get($this->fetchUrl($path)), 200); - - /* - * The response body returns the IP addresses in CIDR format - * Decode the response body and strip the subnet mask information prior to - * returning the data to the user. We're assuming quite a bit here that all - * masks will be /32 as they are as of the time of development. - */ - - $authorizedIps = array(); - - foreach ($githubIps as $key => $serviceIps) - { - // The first level contains an array of IPs based on the service - $authorizedIps[$key] = array(); - - foreach ($serviceIps as $serviceIp) - { - // The second level is each individual IP address, strip the mask here - $authorizedIps[$key][] = substr($serviceIp, 0, -3); - } - } - - return $authorizedIps; - } -} diff --git a/libraries/joomla/github/milestones.php b/libraries/joomla/github/milestones.php deleted file mode 100644 index 093b9b7618..0000000000 --- a/libraries/joomla/github/milestones.php +++ /dev/null @@ -1,240 +0,0 @@ -milestones->getList() - * - * @return array - * - * @since 12.3 - */ - public function getList($user, $repo, $state = 'open', $sort = 'due_date', $direction = 'desc', $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones?'; - - $path .= 'state=' . $state; - $path .= '&sort=' . $sort; - $path .= '&direction=' . $direction; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a specific milestone. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $milestoneId The milestone id to get. - * - * @deprecated use issues->milestones->get() - * - * @return object - * - * @since 12.3 - */ - public function get($user, $repo, $milestoneId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones/' . (int) $milestoneId; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to create a milestone for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $title The title of the milestone. - * @param string $state Can be open (default) or closed. - * @param string $description Optional description for milestone. - * @param string $due_on Optional ISO 8601 time. - * - * @deprecated use issues->milestones->create() - * - * @return object - * - * @since 12.3 - */ - public function create($user, $repo, $title, $state = null, $description = null, $due_on = null) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones'; - - // Build the request data. - $data = array( - 'title' => $title - ); - - if (!is_null($state)) - { - $data['state'] = $state; - } - - if (!is_null($description)) - { - $data['description'] = $description; - } - - if (!is_null($due_on)) - { - $data['due_on'] = $due_on; - } - - $data = json_encode($data); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to update a milestone. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $milestoneId The id of the comment to update. - * @param integer $title Optional title of the milestone. - * @param string $state Can be open (default) or closed. - * @param string $description Optional description for milestone. - * @param string $due_on Optional ISO 8601 time. - * - * @deprecated use issues->milestones->edit() - * - * @return object - * - * @since 12.3 - */ - public function edit($user, $repo, $milestoneId, $title = null, $state = null, $description = null, $due_on = null) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones/' . (int) $milestoneId; - - // Build the request data. - $data = array(); - - if (!is_null($title)) - { - $data['title'] = $title; - } - - if (!is_null($state)) - { - $data['state'] = $state; - } - - if (!is_null($description)) - { - $data['description'] = $description; - } - - if (!is_null($due_on)) - { - $data['due_on'] = $due_on; - } - - $data = json_encode($data); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to delete a milestone. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $milestoneId The id of the milestone to delete. - * - * @deprecated use issues->milestones->delete() - * - * @return void - * - * @since 12.3 - */ - public function delete($user, $repo, $milestoneId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones/' . (int) $milestoneId; - - // Send the request. - $response = $this->client->delete($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - } -} diff --git a/libraries/joomla/github/object.php b/libraries/joomla/github/object.php deleted file mode 100644 index a1a80f8fe0..0000000000 --- a/libraries/joomla/github/object.php +++ /dev/null @@ -1,125 +0,0 @@ -options = isset($options) ? $options : new JRegistry; - $this->client = isset($client) ? $client : new JGithubHttp($this->options); - } - - /** - * Method to build and return a full request URL for the request. This method will - * add appropriate pagination details if necessary and also prepend the API url - * to have a complete URL for the request. - * - * @param string $path URL to inflect - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @return string The request URL. - * - * @since 11.3 - */ - protected function fetchUrl($path, $page = 0, $limit = 0) - { - // Get a new JUri object fousing the api url and given path. - $uri = new JUri($this->options->get('api.url') . $path); - - if ($this->options->get('gh.token', false)) - { - // Use oAuth authentication - @todo set in request header ? - $uri->setVar('access_token', $this->options->get('gh.token')); - } - else - { - // Use basic authentication - if ($this->options->get('api.username', false)) - { - $uri->setUser($this->options->get('api.username')); - } - - if ($this->options->get('api.password', false)) - { - $uri->setPass($this->options->get('api.password')); - } - } - - // If we have a defined page number add it to the JUri object. - if ($page > 0) - { - $uri->setVar('page', (int) $page); - } - - // If we have a defined items per page add it to the JUri object. - if ($limit > 0) - { - $uri->setVar('per_page', (int) $limit); - } - - return (string) $uri; - } - - /** - * Process the response and decode it. - * - * @param JHttpResponse $response The response. - * @param integer $expectedCode The expected "good" code. - * @param boolean $decode If the should be response be JSON decoded. - * - * @throws DomainException - * @since 12.4 - * - * @return mixed - */ - protected function processResponse(JHttpResponse $response, $expectedCode = 200, $decode = true) - { - // Validate the response code. - if ($response->code == $expectedCode) - { - return ($decode) ? json_decode($response->body) : $response->body; - } - - // Decode the error response and throw an exception. - $error = json_decode($response->body); - $message = (isset($error->message)) ? $error->message : 'Error: ' . $response->code; - - throw new DomainException($message, $response->code); - } -} diff --git a/libraries/joomla/github/package.php b/libraries/joomla/github/package.php deleted file mode 100644 index 4f96e43851..0000000000 --- a/libraries/joomla/github/package.php +++ /dev/null @@ -1,59 +0,0 @@ -packages)) - { - throw new RuntimeException(sprintf('%1$s - Unknown package %2$s', __METHOD__, $name)); - } - - if (false == isset($this->$name)) - { - $className = 'JGithubPackage' . ucfirst($this->name) . ucfirst($name); - - $this->$name = new $className($this->options, $this->client); - } - - return $this->$name; - } -} diff --git a/libraries/joomla/github/package/activity.php b/libraries/joomla/github/package/activity.php deleted file mode 100644 index 2796b8f80d..0000000000 --- a/libraries/joomla/github/package/activity.php +++ /dev/null @@ -1,30 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List repository events. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 12.3 - * - * @return object - */ - public function getRepository($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/events'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List issue events for a repository. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 12.3 - * @return object - */ - public function getIssue($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/events'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List public events for a network of repositories. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 12.3 - * @return object - */ - public function getNetwork($owner, $repo) - { - // Build the request path. - $path = '/networks/' . $owner . '/' . $repo . '/events'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List public events for an organization. - * - * @param string $org Organisation. - * - * @since 12.3 - * @return object - */ - public function getOrg($org) - { - // Build the request path. - $path = '/orgs/' . $org . '/events'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List events that a user has received. - * - * These are events that you’ve received by watching repos and following users. - * If you are authenticated as the given user, you will see private events. - * Otherwise, you’ll only see public events. - * - * @param string $user User name. - * - * @since 12.3 - * @return object - */ - public function getUser($user) - { - // Build the request path. - $path = '/users/' . $user . '/received_events'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List public events that a user has received. - * - * @param string $user User name. - * - * @since 12.3 - * @return object - */ - public function getUserPublic($user) - { - // Build the request path. - $path = '/users/' . $user . '/received_events/public'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List events performed by a user. - * - * If you are authenticated as the given user, you will see your private events. - * Otherwise, you’ll only see public events. - * - * @param string $user User name. - * - * @since 12.3 - * @return object - */ - public function getByUser($user) - { - // Build the request path. - $path = '/users/' . $user . '/events'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List public events performed by a user. - * - * @param string $user User name. - * - * @since 12.3 - * @return object - */ - public function getByUserPublic($user) - { - // Build the request path. - $path = '/users/' . $user . '/events/public'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List events for an organization. - * - * This is the user’s organization dashboard. - * You must be authenticated as the user to view this. - * - * @param string $user User name. - * @param string $org Organisation. - * - * @since 12.3 - * @return object - */ - public function getUserOrg($user, $org) - { - // Build the request path. - $path = '/users/' . $user . '/events/orgs/' . $org; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } -} diff --git a/libraries/joomla/github/package/activity/notifications.php b/libraries/joomla/github/package/activity/notifications.php deleted file mode 100644 index 15f424ebb4..0000000000 --- a/libraries/joomla/github/package/activity/notifications.php +++ /dev/null @@ -1,272 +0,0 @@ -toISO8601() : ''; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List your notifications in a repository. - * - * List all notifications for the current user. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * @param boolean $all True to show notifications marked as read. - * @param boolean $participating True to show only notifications in which the user is directly participating or - * mentioned. - * @param JDate $since filters out any notifications updated before the given time. The time should be passed in - * as UTC in the ISO 8601 format. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getListRepository($owner, $repo, $all = true, $participating = true, JDate $since = null) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/notifications?'; - - $path .= ($all) ? '&all=1' : ''; - $path .= ($participating) ? '&participating=1' : ''; - $path .= ($since) ? '&since=' . $since->toISO8601() : ''; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Mark as read. - * - * Marking a notification as “read” removes it from the default view on GitHub.com. - * - * @param boolean $unread Changes the unread status of the threads. - * @param boolean $read Inverse of “unread”. - * @param JDate $last_read_at Describes the last point that notifications were checked. - * Anything updated since this time will not be updated. Default: Now. Expected in ISO 8601 format. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function markRead($unread = true, $read = true, JDate $last_read_at = null) - { - // Build the request path. - $path = '/notifications'; - - $data = array( - 'unread' => $unread, - 'read' => $read - ); - - if ($last_read_at) - { - $data['last_read_at'] = $last_read_at->toISO8601(); - } - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), json_encode($data)), - 205 - ); - } - - /** - * Mark notifications as read in a repository. - * - * Marking all notifications in a repository as “read” removes them from the default view on GitHub.com. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * @param boolean $unread Changes the unread status of the threads. - * @param boolean $read Inverse of “unread”. - * @param JDate $last_read_at Describes the last point that notifications were checked. - * Anything updated since this time will not be updated. Default: Now. Expected in ISO 8601 format. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function markReadRepository($owner, $repo, $unread, $read, JDate $last_read_at = null) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/notifications'; - - $data = array( - 'unread' => $unread, - 'read' => $read - ); - - if ($last_read_at) - { - $data['last_read_at'] = $last_read_at->toISO8601(); - } - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), json_encode($data)), - 205 - ); - } - - /** - * View a single thread. - * - * @param integer $id The thread id. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function viewThread($id) - { - // Build the request path. - $path = '/notifications/threads/' . $id; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Mark a thread as read. - * - * @param integer $id The thread id. - * @param boolean $unread Changes the unread status of the threads. - * @param boolean $read Inverse of “unread”. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function markReadThread($id, $unread = true, $read = true) - { - // Build the request path. - $path = '/notifications/threads/' . $id; - - $data = array( - 'unread' => $unread, - 'read' => $read - ); - - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), json_encode($data)), - 205 - ); - } - - /** - * Get a Thread Subscription. - * - * This checks to see if the current user is subscribed to a thread. - * You can also get a Repository subscription. - * - * @param integer $id The thread id. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getThreadSubscription($id) - { - // Build the request path. - $path = '/notifications/threads/' . $id . '/subscription'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Set a Thread Subscription. - * - * This lets you subscribe to a thread, or ignore it. Subscribing to a thread is unnecessary - * if the user is already subscribed to the repository. Ignoring a thread will mute all - * future notifications (until you comment or get @mentioned). - * - * @param integer $id The thread id. - * @param boolean $subscribed Determines if notifications should be received from this thread. - * @param boolean $ignored Determines if all notifications should be blocked from this thread. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function setThreadSubscription($id, $subscribed, $ignored) - { - // Build the request path. - $path = '/notifications/threads/' . $id . '/subscription'; - - $data = array( - 'subscribed' => $subscribed, - 'ignored' => $ignored - ); - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), json_encode($data)) - ); - } - - /** - * Delete a Thread Subscription. - * - * @param integer $id The thread id. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function deleteThreadSubscription($id) - { - // Build the request path. - $path = '/notifications/threads/' . $id . '/subscription'; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/activity/starring.php b/libraries/joomla/github/package/activity/starring.php deleted file mode 100644 index 0b86b3d027..0000000000 --- a/libraries/joomla/github/package/activity/starring.php +++ /dev/null @@ -1,147 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List repositories being starred. - * - * List repositories being starred by a user. - * - * @param string $user User name. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getRepositories($user = '') - { - // Build the request path. - $path = ($user) - ? '/users' . $user . '/starred' - : '/user/starred'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Check if you are starring a repository. - * - * Requires for the user to be authenticated. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return object - */ - public function check($owner, $repo) - { - // Build the request path. - $path = '/user/starred/' . $owner . '/' . $repo; - - $response = $this->client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case '204' : - // This repository is watched by you. - return true; - break; - - case '404' : - // This repository is not watched by you. - return false; - break; - } - - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - } - - /** - * Star a repository. - * - * Requires for the user to be authenticated. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function star($owner, $repo) - { - // Build the request path. - $path = '/user/starred/' . $owner . '/' . $repo; - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), ''), - 204 - ); - } - - /** - * Unstar a repository. - * - * Requires for the user to be authenticated. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function unstar($owner, $repo) - { - // Build the request path. - $path = '/user/starred/' . $owner . '/' . $repo; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/activity/watching.php b/libraries/joomla/github/package/activity/watching.php deleted file mode 100644 index 2c39e8b4d9..0000000000 --- a/libraries/joomla/github/package/activity/watching.php +++ /dev/null @@ -1,215 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List repositories being watched. - * - * List repositories being watched by a user. - * - * @param string $user User name. - * - * @since 3.3 (CMS) - * - * @return mixed - */ - public function getRepositories($user = '') - { - // Build the request path. - $path = ($user) - ? '/users/' . $user . '/subscriptions' - : '/user/subscriptions'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get a Repository Subscription. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 3.3 (CMS) - * - * @return mixed - */ - public function getSubscription($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/subscription'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Set a Repository Subscription. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * @param boolean $subscribed Determines if notifications should be received from this thread. - * @param boolean $ignored Determines if all notifications should be blocked from this thread. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function setSubscription($owner, $repo, $subscribed, $ignored) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/subscription'; - - $data = array( - 'subscribed' => $subscribed, - 'ignored' => $ignored - ); - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), json_encode($data)) - ); - } - - /** - * Delete a Repository Subscription. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function deleteSubscription($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/subscription'; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * Check if you are watching a repository (LEGACY). - * - * Requires for the user to be authenticated. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return object - */ - public function check($owner, $repo) - { - // Build the request path. - $path = '/user/subscriptions/' . $owner . '/' . $repo; - - $response = $this->client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case '204' : - // This repository is watched by you. - return true; - break; - - case '404' : - // This repository is not watched by you. - return false; - break; - } - - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - } - - /** - * Watch a repository (LEGACY). - * - * Requires for the user to be authenticated. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function watch($owner, $repo) - { - // Build the request path. - $path = '/user/subscriptions/' . $owner . '/' . $repo; - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), ''), - 204 - ); - } - - /** - * Stop watching a repository (LEGACY). - * - * Requires for the user to be authenticated. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function unwatch($owner, $repo) - { - // Build the request path. - $path = '/user/subscriptions/' . $owner . '/' . $repo; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/authorization.php b/libraries/joomla/github/package/authorization.php deleted file mode 100644 index 2c77a2e883..0000000000 --- a/libraries/joomla/github/package/authorization.php +++ /dev/null @@ -1,335 +0,0 @@ - $scopes, 'note' => $note, 'note_url' => $url) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to delete an authorization - * - * @param integer $id ID of the authorization to delete - * - * @throws DomainException - * @since 12.3 - * - * @return object - */ - public function delete($id) - { - // Build the request path. - $path = '/authorizations/' . $id; - - // Send the request. - $response = $this->client->delete($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to edit an authorization. - * - * @param integer $id ID of the authorization to edit - * @param array $scopes Replaces the authorization scopes with these. - * @param array $addScopes A list of scopes to add to this authorization. - * @param array $removeScopes A list of scopes to remove from this authorization. - * @param string $note A note to remind you what the OAuth token is for. - * @param string $url A URL to remind you what app the OAuth token is for. - * - * @throws RuntimeException - * @throws DomainException - * @since 12.3 - * - * @return object - */ - public function edit($id, array $scopes = array(), array $addScopes = array(), array $removeScopes = array(), $note = '', $url = '') - { - // Check if more than one scopes array contains data - $scopesCount = 0; - - if (!empty($scopes)) - { - $scope = 'scopes'; - $scopeData = $scopes; - $scopesCount++; - } - - if (!empty($addScopes)) - { - $scope = 'add_scopes'; - $scopeData = $addScopes; - $scopesCount++; - } - - if (!empty($removeScopes)) - { - $scope = 'remove_scopes'; - $scopeData = $removeScopes; - $scopesCount++; - } - - // Only allowed to send data for one scope parameter - if ($scopesCount >= 2) - { - throw new RuntimeException('You can only send one scope key in this request.'); - } - - // Build the request path. - $path = '/authorizations/' . $id; - - $data = json_encode( - array( - $scope => $scopeData, - 'note' => $note, - 'note_url' => $url - ) - ); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get details about an authorised application for the authenticated user. - * - * @param integer $id ID of the authorization to retrieve - * - * @throws DomainException - * @since 12.3 - * @note This method will only accept Basic Authentication - * - * @return object - */ - public function get($id) - { - // Build the request path. - $path = '/authorizations/' . $id; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get the authorised applications for the authenticated user. - * - * @throws DomainException - * @since 12.3 - * @note This method will only accept Basic Authentication - * - * @return object - */ - public function getList() - { - // Build the request path. - $path = '/authorizations'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get the rate limit for the authenticated user. - * - * @throws DomainException - * @since 12.3 - * - * @return object - */ - public function getRateLimit() - { - // Build the request path. - $path = '/rate_limit'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * 1. Request authorization on GitHub. - * - * @param string $client_id The client ID you received from GitHub when you registered. - * @param string $redirect_uri URL in your app where users will be sent after authorization. - * @param string $scope Comma separated list of scopes. - * @param string $state An unguessable random string. It is used to protect against - * cross-site request forgery attacks. - * - * @since 3.3 (CMS) - * - * @return JUri - */ - public function getAuthorizationLink($client_id, $redirect_uri = '', $scope = '', $state = '') - { - $uri = new JUri('https://github.com/login/oauth/authorize'); - - $uri->setVar('client_id', $client_id); - - if ($redirect_uri) - { - $uri->setVar('redirect_uri', urlencode($redirect_uri)); - } - - if ($scope) - { - $uri->setVar('scope', $scope); - } - - if ($state) - { - $uri->setVar('state', $state); - } - - return (string) $uri; - } - - /** - * 2. Request the access token. - * - * @param string $client_id The client ID you received from GitHub when you registered. - * @param string $client_secret The client secret you received from GitHub when you registered. - * @param string $code The code you received as a response to Step 1. - * @param string $redirect_uri URL in your app where users will be sent after authorization. - * @param string $format The response format (json, xml, ). - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return string - */ - public function requestToken($client_id, $client_secret, $code, $redirect_uri = '', $format = '') - { - $uri = 'https://github.com/login/oauth/access_token'; - - $data = array( - 'client_id' => $client_id, - 'client_secret' => $client_secret, - 'code' => $code - ); - - if ($redirect_uri) - { - $data['redirect_uri'] = $redirect_uri; - } - - $headers = array(); - - switch ($format) - { - case 'json' : - $headers['Accept'] = 'application/json'; - break; - case 'xml' : - $headers['Accept'] = 'application/xml'; - break; - default : - if ($format) - { - throw new UnexpectedValueException('Invalid format'); - } - break; - } - - // Send the request. - return $this->processResponse( - $this->client->post($uri, $data, $headers), - 200, false - ); - } -} diff --git a/libraries/joomla/github/package/data.php b/libraries/joomla/github/package/data.php deleted file mode 100644 index 1855fd2633..0000000000 --- a/libraries/joomla/github/package/data.php +++ /dev/null @@ -1,59 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Create a Blob. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * @param string $content The content of the blob. - * @param string $encoding The encoding to use. - * - * @return object - */ - public function create($owner, $repo, $content, $encoding = 'utf-8') - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/git/blobs'; - - $data = array( - 'content' => $content, - 'encoding' => $encoding - ); - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode($data)), - 201 - ); - } -} diff --git a/libraries/joomla/github/package/data/commits.php b/libraries/joomla/github/package/data/commits.php deleted file mode 100644 index d8859a1f48..0000000000 --- a/libraries/joomla/github/package/data/commits.php +++ /dev/null @@ -1,74 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to create a commit. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $message The commit message. - * @param string $tree SHA of the tree object this commit points to. - * @param array $parents Array of the SHAs of the commits that were the parents of this commit. - * If omitted or empty, the commit will be written as a root commit. - * For a single parent, an array of one SHA should be provided. - * For a merge commit, an array of more than one should be provided. - * - * @throws DomainException - * @since 12.1 - * - * @return object - */ - public function create($owner, $repo, $message, $tree, array $parents = array()) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/git/commits'; - - $data = json_encode( - array('message' => $message, 'tree' => $tree, 'parents' => $parents) - ); - - // Send the request. - return $this->processResponse( - $response = $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } -} diff --git a/libraries/joomla/github/package/data/refs.php b/libraries/joomla/github/package/data/refs.php deleted file mode 100644 index c7b88bfca1..0000000000 --- a/libraries/joomla/github/package/data/refs.php +++ /dev/null @@ -1,192 +0,0 @@ -client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list references for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $namespace Optional sub-namespace to limit the returned references. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @return array - * - * @since 11.3 - */ - public function getList($user, $repo, $namespace = '', $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/git/refs' . $namespace; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to create a ref. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $ref The name of the fully qualified reference. - * @param string $sha The SHA1 value to set this reference to. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function create($user, $repo, $ref, $sha) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/git/refs'; - - // Build the request data. - $data = json_encode( - array( - 'ref' => $ref, - 'sha' => $sha - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to update a reference. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $ref The reference to update. - * @param string $sha The SHA1 value to set the reference to. - * @param boolean $force Whether the update should be forced. Default to false. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function edit($user, $repo, $ref, $sha, $force = false) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/git/refs/' . $ref; - - // Craete the data object. - $data = new stdClass; - - // If a title is set add it to the data object. - if ($force) - { - $data->force = true; - } - - $data->sha = $sha; - - // Encode the request data. - $data = json_encode($data); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Delete a Reference - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $ref The reference to update. - * - * @since 3.3 (CMS) - * @return object - */ - public function delete($owner, $repo, $ref) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/git/refs/' . $ref; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/data/tags.php b/libraries/joomla/github/package/data/tags.php deleted file mode 100644 index ad7eb14e80..0000000000 --- a/libraries/joomla/github/package/data/tags.php +++ /dev/null @@ -1,89 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Create a Tag Object - * - * Note that creating a tag object does not create the reference that makes a tag in Git. - * If you want to create an annotated tag in Git, you have to do this call to create the tag object, - * and then create the refs/tags/[tag] reference. If you want to create a lightweight tag, - * you simply have to create the reference - this call would be unnecessary. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $tag The tag string. - * @param string $message The tag message. - * @param string $object The SHA of the git object this is tagging. - * @param string $type The type of the object we’re tagging. Normally this is a commit - * but it can also be a tree or a blob. - * @param string $tagger_name The name of the author of the tag. - * @param string $tagger_email The email of the author of the tag. - * @param string $tagger_date Timestamp of when this object was tagged. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function create($owner, $repo, $tag, $message, $object, $type, $tagger_name, $tagger_email, $tagger_date) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/git/tags'; - - $data = array( - 'tag' => $tag, - 'message' => $message, - 'object' => $object, - 'type' => $type, - 'tagger_name' => $tagger_name, - 'tagger_email' => $tagger_email, - 'tagger_date' => $tagger_date - ); - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode($data)), - 201 - ); - } -} diff --git a/libraries/joomla/github/package/data/trees.php b/libraries/joomla/github/package/data/trees.php deleted file mode 100644 index d22fec2660..0000000000 --- a/libraries/joomla/github/package/data/trees.php +++ /dev/null @@ -1,117 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get a Tree Recursively - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha The SHA1 value to set the reference to. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getRecursively($owner, $repo, $sha) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/git/trees/' . $sha . '?recursive=1'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Create a Tree. - * - * The tree creation API will take nested entries as well. If both a tree and a nested path - * modifying that tree are specified, it will overwrite the contents of that tree with the - * new path contents and write a new tree out. - * - * Parameters fir the tree: - * - * tree.path - * String of the file referenced in the tree - * tree.mode - * String of the file mode - one of 100644 for file (blob), 100755 for executable (blob), - * 040000 for subdirectory (tree), 160000 for submodule (commit) or 120000 for a blob - * that specifies the path of a symlink - * tree.type - * String of blob, tree, commit - * tree.sha - * String of SHA1 checksum ID of the object in the tree - * tree.content - * String of content you want this file to have - GitHub will write this blob out and use - * that SHA for this entry. Use either this or tree.sha - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param array $tree Array of Hash objects (of path, mode, type and sha) specifying - * a tree structure - * @param string $base_tree The SHA1 of the tree you want to update with new data. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function create($owner, $repo, $tree, $base_tree = '') - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/git/trees'; - - $data = array(); - - $data['tree'] = $tree; - - if ($base_tree) - { - $data['base_tree'] = $base_tree; - } - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode($data)), - 201 - ); - } -} diff --git a/libraries/joomla/github/package/gists.php b/libraries/joomla/github/package/gists.php deleted file mode 100644 index 58d459f588..0000000000 --- a/libraries/joomla/github/package/gists.php +++ /dev/null @@ -1,549 +0,0 @@ - $this->buildFileData((array) $files), - 'public' => (bool) $public, - 'description' => $description - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to delete a gist. - * - * @param integer $gistId The gist number. - * - * @throws DomainException - * @since 11.3 - * - * @return void - */ - public function delete($gistId) - { - // Build the request path. - $path = '/gists/' . (int) $gistId; - - // Send the request. - $response = $this->client->delete($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - } - - /** - * Method to update a gist. - * - * @param integer $gistId The gist number. - * @param mixed $files Either an array of file paths or a single file path as a string. - * @param boolean $public True if the gist should be public. - * @param string $description The description of the gist. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function edit($gistId, $files = null, $public = null, $description = null) - { - // Build the request path. - $path = '/gists/' . (int) $gistId; - - // Craete the data object. - $data = new stdClass; - - // If a description is set add it to the data object. - if (isset($description)) - { - $data->description = $description; - } - - // If the public flag is set add it to the data object. - if (isset($public)) - { - $data->public = $public; - } - - // If a state is set add it to the data object. - if (isset($files)) - { - $data->files = $this->buildFileData((array) $files); - } - - // Encode the request data. - $data = json_encode($data); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to fork a gist. - * - * @param integer $gistId The gist number. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function fork($gistId) - { - // Build the request path. - $path = '/gists/' . (int) $gistId . '/fork'; - - // Send the request. - // TODO: Verify change - $response = $this->client->post($this->fetchUrl($path), ''); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a single gist. - * - * @param integer $gistId The gist number. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function get($gistId) - { - // Build the request path. - $path = '/gists/' . (int) $gistId; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list gists. If a user is authenticated it will return the user's gists, otherwise - * it will return all public gists. - * - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getList($page = 0, $limit = 0) - { - // Build the request path. - $path = '/gists'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a list of gists belonging to a given user. - * - * @param string $user The name of the GitHub user from which to list gists. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getListByUser($user, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/users/' . $user . '/gists'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a list of all public gists. - * - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getListPublic($page = 0, $limit = 0) - { - // Build the request path. - $path = '/gists/public'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a list of the authenticated users' starred gists. - * - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getListStarred($page = 0, $limit = 0) - { - // Build the request path. - $path = '/gists/starred'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to check if a gist has been starred. - * - * @param integer $gistId The gist number. - * - * @throws DomainException - * @since 11.3 - * - * @return boolean True if the gist is starred. - */ - public function isStarred($gistId) - { - // Build the request path. - $path = '/gists/' . (int) $gistId . '/star'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code == 204) - { - return true; - } - elseif ($response->code == 404) - { - return false; - } - else - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - } - - /** - * Method to star a gist. - * - * @param integer $gistId The gist number. - * - * @throws DomainException - * @since 11.3 - * - * @return void - */ - public function star($gistId) - { - // Build the request path. - $path = '/gists/' . (int) $gistId . '/star'; - - // Send the request. - $response = $this->client->put($this->fetchUrl($path), ''); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - } - - /** - * Method to star a gist. - * - * @param integer $gistId The gist number. - * - * @throws DomainException - * @since 11.3 - * - * @return void - */ - public function unstar($gistId) - { - // Build the request path. - $path = '/gists/' . (int) $gistId . '/star'; - - // Send the request. - $response = $this->client->delete($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - } - - /** - * Method to fetch a data array for transmitting to the GitHub API for a list of files based on - * an input array of file paths or filename and content pairs. - * - * @param array $files The list of file paths or filenames and content. - * - * @throws InvalidArgumentException - * @since 11.3 - * - * @return array - */ - protected function buildFileData(array $files) - { - $data = array(); - - foreach ($files as $key => $file) - { - // If the key isn't numeric, then we are dealing with a file whose content has been supplied - if (!is_numeric($key)) - { - $data[$key] = array('content' => $file); - } - - // Otherwise, we have been given a path and we have to load the content - // Verify that the each file exists. - elseif (!file_exists($file)) - { - throw new InvalidArgumentException('The file ' . $file . ' does not exist.'); - } - else - { - $data[basename($file)] = array('content' => file_get_contents($file)); - } - } - - return $data; - } - - /* - * Deprecated methods - */ - - /** - * Method to create a comment on a gist. - * - * @param integer $gistId The gist number. - * @param string $body The comment body text. - * - * @deprecated use gists->comments->create() - * - * @return object - * - * @since 11.3 - */ - public function createComment($gistId, $body) - { - return $this->comments->create($gistId, $body); - } - - /** - * Method to delete a comment on a gist. - * - * @param integer $commentId The id of the comment to delete. - * - * @deprecated use gists->comments->delete() - * - * @return void - * - * @since 11.3 - */ - public function deleteComment($commentId) - { - $this->comments->delete($commentId); - } - - /** - * Method to update a comment on a gist. - * - * @param integer $commentId The id of the comment to update. - * @param string $body The new body text for the comment. - * - * @deprecated use gists->comments->edit() - * - * @return object - * - * @since 11.3 - */ - public function editComment($commentId, $body) - { - return $this->comments->edit($commentId, $body); - } - - /** - * Method to get a specific comment on a gist. - * - * @param integer $commentId The comment id to get. - * - * @deprecated use gists->comments->get() - * - * @return object - * - * @since 11.3 - */ - public function getComment($commentId) - { - return $this->comments->get($commentId); - } - - /** - * Method to get the list of comments on a gist. - * - * @param integer $gistId The gist number. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @deprecated use gists->comments->getList() - * - * @return array - * - * @since 11.3 - */ - public function getComments($gistId, $page = 0, $limit = 0) - { - return $this->comments->getList($gistId, $page, $limit); - } -} diff --git a/libraries/joomla/github/package/gists/comments.php b/libraries/joomla/github/package/gists/comments.php deleted file mode 100644 index c28118a67f..0000000000 --- a/libraries/joomla/github/package/gists/comments.php +++ /dev/null @@ -1,183 +0,0 @@ - $body, - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to delete a comment on a gist. - * - * @param integer $commentId The id of the comment to delete. - * - * @throws DomainException - * @since 11.3 - * - * @return void - */ - public function delete($commentId) - { - // Build the request path. - $path = '/gists/comments/' . (int) $commentId; - - // Send the request. - $response = $this->client->delete($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - } - - /** - * Method to update a comment on a gist. - * - * @param integer $commentId The id of the comment to update. - * @param string $body The new body text for the comment. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function edit($commentId, $body) - { - // Build the request path. - $path = '/gists/comments/' . (int) $commentId; - - // Build the request data. - $data = json_encode( - array( - 'body' => $body - ) - ); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a specific comment on a gist. - * - * @param integer $commentId The comment id to get. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function get($commentId) - { - // Build the request path. - $path = '/gists/comments/' . (int) $commentId; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get the list of comments on a gist. - * - * @param integer $gistId The gist number. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getList($gistId, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/gists/' . (int) $gistId . '/comments'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/github/package/gitignore.php b/libraries/joomla/github/package/gitignore.php deleted file mode 100644 index 139068137c..0000000000 --- a/libraries/joomla/github/package/gitignore.php +++ /dev/null @@ -1,82 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get a single template - * - * @param string $name The name of the template - * @param boolean $raw Raw output - * - * @throws DomainException - * @since 3.3 (CMS) - * - * @return mixed|string - */ - public function get($name, $raw = false) - { - // Build the request path. - $path = '/gitignore/templates/' . $name; - - $headers = array(); - - if ($raw) - { - $headers['Accept'] = 'application/vnd.github.raw+json'; - } - - $response = $this->client->get($this->fetchUrl($path), $headers); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - $message = (isset($error->message)) ? $error->message : 'Invalid response'; - - throw new DomainException($message, $response->code); - } - - return ($raw) ? $response->body : json_decode($response->body); - } -} diff --git a/libraries/joomla/github/package/issues.php b/libraries/joomla/github/package/issues.php deleted file mode 100644 index 5c3429c684..0000000000 --- a/libraries/joomla/github/package/issues.php +++ /dev/null @@ -1,514 +0,0 @@ - $title, - 'assignee' => $assignee, - 'milestone' => $milestone, - 'labels' => $labels, - 'body' => $body - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to update an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $issueId The issue number. - * @param string $state The optional new state for the issue. [open, closed] - * @param string $title The title of the new issue. - * @param string $body The body text for the new issue. - * @param string $assignee The login for the GitHub user that this issue should be assigned to. - * @param integer $milestone The milestone to associate this issue with. - * @param array $labels The labels to associate with this issue. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function edit($user, $repo, $issueId, $state = null, $title = null, $body = null, $assignee = null, $milestone = null, array $labels = null) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/issues/' . (int) $issueId; - - // Craete the data object. - $data = new stdClass; - - // If a title is set add it to the data object. - if (isset($title)) - { - $data->title = $title; - } - - // If a body is set add it to the data object. - if (isset($body)) - { - $data->body = $body; - } - - // If a state is set add it to the data object. - if (isset($state)) - { - $data->state = $state; - } - - // If an assignee is set add it to the data object. - if (isset($assignee)) - { - $data->assignee = $assignee; - } - - // If a milestone is set add it to the data object. - if (isset($milestone)) - { - $data->milestone = $milestone; - } - - // If labels are set add them to the data object. - if (isset($labels)) - { - // Ensure that we have a non-associative array. - if (isset($labels)) - { - $labels = array_values($labels); - } - - $data->labels = $labels; - } - - // Encode the request data. - $data = json_encode($data); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a single issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $issueId The issue number. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function get($user, $repo, $issueId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/issues/' . (int) $issueId; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list an authenticated user's issues. - * - * @param string $filter The filter type: assigned, created, mentioned, subscribed. - * @param string $state The optional state to filter requests by. [open, closed] - * @param string $labels The list of comma separated Label names. Example: bug,ui,@high. - * @param string $sort The sort order: created, updated, comments, default: created. - * @param string $direction The list direction: asc or desc, default: desc. - * @param JDate $since The date/time since when issues should be returned. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getList($filter = null, $state = null, $labels = null, $sort = null, - $direction = null, JDate $since = null, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/issues'; - - // TODO Implement the filtering options. - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list issues. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $milestone The milestone number, 'none', or *. - * @param string $state The optional state to filter requests by. [open, closed] - * @param string $assignee The assignee name, 'none', or *. - * @param string $mentioned The GitHub user name. - * @param string $labels The list of comma separated Label names. Example: bug,ui,@high. - * @param string $sort The sort order: created, updated, comments, default: created. - * @param string $direction The list direction: asc or desc, default: desc. - * @param JDate $since The date/time since when issues should be returned. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getListByRepository($user, $repo, $milestone = null, $state = null, $assignee = null, $mentioned = null, $labels = null, - $sort = null, $direction = null, JDate $since = null, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/issues'; - - $uri = new JUri($this->fetchUrl($path, $page, $limit)); - - if ($milestone) - { - $uri->setVar('milestone', $milestone); - } - - if ($state) - { - $uri->setVar('state', $state); - } - - if ($assignee) - { - $uri->setVar('assignee', $assignee); - } - - if ($mentioned) - { - $uri->setVar('mentioned', $mentioned); - } - - if ($labels) - { - $uri->setVar('labels', $labels); - } - - if ($sort) - { - $uri->setVar('sort', $sort); - } - - if ($direction) - { - $uri->setVar('direction', $direction); - } - - if ($since) - { - $uri->setVar('since', $since->toISO8601()); - } - - // Send the request. - $response = $this->client->get((string) $uri); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /* - * Deprecated methods - */ - - /** - * Method to create a comment on an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $issueId The issue number. - * @param string $body The comment body text. - * - * @deprecated use issues->comments->create() - * - * @return object - * - * @since 11.3 - */ - public function createComment($user, $repo, $issueId, $body) - { - return $this->comments->create($user, $repo, $issueId, $body); - } - - /** - * Method to create a label on a repo. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $name The label name. - * @param string $color The label color. - * - * @deprecated use issues->labels->create() - * - * @return object - * - * @since 12.3 - */ - public function createLabel($user, $repo, $name, $color) - { - return $this->labels->create($user, $repo, $name, $color); - } - - /** - * Method to delete a comment on an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The id of the comment to delete. - * - * @deprecated use issues->comments->delete() - * - * @return void - * - * @since 11.3 - */ - public function deleteComment($user, $repo, $commentId) - { - $this->comments->delete($user, $repo, $commentId); - } - - /** - * Method to delete a label on a repo. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $label The label name. - * - * @deprecated use issues->labels->delete() - * - * @return object - * - * @since 12.3 - */ - public function deleteLabel($user, $repo, $label) - { - return $this->labels->delete($user, $repo, $label); - } - - /** - * Method to update a comment on an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The id of the comment to update. - * @param string $body The new body text for the comment. - * - * @deprecated use issues->comments->edit() - * - * @return object - * - * @since 11.3 - */ - public function editComment($user, $repo, $commentId, $body) - { - return $this->comments->edit($user, $repo, $commentId, $body); - } - - /** - * Method to update a label on a repo. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $label The label name. - * @param string $name The label name. - * @param string $color The label color. - * - * @deprecated use issues->labels->update() - * - * @return object - * - * @since 12.3 - */ - public function editLabel($user, $repo, $label, $name, $color) - { - return $this->labels->update($user, $repo, $label, $name, $color); - } - - /** - * Method to get a specific comment on an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The comment id to get. - * - * @deprecated use issues->comments->get() - * - * @return object - * - * @since 11.3 - */ - public function getComment($user, $repo, $commentId) - { - return $this->comments->get($user, $repo, $commentId); - } - - /** - * Method to get the list of comments on an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $issueId The issue number. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @deprecated use issues->comments->getList() - * - * @return array - * - * @since 11.3 - */ - public function getComments($user, $repo, $issueId, $page = 0, $limit = 0) - { - return $this->comments->getList($user, $repo, $issueId, $page, $limit); - } - - /** - * Method to get a specific label on a repo. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $name The label name to get. - * - * @deprecated use issues->labels->get() - * - * @return object - * - * @since 12.3 - */ - public function getLabel($user, $repo, $name) - { - return $this->labels->get($user, $repo, $name); - } - - /** - * Method to get the list of labels on a repo. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * - * @deprecated use issues->labels->getList() - * - * @return array - * - * @since 12.3 - */ - public function getLabels($user, $repo) - { - return $this->labels->getList($user, $repo); - } -} diff --git a/libraries/joomla/github/package/issues/assignees.php b/libraries/joomla/github/package/issues/assignees.php deleted file mode 100644 index 5b1add38aa..0000000000 --- a/libraries/joomla/github/package/issues/assignees.php +++ /dev/null @@ -1,84 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Check assignee. - * - * You may check to see if a particular user is an assignee for a repository. - * If the given assignee login belongs to an assignee for the repository, a 204 header - * with no content is returned. - * Otherwise a 404 status code is returned. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $assignee The assinees login name. - * - * @throws DomainException|Exception - * @return boolean - */ - public function check($owner, $repo, $assignee) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/assignees/' . $assignee; - - try - { - $response = $this->client->get($this->fetchUrl($path)); - - if (204 == $response->code) - { - return true; - } - - throw new DomainException('Invalid response: ' . $response->code); - } - catch (DomainException $e) - { - if (isset($response->code) && 404 == $response->code) - { - return false; - } - - throw $e; - } - } -} diff --git a/libraries/joomla/github/package/issues/comments.php b/libraries/joomla/github/package/issues/comments.php deleted file mode 100644 index e9ec7627d0..0000000000 --- a/libraries/joomla/github/package/issues/comments.php +++ /dev/null @@ -1,209 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path, $page, $limit)) - ); - } - - /** - * Method to get the list of comments in a repository. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sort The sort field - created or updated. - * @param string $direction The sort order- asc or desc. Ignored without sort parameter. - * @param JDate $since A timestamp in ISO 8601 format. - * - * @throws UnexpectedValueException - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getRepositoryList($owner, $repo, $sort = 'created', $direction = 'asc', JDate $since = null) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/comments'; - - if (false == in_array($sort, array('created', 'updated'))) - { - throw new UnexpectedValueException( - sprintf( - '%1$s - sort field must be "created" or "updated"', __METHOD__ - ) - ); - } - - if (false == in_array($direction, array('asc', 'desc'))) - { - throw new UnexpectedValueException( - sprintf( - '%1$s - direction field must be "asc" or "desc"', __METHOD__ - ) - ); - } - - $path .= '?sort=' . $sort; - $path .= '&direction=' . $direction; - - if ($since) - { - $path .= '&since=' . $since->toISO8601(); - } - - // Send the request. - return $this->processResponse($this->client->get($this->fetchUrl($path))); - } - - /** - * Method to get a single comment. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id The comment id. - * - * @return mixed - */ - public function get($owner, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/comments/' . (int) $id; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to update a comment on an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The id of the comment to update. - * @param string $body The new body text for the comment. - * - * @since 11.3 - * @throws DomainException - * - * @return object - */ - public function edit($user, $repo, $commentId, $body) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/issues/comments/' . (int) $commentId; - - // Build the request data. - $data = json_encode( - array( - 'body' => $body - ) - ); - - // Send the request. - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), $data) - ); - } - - /** - * Method to create a comment on an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $issueId The issue number. - * @param string $body The comment body text. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function create($user, $repo, $issueId, $body) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/issues/' . (int) $issueId . '/comments'; - - // Build the request data. - $data = json_encode( - array( - 'body' => $body, - ) - ); - - // Send the request. - return $this->processResponse( - $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } - - /** - * Method to delete a comment on an issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The id of the comment to delete. - * - * @throws DomainException - * @since 11.3 - * - * @return boolean - */ - public function delete($user, $repo, $commentId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/issues/comments/' . (int) $commentId; - - // Send the request. - $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - - return true; - } -} diff --git a/libraries/joomla/github/package/issues/events.php b/libraries/joomla/github/package/issues/events.php deleted file mode 100644 index e863e76483..0000000000 --- a/libraries/joomla/github/package/issues/events.php +++ /dev/null @@ -1,90 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path, $page, $limit)) - ); - } - - /** - * List events for a repository. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $issueId The issue number. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @return object - */ - public function getListRepository($owner, $repo, $issueId, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/' . (int) $issueId . '/comments'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path, $page, $limit)) - ); - } - - /** - * Get a single event. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id The event number. - * - * @return object - */ - public function get($owner, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/events/' . (int) $id; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } -} diff --git a/libraries/joomla/github/package/issues/labels.php b/libraries/joomla/github/package/issues/labels.php deleted file mode 100644 index 4da6f58549..0000000000 --- a/libraries/joomla/github/package/issues/labels.php +++ /dev/null @@ -1,301 +0,0 @@ -processResponse( - $response = $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to get a specific label on a repo. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $name The label name to get. - * - * @throws DomainException - * @since 12.3 - * - * @return object - */ - public function get($user, $repo, $name) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/labels/' . $name; - - // Send the request. - return $this->processResponse( - $response = $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to create a label on a repo. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $name The label name. - * @param string $color The label color. - * - * @throws DomainException - * @since 12.3 - * - * @return object - */ - public function create($owner, $repo, $name, $color) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/labels'; - - // Build the request data. - $data = json_encode( - array( - 'name' => $name, - 'color' => $color - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to update a label on a repo. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $label The label name. - * @param string $name The new label name. - * @param string $color The new label color. - * - * @throws DomainException - * @since 12.3 - * - * @return object - */ - public function update($user, $repo, $label, $name, $color) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/labels/' . $label; - - // Build the request data. - $data = json_encode( - array( - 'name' => $name, - 'color' => $color - ) - ); - - // Send the request. - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), $data) - ); - } - - /** - * Method to delete a label on a repo. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $name The label name. - * - * @throws DomainException - * @return object - * - * @since 12.3 - */ - public function delete($owner, $repo, $name) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/labels/' . $name; - - // Send the request. - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * List labels on an issue. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $number The issue number. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getListByIssue($owner, $repo, $number) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Add labels to an issue. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $number The issue number. - * @param array $labels An array of labels to add. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function add($owner, $repo, $number, array $labels) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels'; - - // Send the request. - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode($labels)) - ); - } - - /** - * Remove a label from an issue. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $number The issue number. - * @param string $name The name of the label to remove. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function removeFromIssue($owner, $repo, $number, $name) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels/' . $name; - - // Send the request. - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)) - ); - } - - /** Replace all labels for an issue. - * - * Sending an empty array ([]) will remove all Labels from the Issue. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $number The issue number. - * @param array $labels New labels - * - * @since 3.3 (CMS) - * - * @return object - */ - public function replace($owner, $repo, $number, array $labels) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels'; - - // Send the request. - return $this->processResponse( - $this->client->put($this->fetchUrl($path), json_encode($labels)) - ); - } - - /** - .* Remove all labels from an issue. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $number The issue number. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function removeAllFromIssue($owner, $repo, $number) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels'; - - // Send the request. - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * Get labels for every issue in a milestone. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $number The issue number. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getListByMilestone($owner, $repo, $number) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/milestones/' . $number . '/labels'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } -} diff --git a/libraries/joomla/github/package/issues/milestones.php b/libraries/joomla/github/package/issues/milestones.php deleted file mode 100644 index 8f99caeb2c..0000000000 --- a/libraries/joomla/github/package/issues/milestones.php +++ /dev/null @@ -1,237 +0,0 @@ -client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a specific milestone. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $milestoneId The milestone id to get. - * - * @throws DomainException - * @return object - * - * @since 12.3 - */ - public function get($user, $repo, $milestoneId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones/' . (int) $milestoneId; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to create a milestone for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $title The title of the milestone. - * @param string $state Can be open (default) or closed. - * @param string $description Optional description for milestone. - * @param string $due_on Optional ISO 8601 time. - * - * @throws DomainException - * @return object - * - * @since 12.3 - */ - public function create($user, $repo, $title, $state = null, $description = null, $due_on = null) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones'; - - // Build the request data. - $data = array( - 'title' => $title - ); - - if (!is_null($state)) - { - $data['state'] = $state; - } - - if (!is_null($description)) - { - $data['description'] = $description; - } - - if (!is_null($due_on)) - { - $data['due_on'] = $due_on; - } - - $data = json_encode($data); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to update a milestone. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $milestoneId The id of the comment to update. - * @param integer $title Optional title of the milestone. - * @param string $state Can be open (default) or closed. - * @param string $description Optional description for milestone. - * @param string $due_on Optional ISO 8601 time. - * - * @throws DomainException - * @return object - * - * @since 12.3 - */ - public function edit($user, $repo, $milestoneId, $title = null, $state = null, $description = null, $due_on = null) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones/' . (int) $milestoneId; - - // Build the request data. - $data = array(); - - if (!is_null($title)) - { - $data['title'] = $title; - } - - if (!is_null($state)) - { - $data['state'] = $state; - } - - if (!is_null($description)) - { - $data['description'] = $description; - } - - if (!is_null($due_on)) - { - $data['due_on'] = $due_on; - } - - $data = json_encode($data); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to delete a milestone. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $milestoneId The id of the milestone to delete. - * - * @throws DomainException - * @return void - * - * @since 12.3 - */ - public function delete($user, $repo, $milestoneId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/milestones/' . (int) $milestoneId; - - // Send the request. - $response = $this->client->delete($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 204) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - } -} diff --git a/libraries/joomla/github/package/markdown.php b/libraries/joomla/github/package/markdown.php deleted file mode 100644 index 4ff992c4b3..0000000000 --- a/libraries/joomla/github/package/markdown.php +++ /dev/null @@ -1,74 +0,0 @@ - $text, - 'mode' => $mode, - 'context' => $context - ) - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - $message = (isset($error->message)) ? $error->message : 'Error: ' . $response->code; - throw new DomainException($message, $response->code); - } - - return $response->body; - } -} diff --git a/libraries/joomla/github/package/orgs.php b/libraries/joomla/github/package/orgs.php deleted file mode 100644 index 031713038e..0000000000 --- a/libraries/joomla/github/package/orgs.php +++ /dev/null @@ -1,114 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get an Organization. - * - * @param string $org The organization name. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function get($org) - { - // Build the request path. - $path = '/orgs/' . $org; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Edit an Organization. - * - * @param string $org The organization name. - * @param string $billingEmail Billing email address. This address is not publicized. - * @param string $company The company name. - * @param string $email The email address. - * @param string $location The location name. - * @param string $name The name. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function edit($org, $billingEmail = '', $company = '', $email = '', $location = '', $name = '') - { - // Build the request path. - $path = '/orgs/' . $org; - - $args = array('billing_email', 'company', 'email', 'location', 'name'); - - $data = array(); - - $fArgs = func_get_args(); - - foreach ($args as $i => $arg) - { - if (array_key_exists($i + 1, $fArgs) && $fArgs[$i + 1]) - { - $data[$arg] = $fArgs[$i + 1]; - } - } - - // Send the request. - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), $data) - ); - } -} diff --git a/libraries/joomla/github/package/orgs/members.php b/libraries/joomla/github/package/orgs/members.php deleted file mode 100644 index a562e8acdc..0000000000 --- a/libraries/joomla/github/package/orgs/members.php +++ /dev/null @@ -1,236 +0,0 @@ -client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case 302 : - // Requester is not an organization member. - return false; - break; - - case 200 : - return json_decode($response->body); - break; - - default : - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - break; - } - } - - /** - * Check membership. - * - * Check if a user is, publicly or privately, a member of the organization. - * - * @param string $org The name of the organization. - * @param string $user The name of the user. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return boolean - */ - public function check($org, $user) - { - // Build the request path. - $path = '/orgs/' . $org . '/members/' . $user; - - $response = $this->client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case 204 : - // Requester is an organization member and user is a member. - return true; - break; - - case 404 : - // Requester is an organization member and user is not a member. - // Requester is not an organization member and is inquiring about themselves. - return false; - break; - - case 302 : - // Requester is not an organization member. - return false; - break; - - default : - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - break; - } - } - - /** - * Add a member. - * - * To add someone as a member to an org, you must add them to a team. - */ - - /** - * Remove a member. - * - * Removing a user from this list will remove them from all teams and they will no longer have - * any access to the organization’s repositories. - * - * @param string $org The name of the organization. - * @param string $user The name of the user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function remove($org, $user) - { - // Build the request path. - $path = '/orgs/' . $org . '/members/' . $user; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * Public members list. - * - * Members of an organization can choose to have their membership publicized or not. - * - * @param string $org The name of the organization. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getListPublic($org) - { - // Build the request path. - $path = '/orgs/' . $org . '/public_members'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Check public membership. - * - * @param string $org The name of the organization. - * @param string $user The name of the user. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return object - */ - public function checkPublic($org, $user) - { - // Build the request path. - $path = '/orgs/' . $org . '/public_members/' . $user; - - $response = $this->client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case 204 : - // Response if user is a public member. - return true; - break; - - case 404 : - // Response if user is not a public member. - return false; - break; - - default : - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - break; - } - } - - /** - * Publicize a user’s membership. - * - * @param string $org The name of the organization. - * @param string $user The name of the user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function publicize($org, $user) - { - // Build the request path. - $path = '/orgs/' . $org . '/public_members/' . $user; - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), ''), - 204 - ); - } - - /** - * Conceal a user’s membership. - * - * @param string $org The name of the organization. - * @param string $user The name of the user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function conceal($org, $user) - { - // Build the request path. - $path = '/orgs/' . $org . '/public_members/' . $user; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/orgs/teams.php b/libraries/joomla/github/package/orgs/teams.php deleted file mode 100644 index 446b800bc5..0000000000 --- a/libraries/joomla/github/package/orgs/teams.php +++ /dev/null @@ -1,393 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get team. - * - * @param integer $id The team id. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function get($id) - { - // Build the request path. - $path = '/teams/' . (int) $id; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Create team. - * - * In order to create a team, the authenticated user must be an owner of the organization. - * - * @param string $org The name of the organization. - * @param string $name The name of the team. - * @param array $repoNames Repository names. - * @param string $permission The permission. - * pull - team members can pull, but not push to or administer these repositories. Default - * push - team members can pull and push, but not administer these repositories. - * admin - team members can pull, push and administer these repositories. - * - * @throws UnexpectedValueException - * - * @since 3.3 (CMS) - * - * @return object - */ - public function create($org, $name, array $repoNames = array(), $permission = '') - { - // Build the request path. - $path = '/orgs/' . $org . '/teams'; - - $data = array( - 'name' => $name - ); - - if ($repoNames) - { - $data['repo_names'] = $repoNames; - } - - if ($permission) - { - if (false == in_array($permission, array('pull', 'push', 'admin'))) - { - throw new UnexpectedValueException('Permissions must be either "pull", "push", or "admin".'); - } - - $data['permission'] = $permission; - } - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } - - /** - * Edit team. - * - * In order to edit a team, the authenticated user must be an owner of the org that the team is associated with. - * - * @param integer $id The team id. - * @param string $name The name of the team. - * @param string $permission The permission. - * pull - team members can pull, but not push to or administer these repositories. Default - * push - team members can pull and push, but not administer these repositories. - * admin - team members can pull, push and administer these repositories. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return object - */ - public function edit($id, $name, $permission = '') - { - // Build the request path. - $path = '/teams/' . (int) $id; - - $data = array( - 'name' => $name - ); - - if ($permission) - { - if (false == in_array($permission, array('pull', 'push', 'admin'))) - { - throw new UnexpectedValueException('Permissions must be either "pull", "push", or "admin".'); - } - - $data['permission'] = $permission; - } - - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), $data) - ); - } - - /** - * Delete team. - * - * In order to delete a team, the authenticated user must be an owner of the org that the team is associated with. - * - * @param integer $id The team id. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function delete($id) - { - // Build the request path. - $path = '/teams/' . $id; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * List team members. - * - * In order to list members in a team, the authenticated user must be a member of the team. - * - * @param integer $id The team id. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getListMembers($id) - { - // Build the request path. - $path = '/teams/' . $id . '/members'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get team member. - * - * In order to get if a user is a member of a team, the authenticated user must be a member of the team. - * - * @param integer $id The team id. - * @param string $user The name of the user. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return object - */ - public function isMember($id, $user) - { - // Build the request path. - $path = '/teams/' . $id . '/members/' . $user; - - $response = $this->client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case 204 : - // Response if user is a member - return true; - break; - - case 404 : - // Response if user is not a member - return false; - break; - - default : - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - break; - } - } - - /** - * Add team member. - * - * In order to add a user to a team, the authenticated user must have ‘admin’ permissions - * to the team or be an owner of the org that the team is associated with. - * - * @param integer $id The team id. - * @param string $user The name of the user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function addMember($id, $user) - { - // Build the request path. - $path = '/teams/' . $id . '/members/' . $user; - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), ''), - 204 - ); - } - - /** - * Remove team member. - * - * In order to remove a user from a team, the authenticated user must have ‘admin’ permissions - * to the team or be an owner of the org that the team is associated with. - * NOTE: This does not delete the user, it just remove them from the team. - * - * @param integer $id The team id. - * @param string $user The name of the user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function removeMember($id, $user) - { - // Build the request path. - $path = '/teams/' . $id . '/members/' . $user; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * List team repos. - * - * @param integer $id The team id. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getListRepos($id) - { - // Build the request path. - $path = '/teams/' . $id . '/repos'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Check if the repo is managed by this team. - * - * @param integer $id The team id. - * @param string $repo The name of the GitHub repository. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return object - */ - public function checkRepo($id, $repo) - { - // Build the request path. - $path = '/teams/' . $id . '/repos/' . $repo; - - $response = $this->client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case 204 : - // Response if repo is managed by this team. - return true; - break; - - case 404 : - // Response if repo is not managed by this team. - return false; - break; - - default : - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - break; - } - } - - /** - * Add team repo. - * - * In order to add a repo to a team, the authenticated user must be an owner of the - * org that the team is associated with. Also, the repo must be owned by the organization, - * or a direct form of a repo owned by the organization. - * - * If you attempt to add a repo to a team that is not owned by the organization, you get: - * Status: 422 Unprocessable Entity - * - * @param integer $id The team id. - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function addRepo($id, $owner, $repo) - { - // Build the request path. - $path = '/teams/' . $id . '/repos/' . $owner . '/' . $repo; - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), ''), - 204 - ); - } - - /** - * Remove team repo. - * - * In order to remove a repo from a team, the authenticated user must be an owner - * of the org that the team is associated with. NOTE: This does not delete the - * repo, it just removes it from the team. - * - * @param integer $id The team id. - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function removeRepo($id, $owner, $repo) - { - // Build the request path. - $path = '/teams/' . (int) $id . '/repos/' . $owner . '/' . $repo; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/pulls.php b/libraries/joomla/github/package/pulls.php deleted file mode 100644 index a58b529699..0000000000 --- a/libraries/joomla/github/package/pulls.php +++ /dev/null @@ -1,513 +0,0 @@ - $title, - 'base' => $base, - 'head' => $head, - 'body' => $body - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to create a pull request from an existing issue. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $issueId The issue number for which to attach the new pull request. - * @param string $base The branch (or git ref) you want your changes pulled into. This - * should be an existing branch on the current repository. You cannot - * submit a pull request to one repo that requests a merge to a base - * of another repo. - * @param string $head The branch (or git ref) where your changes are implemented. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function createFromIssue($user, $repo, $issueId, $base, $head) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls'; - - // Build the request data. - $data = json_encode( - array( - 'issue' => (int) $issueId, - 'base' => $base, - 'head' => $head - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to update a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param string $title The optional new title for the pull request. - * @param string $body The optional new body text for the pull request. - * @param string $state The optional new state for the pull request. [open, closed] - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function edit($user, $repo, $pullId, $title = null, $body = null, $state = null) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId; - - // Craete the data object. - $data = new stdClass; - - // If a title is set add it to the data object. - if (isset($title)) - { - $data->title = $title; - } - - // If a body is set add it to the data object. - if (isset($body)) - { - $data->body = $body; - } - - // If a state is set add it to the data object. - if (isset($state)) - { - $data->state = $state; - } - - // Encode the request data. - $data = json_encode($data); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a single pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function get($user, $repo, $pullId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a list of commits for a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getCommits($user, $repo, $pullId, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/commits'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a list of files for a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getFiles($user, $repo, $pullId, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/files'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list pull requests. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $state The optional state to filter requests by. [open, closed] - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getList($user, $repo, $state = 'open', $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls'; - - // If a state exists append it as an option. - if ($state != 'open') - { - $path .= '?state=' . $state; - } - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to check if a pull request has been merged. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. The pull request number. - * - * @throws DomainException - * @since 11.3 - * - * @return boolean True if the pull request has been merged. - */ - public function isMerged($user, $repo, $pullId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/merge'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code == 204) - { - return true; - } - elseif ($response->code == 404) - { - return false; - } - else - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - } - - /** - * Method to merge a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param string $message The message that will be used for the merge commit. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function merge($user, $repo, $pullId, $message = '') - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/merge'; - - // Build the request data. - $data = json_encode( - array( - 'commit_message' => $message - ) - ); - - // Send the request. - $response = $this->client->put($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /* - * Legacy methods - */ - - /** - * Method to create a comment on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param string $body The comment body text. - * @param string $commitId The SHA1 hash of the commit to comment on. - * @param string $filePath The Relative path of the file to comment on. - * @param string $position The line index in the diff to comment on. - * - * @deprecated use pulls->comments->create() - * - * @return object - * - * @since 11.3 - */ - public function createComment($user, $repo, $pullId, $body, $commitId, $filePath, $position) - { - return $this->comments->create($user, $repo, $pullId, $body, $commitId, $filePath, $position); - } - - /** - * Method to create a comment in reply to another comment. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param string $body The comment body text. - * @param integer $inReplyTo The id of the comment to reply to. - * - * @deprecated use pulls->comments->createReply() - * - * @return object - * - * @since 11.3 - */ - public function createCommentReply($user, $repo, $pullId, $body, $inReplyTo) - { - return $this->comments->createReply($user, $repo, $pullId, $body, $inReplyTo); - } - - /** - * Method to delete a comment on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The id of the comment to delete. - * - * @deprecated use pulls->comments->delete() - * - * @return void - * - * @since 11.3 - */ - public function deleteComment($user, $repo, $commentId) - { - $this->comments->delete($user, $repo, $commentId); - } - - /** - * Method to update a comment on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The id of the comment to update. - * @param string $body The new body text for the comment. - * - * @deprecated use pulls->comments->edit() - * - * @return object - * - * @since 11.3 - */ - public function editComment($user, $repo, $commentId, $body) - { - return $this->comments->edit($user, $repo, $commentId, $body); - } - - /** - * Method to get a specific comment on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The comment id to get. - * - * @deprecated use pulls->comments->get() - * - * @return object - * - * @since 11.3 - */ - public function getComment($user, $repo, $commentId) - { - return $this->comments->get($user, $repo, $commentId); - } - - /** - * Method to get the list of comments on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @deprecated use pulls->comments->getList() - * - * @return array - * - * @since 11.3 - */ - public function getComments($user, $repo, $pullId, $page = 0, $limit = 0) - { - return $this->comments->getList($user, $repo, $pullId, $page, $limit); - } -} diff --git a/libraries/joomla/github/package/pulls/comments.php b/libraries/joomla/github/package/pulls/comments.php deleted file mode 100644 index 5f39307e69..0000000000 --- a/libraries/joomla/github/package/pulls/comments.php +++ /dev/null @@ -1,197 +0,0 @@ - $body, - 'commit_id' => $commitId, - 'path' => $filePath, - 'position' => $position - ) - ); - - // Send the request. - return $this->processResponse( - $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } - - /** - * Method to create a comment in reply to another comment. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param string $body The comment body text. - * @param integer $inReplyTo The id of the comment to reply to. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function createReply($user, $repo, $pullId, $body, $inReplyTo) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/comments'; - - // Build the request data. - $data = json_encode( - array( - 'body' => $body, - 'in_reply_to' => (int) $inReplyTo - ) - ); - - // Send the request. - return $this->processResponse( - $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } - - /** - * Method to delete a comment on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The id of the comment to delete. - * - * @throws DomainException - * @since 11.3 - * - * @return void - */ - public function delete($user, $repo, $commentId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/comments/' . (int) $commentId; - - // Send the request. - $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * Method to update a comment on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The id of the comment to update. - * @param string $body The new body text for the comment. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function edit($user, $repo, $commentId, $body) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/comments/' . (int) $commentId; - - // Build the request data. - $data = json_encode( - array( - 'body' => $body - ) - ); - - // Send the request. - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), $data) - ); - } - - /** - * Method to get a specific comment on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $commentId The comment id to get. - * - * @throws DomainException - * @since 11.3 - * - * @return object - */ - public function get($user, $repo, $commentId) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/comments/' . (int) $commentId; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to get the list of comments on a pull request. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $pullId The pull request number. - * @param integer $page The page number from which to get items. - * @param integer $limit The number of items on a page. - * - * @throws DomainException - * @since 11.3 - * - * @return array - */ - public function getList($user, $repo, $pullId, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/comments'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path, $page, $limit)) - ); - } -} diff --git a/libraries/joomla/github/package/repositories.php b/libraries/joomla/github/package/repositories.php deleted file mode 100644 index c4e9e2bf0d..0000000000 --- a/libraries/joomla/github/package/repositories.php +++ /dev/null @@ -1,433 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List user repositories. - * - * List public repositories for the specified user. - * - * @param string $user The user name. - * @param string $type Sort type. all, owner, member. Default: all. - * @param string $sort Sort field. created, updated, pushed, full_name, default: full_name. - * @param string $direction Sort direction. asc or desc, default: when using full_name: asc, otherwise desc. - * - * @throws RuntimeException - * - * @return object - */ - public function getListUser($user, $type = 'all', $sort = 'full_name', $direction = '') - { - if (false == in_array($type, array('all', 'owner', 'member'))) - { - throw new RuntimeException('Invalid type'); - } - - if (false == in_array($sort, array('created', 'updated', 'pushed', 'full_name'))) - { - throw new RuntimeException('Invalid sort field'); - } - - // Sort direction default: when using full_name: asc, otherwise desc. - $direction = ($direction) ? : (('full_name' == $sort) ? 'asc' : 'desc'); - - if (false == in_array($direction, array('asc', 'desc'))) - { - throw new RuntimeException('Invalid sort order'); - } - - // Build the request path. - $path = '/users/' . $user . '/repos' - . '?type=' . $type - . '&sort=' . $sort - . '&direction=' . $direction; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List organization repositories. - * - * List repositories for the specified org. - * - * @param string $org The name of the organization. - * @param string $type Sort type. all, public, private, forks, sources, member. Default: all. - * - * @throws RuntimeException - * - * @return object - */ - public function getListOrg($org, $type = 'all') - { - if (false == in_array($type, array('all', 'public', 'private', 'forks', 'sources', 'member'))) - { - throw new RuntimeException('Invalid type'); - } - - // Build the request path. - $path = '/orgs/' . $org . '/repos' - . '?type=' . $type; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List all repositories. - * - * This provides a dump of every repository, in the order that they were created. - * - * @param integer $id The integer ID of the last Repository that you’ve seen. - * - * @throws RuntimeException - * - * @return object - */ - public function getList($id = 0) - { - // Build the request path. - $path = '/repositories'; - $path .= ($id) ? '?since=' . (int) $id : ''; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Create a new repository for the authenticated user or an organization. - * OAuth users must supply repo scope. - * - * @param string $name The repository name. - * @param string $org The organization name (if needed). - * @param string $description The repository description. - * @param string $homepage The repository homepage. - * @param boolean $private Set true to create a private repository, false to create a public one. - * Creating private repositories requires a paid GitHub account. - * @param boolean $has_issues Set true to enable issues for this repository, false to disable them. - * @param boolean $has_wiki Set true to enable the wiki for this repository, false to disable it. - * @param boolean $has_downloads Set true to enable downloads for this repository, false to disable them. - * @param integer $team_id The id of the team that will be granted access to this repository. - * This is only valid when creating a repo in an organization. - * @param boolean $auto_init true to create an initial commit with empty README. - * @param string $gitignore_template Desired language or platform .gitignore template to apply. - * Use the name of the template without the extension. For example, - * “Haskell” Ignored if auto_init parameter is not provided. - * - * @return object - */ - public function create($name, $org = '', $description = '', $homepage = '', $private = false, $has_issues = false, - $has_wiki = false, $has_downloads = false, $team_id = 0, $auto_init = false, $gitignore_template = '') - { - $path = ($org) - // Create a repository for an organization - ? '/orgs/' . $org . '/repos' - // Create a repository for a user - : '/user/repos'; - - $data = array( - 'name' => $name, - 'description' => $description, - 'homepage' => $homepage, - 'private' => $private, - 'has_issues' => $has_issues, - 'has_wiki' => $has_wiki, - 'has_downloads' => $has_downloads, - 'team_id' => $team_id, - 'auto_init' => $auto_init, - 'gitignore_template' => $gitignore_template - ); - - // Send the request. - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode($data)), - 201 - ); - } - - /** - * Get a repository. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @return object - */ - public function get($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Edit a repository. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * @param string $name The repository name. - * @param string $description The repository description. - * @param string $homepage The repository homepage. - * @param boolean $private Set true to create a private repository, false to create a public one. - * Creating private repositories requires a paid GitHub account. - * @param boolean $has_issues Set true to enable issues for this repository, false to disable them. - * @param boolean $has_wiki Set true to enable the wiki for this repository, false to disable it. - * @param boolean $has_downloads Set true to enable downloads for this repository, false to disable them. - * @param string $default_branch Update the default branch for this repository - * - * @return object - */ - public function edit($owner, $repo, $name, $description = '', $homepage = '', $private = false, $has_issues = false, - $has_wiki = false, $has_downloads = false, $default_branch = '') - { - $path = '/repos/' . $owner . '/' . $repo; - - $data = array( - 'name' => $name, - 'description' => $description, - 'homepage' => $homepage, - 'private' => $private, - 'has_issues' => $has_issues, - 'has_wiki' => $has_wiki, - 'has_downloads' => $has_downloads, - 'default_branch' => $default_branch - ); - - // Send the request. - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), json_encode($data)) - ); - } - - /** - * List contributors. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * @param boolean $anon Set to 1 or true to include anonymous contributors in results. - * - * @return object - */ - public function getListContributors($owner, $repo, $anon = false) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/contributors'; - - $path .= ($anon) ? '?anon=true' : ''; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List languages. - * - * List languages for the specified repository. The value on the right of a language is the number of bytes of code - * written in that language. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @return object - */ - public function getListLanguages($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/languages'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List Teams - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @return object - */ - public function getListTeams($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/teams'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List Tags. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @return object - */ - public function getListTags($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/tags'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List Branches. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @return object - */ - public function getListBranches($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/branches'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get a Branch. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * @param string $branch Branch name. - * - * @return object - */ - public function getBranch($owner, $repo, $branch) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/branches/' . $branch; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Delete a Repository. - * - * Deleting a repository requires admin access. If OAuth is used, the delete_repo scope is required. - * - * @param string $owner Repository owner. - * @param string $repo Repository name. - * - * @return object - */ - public function delete($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo; - - // Send the request. - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)) - ); - } -} diff --git a/libraries/joomla/github/package/repositories/collaborators.php b/libraries/joomla/github/package/repositories/collaborators.php deleted file mode 100644 index c17ca8eab9..0000000000 --- a/libraries/joomla/github/package/repositories/collaborators.php +++ /dev/null @@ -1,125 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Test if a user is a collaborator. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $user The name of the GitHub user. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return boolean - */ - public function get($owner, $repo, $user) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/collaborators/' . $user; - - $response = $this->client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case '204'; - - return true; - break; - case '404'; - - return false; - break; - default; - throw new UnexpectedValueException('Unexpected code: ' . $response->code); - break; - } - } - - /** - * Add collaborator. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $user The name of the GitHub user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function add($owner, $repo, $user) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/collaborators/' . $user; - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), ''), - 204 - ); - } - - /** - * Remove collaborator. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $user The name of the GitHub user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function remove($owner, $repo, $user) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/collaborators/' . $user; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/repositories/comments.php b/libraries/joomla/github/package/repositories/comments.php deleted file mode 100644 index e98594170b..0000000000 --- a/libraries/joomla/github/package/repositories/comments.php +++ /dev/null @@ -1,179 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path, $page, $limit)) - ); - } - - /** - * Method to get a list of comments for a single commit for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha The SHA of the commit to retrieve. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @return array - * - * @since 12.1 - */ - public function getList($user, $repo, $sha, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha . '/comments'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path, $page, $limit)) - ); - } - - /** - * Method to get a single comment on a commit. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the comment to retrieve - * - * @return array - * - * @since 12.1 - */ - public function get($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/comments/' . (int) $id; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to edit a comment on a commit. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $id The ID of the comment to edit. - * @param string $comment The text of the comment. - * - * @return object - * - * @since 12.1 - */ - public function edit($user, $repo, $id, $comment) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/comments/' . $id; - - $data = json_encode( - array( - 'body' => $comment - ) - ); - - // Send the request. - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), $data) - ); - } - - /** - * Method to delete a comment on a commit. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $id The ID of the comment to edit. - * - * @return object - * - * @since 12.1 - */ - public function delete($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/comments/' . $id; - - // Send the request. - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * Method to create a comment on a commit. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha The SHA of the commit to comment on. - * @param string $comment The text of the comment. - * @param integer $line The line number of the commit to comment on. - * @param string $filepath A relative path to the file to comment on within the commit. - * @param integer $position Line index in the diff to comment on. - * - * @return object - * - * @since 12.1 - */ - public function create($user, $repo, $sha, $comment, $line, $filepath, $position) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha . '/comments'; - - $data = json_encode( - array( - 'body' => $comment, - 'path' => $filepath, - 'position' => (int) $position, - 'line' => (int) $line - ) - ); - - // Send the request. - return $this->processResponse( - $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } -} diff --git a/libraries/joomla/github/package/repositories/commits.php b/libraries/joomla/github/package/repositories/commits.php deleted file mode 100644 index 14b3951b82..0000000000 --- a/libraries/joomla/github/package/repositories/commits.php +++ /dev/null @@ -1,122 +0,0 @@ -toISO8601() : ''; - $rPath .= ($until) ? '&until=' . $until->toISO8601() : ''; - - // Send the request. - $response = $this->client->get($this->fetchUrl($rPath)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a single commit for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha The SHA of the commit to retrieve. - * - * @throws DomainException - * @since 12.1 - * - * @return array - */ - public function get($user, $repo, $sha) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a diff for two commits. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $base The base of the diff, either a commit SHA or branch. - * @param string $head The head of the diff, either a commit SHA or branch. - * - * @return array - * - * @since 12.1 - */ - public function compare($user, $repo, $base, $head) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/compare/' . $base . '...' . $head; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } -} diff --git a/libraries/joomla/github/package/repositories/contents.php b/libraries/joomla/github/package/repositories/contents.php deleted file mode 100644 index c70653ad5e..0000000000 --- a/libraries/joomla/github/package/repositories/contents.php +++ /dev/null @@ -1,206 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - - Get contents - - This method returns the contents of any file or directory in a repository. - - GET /repos/:owner/:repo/contents/:path - - Parameters - - path - Optional string - The content path. - ref - Optional string - The String name of the Commit/Branch/Tag. Defaults to master. - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "type": "file", - "encoding": "base64", - "_links": { - "git": "https://api.github.com/repos/pengwynn/octokit/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1", - "self": "https://api.github.com/repos/pengwynn/octokit/contents/README.md", - "html": "https://github.com/pengwynn/octokit/blob/master/README.md" - }, - "size": 5362, - "name": "README.md", - "path": "README.md", - "content": "encoded content ...", - "sha": "3d21ec53a331a6f037a91c368710b99387d012c1" - } - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $path The content path. - * @param string $ref The String name of the Commit/Branch/Tag. Defaults to master. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function get($owner, $repo, $path, $ref = '') - { - // Build the request path. - $rPath = '/repos/' . $owner . '/' . $repo . '/contents'; - - $rPath .= '?path=' . $path; - - if ($ref) - { - $rPath .= '&ref=' . $ref; - } - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($rPath)) - ); - } - - /** - - Get archive link - - This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - * Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request. - - Note: For private repositories, these links are temporary and expire quickly. - - GET /repos/:owner/:repo/:archive_format/:ref - - Parameters - - archive_format - Either tarball or zipball - ref - Optional string - valid Git reference, defaults to master - - Response - - Status: 302 Found - Location: http://github.com/me/myprivate/tarball/master?SSO=thistokenexpires - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - To follow redirects with curl, use the -L switch: - - curl -L https://api.github.com/repos/pengwynn/octokit/tarball > octokit.tar.gz - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $archive_format Either tarball or zipball. - * @param string $ref The String name of the Commit/Branch/Tag. Defaults to master. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return object - */ - public function getArchiveLink($owner, $repo, $archive_format = 'zipball', $ref = '') - { - if (false == in_array($archive_format, array('tarball', 'zipball'))) - { - throw new UnexpectedValueException('Archive format must be either "tarball" or "zipball".'); - } - - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/' . $archive_format; - - if ($ref) - { - $path .= '?ref=' . $ref; - } - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)), - 302 - ); - } -} diff --git a/libraries/joomla/github/package/repositories/downloads.php b/libraries/joomla/github/package/repositories/downloads.php deleted file mode 100644 index 962010e956..0000000000 --- a/libraries/joomla/github/package/repositories/downloads.php +++ /dev/null @@ -1,202 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get a single download. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id The id of the download. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function get($owner, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/downloads/' . $id; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Create a new download (Part 1: Create the resource). - * - * Creating a new download is a two step process. You must first create a new download resource. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $name The name. - * @param string $size Size of file in bytes. - * @param string $description The description. - * @param string $content_type The content type. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function create($owner, $repo, $name, $size, $description = '', $content_type = '') - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/downloads'; - - $data = array( - 'name' => $name, - 'size' => $size - ); - - if ($description) - { - $data['description'] = $description; - } - - if ($content_type) - { - $data['content_type'] = $content_type; - } - - // Send the request. - return $this->processResponse( - $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } - - /** - * Create a new download (Part 2: Upload file to s3). - * - * Now that you have created the download resource, you can use the information - * in the response to upload your file to s3. This can be done with a POST to - * the s3_url you got in the create response. Here is a brief example using curl: - * - * curl \ - * -F "key=downloads/octocat/Hello-World/new_file.jpg" \ - * -F "acl=public-read" \ - * -F "success_action_status=201" \ - * -F "Filename=new_file.jpg" \ - * -F "AWSAccessKeyId=1ABCDEF..." \ - * -F "Policy=ewogIC..." \ - * -F "Signature=mwnF..." \ - * -F "Content-Type=image/jpeg" \ - * -F "file=@new_file.jpg" \ - * https://github.s3.amazonaws.com/ - * - * NOTES - * The order in which you pass these fields matters! Follow the order shown above exactly. - * All parameters shown are required and if you excluded or modify them your upload will - * fail because the values are hashed and signed by the policy. - * - * More information about using the REST API to interact with s3 can be found here: - * http://docs.amazonwebservices.com/AmazonS3/latest/API/ - * - * @param string $key Value of path field in the response. - * @param string $acl Value of acl field in the response. - * @param string $success_action_status 201, or whatever you want to get back. - * @param string $filename Value of name field in the response. - * @param string $awsAccessKeyId Value of accesskeyid field in the response. - * @param string $policy Value of policy field in the response. - * @param string $signature Value of signature field in the response. - * @param string $content_type Value of mime_type field in the response. - * @param string $file Local file. Example assumes the file existing in the directory - * where you are running the curl command. Yes, the @ matters. - * - * @since 3.3 (CMS) - * - * @return boolean - */ - public function upload($key, $acl, $success_action_status, $filename, $awsAccessKeyId, $policy, $signature, $content_type, $file) - { - // Build the request path. - $url = 'https://github.s3.amazonaws.com/'; - - $data = array( - 'key' => $key, - 'acl' => $acl, - 'success_action_status' => (int) $success_action_status, - 'Filename' => $filename, - 'AWSAccessKeyId' => $awsAccessKeyId, - 'Policy' => $policy, - 'Signature' => $signature, - 'Content-Type' => $content_type, - 'file' => $file - ); - - // Send the request. - $response = $this->client->post($url, $data); - - // @todo Process the response.. - - return (201 == $response->code) ? true : false; - } - - /** - * Delete a download. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id The id of the download. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function delete($owner, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/downloads/' . (int) $id; - - // Send the request. - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/repositories/forks.php b/libraries/joomla/github/package/repositories/forks.php deleted file mode 100644 index 60ddf03216..0000000000 --- a/libraries/joomla/github/package/repositories/forks.php +++ /dev/null @@ -1,96 +0,0 @@ - 0) - { - $data = json_encode( - array('org' => $org) - ); - } - else - { - $data = json_encode(array()); - } - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 202) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list forks for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @return array - * - * @since 11.4 - * @throws DomainException - */ - public function getList($user, $repo, $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/forks'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/github/package/repositories/hooks.php b/libraries/joomla/github/package/repositories/hooks.php deleted file mode 100644 index 926201d44b..0000000000 --- a/libraries/joomla/github/package/repositories/hooks.php +++ /dev/null @@ -1,227 +0,0 @@ -events)) - { - throw new RuntimeException('Your events array contains an unauthorized event.'); - } - } - - $data = json_encode( - array('name' => $name, 'config' => $config, 'events' => $events, 'active' => $active) - ); - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), $data), - 201 - ); - } - - /** - * Method to delete a hook - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the hook to delete. - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function delete($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } - - /** - * Method to edit a hook. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the hook to edit. - * @param string $name The name of the service being called. - * @param array $config Array containing the config for the service. - * @param array $events The events the hook will be triggered for. This resets the currently set list - * @param array $addEvents Events to add to the hook. - * @param array $removeEvents Events to remove from the hook. - * @param boolean $active Flag to determine if the hook is active - * - * @return object - * - * @since 12.3 - * @throws DomainException - * @throws RuntimeException - */ - public function edit($user, $repo, $id, $name, $config, array $events = array('push'), array $addEvents = array(), - array $removeEvents = array(), $active = true) - { - // Check to ensure all events are in the allowed list - foreach ($events as $event) - { - if (!in_array($event, $this->events)) - { - throw new RuntimeException('Your events array contains an unauthorized event.'); - } - } - - foreach ($addEvents as $event) - { - if (!in_array($event, $this->events)) - { - throw new RuntimeException('Your active_events array contains an unauthorized event.'); - } - } - - foreach ($removeEvents as $event) - { - if (!in_array($event, $this->events)) - { - throw new RuntimeException('Your remove_events array contains an unauthorized event.'); - } - } - - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id; - - $data = json_encode( - array( - 'name' => $name, - 'config' => $config, - 'events' => $events, - 'add_events' => $addEvents, - 'remove_events' => $removeEvents, - 'active' => $active) - ); - - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), $data) - ); - } - - /** - * Method to get details about a single hook for the repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the hook to retrieve - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function get($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to list hooks for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function getList($user, $repo) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Method to test a hook against the latest repository commit - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id ID of the hook to delete - * - * @return object - * - * @since 12.3 - * @throws DomainException - */ - public function test($user, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id . '/test'; - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode('')), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/repositories/keys.php b/libraries/joomla/github/package/repositories/keys.php deleted file mode 100644 index 8c4af1e7f4..0000000000 --- a/libraries/joomla/github/package/repositories/keys.php +++ /dev/null @@ -1,143 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get a key. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id The id of the key. - * - * @since 12.4 - * - * @return object - */ - public function get($owner, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/keys/' . (int) $id; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Create a key. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $title The key title. - * @param string $key The key. - * - * @since 12.4 - * - * @return object - */ - public function create($owner, $repo, $title, $key) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/keys'; - - $data = array( - 'title' => $title, - 'key' => $key - ); - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode($data)), - 201 - ); - } - - /** - * Edit a key. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id The id of the key. - * @param string $title The key title. - * @param string $key The key. - * - * @since 12.4 - * - * @return object - */ - public function edit($owner, $repo, $id, $title, $key) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/keys/' . (int) $id; - - $data = array( - 'title' => $title, - 'key' => $key - ); - - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), json_encode($data)) - ); - } - - /** - * Delete a key. - * - * @param string $owner The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param integer $id The id of the key. - * - * @since 12.4 - * - * @return boolean - */ - public function delete($owner, $repo, $id) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/keys/' . (int) $id; - - $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - - return true; - } -} diff --git a/libraries/joomla/github/package/repositories/merging.php b/libraries/joomla/github/package/repositories/merging.php deleted file mode 100644 index 6d8539d1e9..0000000000 --- a/libraries/joomla/github/package/repositories/merging.php +++ /dev/null @@ -1,91 +0,0 @@ -base = $base; - $data->head = $head; - - if ($commit_message) - { - $data->commit_message = $commit_message; - } - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), json_encode($data)); - - switch ($response->code) - { - case '201': - // Success - return json_decode($response->body); - break; - - case '204': - // No-op response (base already contains the head, nothing to merge) - throw new UnexpectedValueException('Nothing to merge'); - break; - - case '404': - // Missing base or Missing head response - $error = json_decode($response->body); - - $message = (isset($error->message)) ? $error->message : 'Missing base or head: ' . $response->code; - - throw new UnexpectedValueException($message); - break; - - case '409': - // Merge conflict response - $error = json_decode($response->body); - - $message = (isset($error->message)) ? $error->message : 'Merge conflict ' . $response->code; - - throw new UnexpectedValueException($message); - break; - - default : - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - break; - } - } -} diff --git a/libraries/joomla/github/package/repositories/statistics.php b/libraries/joomla/github/package/repositories/statistics.php deleted file mode 100644 index d457f6935d..0000000000 --- a/libraries/joomla/github/package/repositories/statistics.php +++ /dev/null @@ -1,175 +0,0 @@ -processResponse($this->client->get($this->fetchUrl($path))); - } - - /** - * Get the last year of commit activity data. - * - * Returns the last year of commit activity grouped by week. - * The days array is a group of commits per day, starting on Sunday. - * - * @param string $owner The owner of the repository. - * @param string $repo The repository name. - * - * @since 1.0 - * - * @return object - */ - public function getActivityData($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/stats/commit_activity'; - - // Send the request. - return $this->processResponse($this->client->get($this->fetchUrl($path))); - } - - /** - * Get the number of additions and deletions per week. - * - * Response returns a weekly aggregate of the number of additions and deletions pushed to a repository. - * - * @param string $owner The owner of the repository. - * @param string $repo The repository name. - * - * @since 1.0 - * - * @return object - */ - public function getCodeFrequency($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/stats/code_frequency'; - - // Send the request. - return $this->processResponse($this->client->get($this->fetchUrl($path))); - } - - /** - * Get the weekly commit count for the repo owner and everyone else. - * - * Returns the total commit counts for the "owner" and total commit counts in "all". "all" is everyone combined, - * including the owner in the last 52 weeks. - * If you’d like to get the commit counts for non-owners, you can subtract all from owner. - * - * The array order is oldest week (index 0) to most recent week. - * - * @param string $owner The owner of the repository. - * @param string $repo The repository name. - * - * @since 1.0 - * - * @return object - */ - public function getParticipation($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/stats/participation'; - - // Send the request. - return $this->processResponse($this->client->get($this->fetchUrl($path))); - } - - /** - * Get the number of commits per hour in each day. - * - * Response - * Each array contains the day number, hour number, and number of commits: - * - * 0-6: Sunday - Saturday - * 0-23: Hour of day - * Number of commits - * - * For example, [2, 14, 25] indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. - * All times are based on the time zone of individual commits. - * - * @param string $owner The owner of the repository. - * @param string $repo The repository name. - * - * @since 1.0 - * - * @return object - */ - public function getPunchCard($owner, $repo) - { - // Build the request path. - $path = '/repos/' . $owner . '/' . $repo . '/stats/punch_card'; - - // Send the request. - return $this->processResponse($this->client->get($this->fetchUrl($path))); - } - - /** - * Process the response and decode it. - * - * @param JHttpResponse $response The response. - * @param integer $expectedCode The expected "good" code. - * - * @return mixed - * - * @since 1.0 - * @throws \DomainException - */ - protected function processResponse(JHttpResponse $response, $expectedCode = 200) - { - if (202 == $response->code) - { - throw new \DomainException( - 'GitHub is building the statistics data. Please try again in a few moments.', - $response->code - ); - } - - return parent::processResponse($response, $expectedCode); - } -} diff --git a/libraries/joomla/github/package/repositories/statuses.php b/libraries/joomla/github/package/repositories/statuses.php deleted file mode 100644 index 6101db3085..0000000000 --- a/libraries/joomla/github/package/repositories/statuses.php +++ /dev/null @@ -1,108 +0,0 @@ - $state - ); - - if (!is_null($targetUrl)) - { - $data['target_url'] = $targetUrl; - } - - if (!is_null($description)) - { - $data['description'] = $description; - } - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), json_encode($data)); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list statuses for an SHA. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha SHA1 for which to get the statuses. - * - * @return array - * - * @since 12.3 - */ - public function getList($user, $repo, $sha) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/statuses/' . $sha; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/github/package/search.php b/libraries/joomla/github/package/search.php deleted file mode 100644 index 42ddff102d..0000000000 --- a/libraries/joomla/github/package/search.php +++ /dev/null @@ -1,132 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Search repositories. - * - * Find repositories by keyword. Note, this legacy method does not follow - * the v3 pagination pattern. - * This method returns up to 100 results per page and pages can be fetched - * using the start_page parameter. - * - * @param string $keyword The search term. - * @param string $language Filter results by language https://github.com/languages - * @param integer $start_page Page number to fetch - * - * @since 3.3 (CMS) - * - * @return object - */ - public function repositories($keyword, $language = '', $start_page = 0) - { - // Build the request path. - $path = '/legacy/repos/search/' . $keyword . '?'; - - $path .= ($language) ? '&language=' . $language : ''; - $path .= ($start_page) ? '&start_page=' . $start_page : ''; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Search users. - * - * Find users by keyword. - * - * @param string $keyword The search term. - * @param integer $start_page Page number to fetch - * - * @since 3.3 (CMS) - * - * @return object - */ - public function users($keyword, $start_page = 0) - { - // Build the request path. - $path = '/legacy/user/search/' . $keyword . '?'; - - $path .= ($start_page) ? '&start_page=' . $start_page : ''; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Email search. - * - * This API call is added for compatibility reasons only. There’s no guarantee - * that full email searches will always be available. The @ character in the - * address must be left unencoded. Searches only against public email addresses - * (as configured on the user’s GitHub profile). - * - * @param string $email The email address(es). - * - * @since 3.3 (CMS) - * - * @return object - */ - public function email($email) - { - // Build the request path. - $path = '/legacy/user/email/' . $email; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } -} diff --git a/libraries/joomla/github/package/users.php b/libraries/joomla/github/package/users.php deleted file mode 100644 index 581ae77ed8..0000000000 --- a/libraries/joomla/github/package/users.php +++ /dev/null @@ -1,184 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get the current authenticated user. - * - * @throws DomainException - * - * @return mixed - */ - public function getAuthenticatedUser() - { - // Build the request path. - $path = '/user'; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Update a user. - * - * @param string $name The full name - * @param string $email The email - * @param string $blog The blog - * @param string $company The company - * @param string $location The location - * @param string $hireable If he is unemplayed :P - * @param string $bio The biometrical DNA fingerprint (or smthng...) - * - * @throws DomainException - * - * @return mixed - */ - public function edit($name = '', $email = '', $blog = '', $company = '', $location = '', $hireable = '', $bio = '') - { - $data = array( - 'name' => $name, - 'email' => $email, - 'blog' => $blog, - 'company' => $company, - 'location' => $location, - 'hireable' => $hireable, - 'bio' => $bio - ); - - // Build the request path. - $path = '/user'; - - // Send the request. - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), json_encode($data)) - ); - } - - /** - * Get all users. - * - * This provides a dump of every user, in the order that they signed up for GitHub. - * - * @param integer $since The integer ID of the last User that you’ve seen. - * - * @throws DomainException - * @return mixed - */ - public function getList($since = 0) - { - // Build the request path. - $path = '/users'; - - $path .= ($since) ? '?since=' . $since : ''; - - // Send the request. - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /* - * Legacy methods - */ - - /** - * Get a single user. - * - * @param string $user The users login name. - * - * @deprecated use users->get() - * - * @throws DomainException - * - * @return mixed - */ - public function getUser($user) - { - return $this->get($user); - } - - /** - * Update a user. - * - * @param string $name The full name - * @param string $email The email - * @param string $blog The blog - * @param string $company The company - * @param string $location The location - * @param string $hireable If he is unemplayed :P - * @param string $bio The biometrical DNA fingerprint (or smthng...) - * - * @deprecated use users->edit() - * - * @throws DomainException - * - * @return mixed - */ - public function updateUser($name = '', $email = '', $blog = '', $company = '', $location = '', $hireable = '', $bio = '') - { - return $this->edit($name = '', $email = '', $blog = '', $company = '', $location = '', $hireable = '', $bio = ''); - } - - /** - * Get all users. - * - * This provides a dump of every user, in the order that they signed up for GitHub. - * - * @param integer $since The integer ID of the last User that you’ve seen. - * - * @deprecated use users->getList() - * - * @throws DomainException - * @return mixed - */ - public function getUsers($since = 0) - { - return $this->getList($since); - } -} diff --git a/libraries/joomla/github/package/users/emails.php b/libraries/joomla/github/package/users/emails.php deleted file mode 100644 index f6676b39c8..0000000000 --- a/libraries/joomla/github/package/users/emails.php +++ /dev/null @@ -1,92 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Add email address(es). - * - * @param string|array $email The email address(es). - * - * @since 3.3 (CMS) - * - * @return object - */ - public function add($email) - { - // Build the request path. - $path = '/user/emails'; - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode($email)), - 201 - ); - } - - /** - * Delete email address(es). - * - * @param string|array $email The email address(es). - * - * @since 3.3 (CMS) - * - * @return object - */ - public function delete($email) - { - // Build the request path. - $path = '/user/emails'; - - $this->client->setOption('body', json_encode($email)); - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/users/followers.php b/libraries/joomla/github/package/users/followers.php deleted file mode 100644 index fdc674a9e5..0000000000 --- a/libraries/joomla/github/package/users/followers.php +++ /dev/null @@ -1,145 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List users followed by another user. - * - * @param string $user The name of the user. If not set the current authenticated user will be used. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getListFollowedBy($user = '') - { - // Build the request path. - $path = ($user) - ? '/users/' . $user . '/following' - : '/user/following'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Check if you are following a user. - * - * @param string $user The name of the user. - * - * @throws UnexpectedValueException - * @since 3.3 (CMS) - * - * @return boolean - */ - public function check($user) - { - // Build the request path. - $path = '/user/following/' . $user; - - $response = $this->client->get($this->fetchUrl($path)); - - switch ($response->code) - { - case '204' : - // You are following this user - return true; - break; - - case '404' : - // You are not following this user - return false; - break; - - default : - throw new UnexpectedValueException('Unexpected response code: ' . $response->code); - break; - } - } - - /** - * Follow a user. - * - * Following a user requires the user to be logged in and authenticated with - * basic auth or OAuth with the user:follow scope. - * - * @param string $user The name of the user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function follow($user) - { - // Build the request path. - $path = '/user/following/' . $user; - - return $this->processResponse( - $this->client->put($this->fetchUrl($path), ''), - 204 - ); - } - - /** - * Unfollow a user. - * - * Unfollowing a user requires the user to be logged in and authenticated with - * basic auth or OAuth with the user:follow scope. - * - * @param string $user The name of the user. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function unfollow($user) - { - // Build the request path. - $path = '/user/following/' . $user; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/package/users/keys.php b/libraries/joomla/github/package/users/keys.php deleted file mode 100644 index f6905b9928..0000000000 --- a/libraries/joomla/github/package/users/keys.php +++ /dev/null @@ -1,155 +0,0 @@ -processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * List your public keys. - * - * Lists the current user’s keys. - * Management of public keys via the API requires that you are authenticated - * through basic auth, or OAuth with the ‘user’ scope. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function getList() - { - // Build the request path. - $path = '/users/keys'; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Get a single public key. - * - * @param integer $id The id of the key. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function get($id) - { - // Build the request path. - $path = '/users/keys/' . $id; - - return $this->processResponse( - $this->client->get($this->fetchUrl($path)) - ); - } - - /** - * Create a public key - * - * @param string $title The title of the key. - * @param string $key The key. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function create($title, $key) - { - // Build the request path. - $path = '/users/keys'; - - $data = array( - 'title' => $title, - 'key' => $key - ); - - return $this->processResponse( - $this->client->post($this->fetchUrl($path), json_encode($data)), - 201 - ); - } - - /** - * Update a public key. - * - * @param integer $id The id of the key. - * @param string $title The title of the key. - * @param string $key The key. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function edit($id, $title, $key) - { - // Build the request path. - $path = '/users/keys/' . $id; - - $data = array( - 'title' => $title, - 'key' => $key - ); - - return $this->processResponse( - $this->client->patch($this->fetchUrl($path), json_encode($data)) - ); - } - - /** - * Delete a public key. - * - * @param integer $id The id of the key. - * - * @since 3.3 (CMS) - * - * @return object - */ - public function delete($id) - { - // Build the request path. - $path = '/users/keys/' . (int) $id; - - return $this->processResponse( - $this->client->delete($this->fetchUrl($path)), - 204 - ); - } -} diff --git a/libraries/joomla/github/refs.php b/libraries/joomla/github/refs.php deleted file mode 100644 index 77ba56d4fb..0000000000 --- a/libraries/joomla/github/refs.php +++ /dev/null @@ -1,175 +0,0 @@ -refs->create() - * - * @return object - * - * @since 11.3 - */ - public function create($user, $repo, $ref, $sha) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/git/refs'; - - // Build the request data. - $data = json_encode( - array( - 'ref' => $ref, - 'sha' => $sha - ) - ); - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to update a reference. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $ref The reference to update. - * @param string $sha The SHA1 value to set the reference to. - * @param string $force Whether the update should be forced. Default to false. - * - * @deprecated use data->refs->edit() - * - * @return object - * - * @since 11.3 - */ - public function edit($user, $repo, $ref, $sha, $force = false) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/git/refs/' . $ref; - - // Craete the data object. - $data = new stdClass; - - // If a title is set add it to the data object. - if ($force) - { - $data->force = true; - } - - $data->sha = $sha; - - // Encode the request data. - $data = json_encode($data); - - // Send the request. - $response = $this->client->patch($this->fetchUrl($path), $data); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to get a reference. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $ref The reference to get. - * - * @deprecated use data->refs->get() - * - * @return object - * - * @since 11.3 - */ - public function get($user, $repo, $ref) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/git/refs/' . $ref; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list references for a repository. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $namespace Optional sub-namespace to limit the returned references. - * @param integer $page Page to request - * @param integer $limit Number of results to return per page - * - * @deprecated use data->refs->getList() - * - * @return array - * - * @since 11.3 - */ - public function getList($user, $repo, $namespace = '', $page = 0, $limit = 0) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/git/refs' . $namespace; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path, $page, $limit)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/github/statuses.php b/libraries/joomla/github/statuses.php deleted file mode 100644 index 109a4c7508..0000000000 --- a/libraries/joomla/github/statuses.php +++ /dev/null @@ -1,107 +0,0 @@ -statuses->create() - * - * @return object - * - * @since 12.3 - */ - public function create($user, $repo, $sha, $state, $targetUrl = null, $description = null) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/statuses/' . $sha; - - if (!in_array($state, array('pending', 'success', 'error', 'failure'))) - { - throw new InvalidArgumentException('State must be one of pending, success, error or failure.'); - } - - // Build the request data. - $data = array( - 'state' => $state - ); - - if (!is_null($targetUrl)) - { - $data['target_url'] = $targetUrl; - } - - if (!is_null($description)) - { - $data['description'] = $description; - } - - // Send the request. - $response = $this->client->post($this->fetchUrl($path), json_encode($data)); - - // Validate the response code. - if ($response->code != 201) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * Method to list statuses for an SHA. - * - * @param string $user The name of the owner of the GitHub repository. - * @param string $repo The name of the GitHub repository. - * @param string $sha SHA1 for which to get the statuses. - * - * @deprecated use repositories->statuses->getList() - * - * @return array - * - * @since 12.3 - */ - public function getList($user, $repo, $sha) - { - // Build the request path. - $path = '/repos/' . $user . '/' . $repo . '/statuses/' . $sha; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if ($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubAccountTest.php b/tests/unit/suites/libraries/joomla/github/JGithubAccountTest.php deleted file mode 100644 index 552971bf88..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubAccountTest.php +++ /dev/null @@ -1,480 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubAccount($this->options, $this->client); - } - - /** - * Tests the createAuthorisation method - * - * @return void - * - * @since 12.3 - */ - public function testCreateAuthorisation() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $authorisation = new stdClass; - $authorisation->scopes = array('public_repo'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/authorizations', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->createAuthorisation(array('public_repo'), 'My test app', 'http://www.joomla.org'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createAuthorisation method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testCreateAuthorisationFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $authorisation = new stdClass; - $authorisation->scopes = array('public_repo'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/authorizations', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->createAuthorisation(array('public_repo'), 'My test app', 'http://www.joomla.org'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the deleteAuthorisation method - * - * @return void - * - * @since 12.3 - */ - public function testDeleteAuthorisation() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/authorizations/42') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->deleteAuthorisation(42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the deleteAuthorisation method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testDeleteAuthorisationFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/authorizations/42') - ->will($this->returnValue($returnData)); - - try - { - $this->object->deleteAuthorisation(42); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the editAuthorisation method - Add scopes - * - * @return void - * - * @since 12.3 - */ - public function testEditAuthorisationAddScopes() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $authorisation = new stdClass; - $authorisation->add_scopes = array('public_repo', 'gist'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/authorizations/42', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->editAuthorisation(42, array(), array('public_repo', 'gist'), array(), 'My test app', 'http://www.joomla.org'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editAuthorisation method - Remove scopes - * - * @return void - * - * @since 12.3 - */ - public function testEditAuthorisationRemoveScopes() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $authorisation = new stdClass; - $authorisation->remove_scopes = array('public_repo', 'gist'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/authorizations/42', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->editAuthorisation(42, array(), array(), array('public_repo', 'gist'), 'My test app', 'http://www.joomla.org'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editAuthorisation method - Scopes param - * - * @return void - * - * @since 12.3 - */ - public function testEditAuthorisationScopes() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $authorisation = new stdClass; - $authorisation->scopes = array('public_repo', 'gist'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/authorizations/42', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->editAuthorisation(42, array('public_repo', 'gist'), array(), array(), 'My test app', 'http://www.joomla.org'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editAuthorisation method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testEditAuthorisationFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $authorisation = new stdClass; - $authorisation->add_scopes = array('public_repo', 'gist'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/authorizations/42', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->editAuthorisation(42, array(), array('public_repo', 'gist'), array(), 'My test app', 'http://www.joomla.org'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the editAuthorisation method - too many scope params - * - * @return void - * - * @since 12.3 - * - * @expectedException RuntimeException - */ - public function testEditAuthorisationTooManyScopes() - { - $this->object->editAuthorisation(42, array(), array('public_repo', 'gist'), array('public_repo', 'gist'), 'My test app', 'http://www.joomla.org'); - } - - /** - * Tests the getAuthorisation method - * - * @return void - * - * @since 12.3 - */ - public function testGetAuthorisation() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/authorizations/42') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getAuthorisation(42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getAuthorisation method - failure - * - * @return void - * - * @since 12.1 - * - * @expectedException DomainException - */ - public function testGetAuthorisationFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/authorizations/42') - ->will($this->returnValue($returnData)); - - $this->object->getAuthorisation(42); - } - - /** - * Tests the getAuthorisations method - * - * @return void - * - * @since 12.3 - */ - public function testGetAuthorisations() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/authorizations') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getAuthorisations(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getAuthorisations method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testGetAuthorisationsFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/authorizations') - ->will($this->returnValue($returnData)); - - $this->object->getAuthorisations(); - } - - /** - * Tests the getRateLimit method - * - * @return void - * - * @since 12.3 - */ - public function testGetRateLimit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/rate_limit') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getRateLimit(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getRateLimit method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testGetRateLimitFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/rate_limit') - ->will($this->returnValue($returnData)); - - $this->object->getRateLimit(); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubCommitsTest.php b/tests/unit/suites/libraries/joomla/github/JGithubCommitsTest.php deleted file mode 100644 index 472e8929ca..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubCommitsTest.php +++ /dev/null @@ -1,627 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubCommits($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - * - * @since 12.1 - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $pull = new stdClass; - $pull->message = 'My latest commit'; - $pull->tree = 'abc1234'; - $pull->parents = array('def5678'); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/commits', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'My latest commit', 'abc1234', array('def5678')), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - simulated failure - * - * @return void - * - * @since 12.1 - */ - public function testCreateFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $pull = new stdClass; - $pull->message = 'My latest commit'; - $pull->tree = 'abc1234'; - $pull->parents = array('def5678'); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/commits', json_encode($pull)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->create('joomla', 'joomla-platform', 'My latest commit', 'abc1234', array('def5678')); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the createCommitComment method - * - * @return void - * - * @since 12.1 - */ - public function testCreateCommitComment() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - // The comment data - $comment = new stdClass; - $comment->body = 'My Insightful Comment'; - $comment->commit_id = 'abc1234'; - $comment->line = 1; - $comment->path = 'path/to/file'; - $comment->position = 254; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/commits/abc1234/comments', json_encode($comment)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->createCommitComment('joomla', 'joomla-platform', 'abc1234', 'My Insightful Comment', 1, 'path/to/file', 254), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createCommitComment method - simulated failure - * - * @return void - * - * @since 12.1 - */ - public function testCreateCommitCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - // The comment data - $comment = new stdClass; - $comment->body = 'My Insightful Comment'; - $comment->commit_id = 'abc1234'; - $comment->line = 1; - $comment->path = 'path/to/file'; - $comment->position = 254; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/commits/abc1234/comments', json_encode($comment)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->createCommitComment('joomla', 'joomla-platform', 'abc1234', 'My Insightful Comment', 1, 'path/to/file', 254); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the deleteCommitComment method - * - * @return void - * - * @since 12.1 - */ - public function testDeleteCommitComment() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/comments/42') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->deleteCommitComment('joomla', 'joomla-platform', 42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the deleteCommitComment method - simulated failure - * - * @return void - * - * @since 12.1 - */ - public function testDeleteCommitCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/comments/42') - ->will($this->returnValue($returnData)); - - try - { - $this->object->deleteCommitComment('joomla', 'joomla-platform', 42); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the editCommitComment method - * - * @return void - * - * @since 12.1 - */ - public function testEditCommitComment() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - // The comment data - $comment = new stdClass; - $comment->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/comments/42', json_encode($comment)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->editCommitComment('joomla', 'joomla-platform', 42, 'My Insightful Comment'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editCommitComment method - simulated failure - * - * @return void - * - * @since 12.1 - */ - public function testEditCommitCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - // The comment data - $comment = new stdClass; - $comment->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/comments/42', json_encode($comment)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->editCommitComment('joomla', 'joomla-platform', 42, 'My Insightful Comment'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getCommit method - * - * @return void - * - * @since 12.1 - */ - public function testGetCommit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/commits/abc1234') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getCommit('joomla', 'joomla-platform', 'abc1234'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getCommit method - failure - * - * @return void - * - * @since 12.1 - * - * @expectedException DomainException - */ - public function testGetCommitFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/commits/abc1234') - ->will($this->returnValue($returnData)); - - $this->object->getCommit('joomla', 'joomla-platform', 'abc1234'); - } - - /** - * Tests the getCommitComment method - * - * @return void - * - * @since 12.1 - */ - public function testGetCommitComment() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/comments/42') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getCommitComment('joomla', 'joomla-platform', 42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getCommitComment method - failure - * - * @return void - * - * @since 12.1 - * - * @expectedException DomainException - */ - public function testGetCommitCommentFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/comments/42') - ->will($this->returnValue($returnData)); - - $this->object->getCommitComment('joomla', 'joomla-platform', 42); - } - - /** - * Tests the getCommitComments method - * - * @return void - * - * @since 12.1 - */ - public function testGetCommitComments() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/commits/abc1234/comments') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getCommitComments('joomla', 'joomla-platform', 'abc1234'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getCommitComments method - failure - * - * @return void - * - * @since 12.1 - * - * @expectedException DomainException - */ - public function testGetCommitCommentsFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/commits/abc1234/comments') - ->will($this->returnValue($returnData)); - - $this->object->getCommitComments('joomla', 'joomla-platform', 'abc1234'); - } - - /** - * Tests the getDiff method - * - * @return void - * - * @since 12.1 - */ - public function testGetDiff() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/compare/master...staging') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getDiff('joomla', 'joomla-platform', 'master', 'staging'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getDiff method - failure - * - * @return void - * - * @since 12.1 - * - * @expectedException DomainException - */ - public function testGetDiffFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/compare/master...staging') - ->will($this->returnValue($returnData)); - - $this->object->getDiff('joomla', 'joomla-platform', 'master', 'staging'); - } - - /** - * Tests the getList method - * - * @return void - * - * @since 12.1 - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/commits') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @return void - * - * @since 12.1 - * - * @expectedException DomainException - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/commits') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform'); - } - - /** - * Tests the getListComments method - * - * @return void - * - * @since 12.1 - */ - public function testGetListComments() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/comments') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getListComments('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListComments method - failure - * - * @return void - * - * @since 12.1 - * - * @expectedException DomainException - */ - public function testGetListCommentsFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/comments') - ->will($this->returnValue($returnData)); - - $this->object->getListComments('joomla', 'joomla-platform'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubForksTest.php b/tests/unit/suites/libraries/joomla/github/JGithubForksTest.php deleted file mode 100644 index 607544abaf..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubForksTest.php +++ /dev/null @@ -1,169 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubForks($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 202; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'org' => 'jenkins-jools' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/forks', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'jenkins-jools'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array() - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/forks', $data) - ->will($this->returnValue($returnData)); - - $this->object->create('joomla', 'joomla-platform', ''); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/forks') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/forks') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubGistsTest.php b/tests/unit/suites/libraries/joomla/github/JGithubGistsTest.php deleted file mode 100644 index c4012c5c77..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubGistsTest.php +++ /dev/null @@ -1,1171 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageGists($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'files' => array( - 'file2.txt' => array('content' => 'This is the second file') - ), - 'public' => true, - 'description' => 'This is a gist' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create( - array( - 'file2.txt' => 'This is the second file' - ), - true, - 'This is a gist' - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method loading file content from a file - * - * @return void - */ - public function testCreateGistFromFile() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'files' => array( - 'gittest' => array('content' => 'GistContent' . "\n") - ), - 'public' => true, - 'description' => 'This is a gist' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create( - array( - JPATH_TESTS . '/tmp/gittest' - ), - true, - 'This is a gist' - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method loading file content from a file - file does not exist - * - * @expectedException InvalidArgumentException - * - * @return void - */ - public function testCreateGistFromFileNotFound() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->sampleString; - - $this->object->create( - array( - JPATH_BASE . '/gittest_notfound' - ), - true, - 'This is a gist' - ); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreateFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array('files' => array(), 'public' => true, 'description' => 'This is a gist') - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists', $data) - ->will($this->returnValue($returnData)); - - try - { - $this->object->create(array(), true, 'This is a gist'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the createComment method - simulated failure - * - * @return void - */ - public function testCreateComment() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $gist = new stdClass; - $gist->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists/523/comments', json_encode($gist)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->createComment(523, 'My Insightful Comment'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createComment method - simulated failure - * - * @return void - */ - public function testCreateCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $gist = new stdClass; - $gist->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists/523/comments', json_encode($gist)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->createComment(523, 'My Insightful Comment'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the delete method - * - * @return void - */ - public function testDelete() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/254') - ->will($this->returnValue($returnData)); - - $this->object->delete(254); - } - - /** - * Tests the delete method - simulated failure - * - * @return void - */ - public function testDeleteFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/254') - ->will($this->returnValue($returnData)); - - try - { - $this->object->delete(254); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the deleteComment method - * - * @return void - */ - public function testDeleteComment() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/comments/254') - ->will($this->returnValue($returnData)); - - $this->object->deleteComment(254); - } - - /** - * Tests the deleteComment method - simulated failure - * - * @return void - */ - public function testDeleteCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/comments/254') - ->will($this->returnValue($returnData)); - - try - { - $this->object->deleteComment(254); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the edit method - * - * @return void - */ - public function testEdit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'description' => 'This is a gist', - 'public' => true, - 'files' => array( - 'file1.txt' => array('content' => 'This is the first file'), - 'file2.txt' => array('content' => 'This is the second file') - ) - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/gists/512', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit( - 512, - array( - 'file1.txt' => 'This is the first file', - 'file2.txt' => 'This is the second file' - ), - true, - 'This is a gist' - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - simulated failure - * - * @return void - */ - public function testEditFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'description' => 'This is a gist', - 'public' => true, - 'files' => array( - 'file1.txt' => array('content' => 'This is the first file'), - 'file2.txt' => array('content' => 'This is the second file') - ) - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/gists/512', $data) - ->will($this->returnValue($returnData)); - - try - { - $this->object->edit( - 512, - array( - 'file1.txt' => 'This is the first file', - 'file2.txt' => 'This is the second file' - ), - true, - 'This is a gist' - ); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the editComment method - * - * @return void - */ - public function testEditComment() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $gist = new stdClass; - $gist->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/gists/comments/523', json_encode($gist)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->editComment(523, 'This comment is now even more insightful'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editComment method - simulated failure - * - * @return void - */ - public function testEditCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $gist = new stdClass; - $gist->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/gists/comments/523', json_encode($gist)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->editComment(523, 'This comment is now even more insightful'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the fork method - * - * @return void - */ - public function testFork() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists/523/fork') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->fork(523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the fork method - simulated failure - * - * @return void - */ - public function testForkFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists/523/fork') - ->will($this->returnValue($returnData)); - - try - { - $this->object->fork(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the get method - * - * @return void - */ - public function testGet() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->get(523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - simulated failure - * - * @return void - */ - public function testGetFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523') - ->will($this->returnValue($returnData)); - - try - { - $this->object->get(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getComment method - * - * @return void - */ - public function testGetComment() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/comments/523') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getComment(523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComment method - simulated failure - * - * @return void - */ - public function testGetCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/comments/523') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getComment(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getComments method - * - * @return void - */ - public function testGetComments() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/comments') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getComments(523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComments method - simulated failure - * - * @return void - */ - public function testGetCommentsFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/comments') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getComments(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - simulated failure - * - * @return void - */ - public function testGetListFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getList(); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getListByUser method - * - * @return void - */ - public function testGetListByUser() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/gists') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getListByUser('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListByUser method - simulated failure - * - * @return void - */ - public function testGetListByUserFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/gists') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getListByUser('joomla'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getListPublic method - * - * @return void - */ - public function testGetListPublic() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/public') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getListPublic(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListPublic method - simulated failure - * - * @return void - */ - public function testGetListPublicFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/public') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getListPublic(); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getListStarred method - * - * @return void - */ - public function testGetListStarred() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/starred') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getListStarred(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListStarred method - simulated failure - * - * @return void - */ - public function testGetListStarredFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/starred') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getListStarred(); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the isStarred method when the gist has been starred - * - * @return void - */ - public function testIsStarredTrue() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->isStarred(523), - $this->equalTo(true) - ); - } - - /** - * Tests the isStarred method when the gist has not been starred - * - * @return void - */ - public function testIsStarredFalse() - { - $returnData = new stdClass; - $returnData->code = 404; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->isStarred(523), - $this->equalTo(false) - ); - } - - /** - * Tests the isStarred method expecting a failure response - * - * @return void - */ - public function testIsStarredFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - try - { - $this->object->isStarred(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the star method - * - * @return void - */ - public function testStar() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/gists/523/star', '') - ->will($this->returnValue($returnData)); - - $this->object->star(523); - } - - /** - * Tests the star method - simulated failure - * - * @return void - */ - public function testStarFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 504; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/gists/523/star', '') - ->will($this->returnValue($returnData)); - - try - { - $this->object->star(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the unstar method - * - * @return void - */ - public function testUnstar() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - $this->object->unstar(523); - } - - /** - * Tests the unstar method - simulated failure - * - * @return void - */ - public function testUnstarFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 504; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - try - { - $this->object->unstar(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubHooksTest.php b/tests/unit/suites/libraries/joomla/github/JGithubHooksTest.php deleted file mode 100644 index 592a99efc8..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubHooksTest.php +++ /dev/null @@ -1,442 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubHooks($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - * - * @since 12.3 - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $hook = new stdClass; - $hook->name = 'acunote'; - $hook->config = array('token' => '123456789'); - $hook->events = array('push', 'public'); - $hook->active = true; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/hooks', json_encode($hook)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'acunote', array('token' => '123456789'), array('push', 'public')), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testCreateFailure() - { - $exception = false; - - $this->response->code = 500; - $this->response->body = $this->errorString; - - $hook = new stdClass; - $hook->name = 'acunote'; - $hook->config = array('token' => '123456789'); - $hook->events = array('push', 'public'); - $hook->active = true; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/hooks', json_encode($hook)) - ->will($this->returnValue($this->response)); - - try - { - $this->object->create('joomla', 'joomla-platform', 'acunote', array('token' => '123456789'), array('push', 'public')); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the create method - unauthorised event - * - * @return void - * - * @since 12.3 - * - * @expectedException RuntimeException - */ - public function testCreateUnauthorisedEvent() - { - $this->object->create('joomla', 'joomla-platform', 'acunote', array('token' => '123456789'), array('push', 'faker')); - } - - /** - * Tests the delete method - * - * @return void - * - * @since 12.3 - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/hooks/42') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', 42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the delete method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testDeleteFailure() - { - $exception = false; - - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/hooks/42') - ->will($this->returnValue($this->response)); - - try - { - $this->object->delete('joomla', 'joomla-platform', 42); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the edit method - * - * @return void - * - * @since 12.3 - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $hook = new stdClass; - $hook->name = 'acunote'; - $hook->config = array('token' => '123456789'); - $hook->events = array('push', 'public'); - $hook->add_events = array('watch'); - $hook->remove_events = array('watch'); - $hook->active = true; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/hooks/42', json_encode($hook)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 42, 'acunote', array('token' => '123456789'), - array('push', 'public'), array('watch'), array('watch') - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testEditFailure() - { - $exception = false; - - $this->response->code = 500; - $this->response->body = $this->errorString; - - $hook = new stdClass; - $hook->name = 'acunote'; - $hook->config = array('token' => '123456789'); - $hook->events = array('push', 'public'); - $hook->add_events = array('watch'); - $hook->remove_events = array('watch'); - $hook->active = true; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/hooks/42', json_encode($hook)) - ->will($this->returnValue($this->response)); - - try - { - $this->object->edit('joomla', 'joomla-platform', 42, 'acunote', array('token' => '123456789'), - array('push', 'public'), array('watch'), array('watch') - ); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the edit method - unauthorised event - * - * @return void - * - * @since 12.3 - * - * @expectedException RuntimeException - */ - public function testEditUnauthorisedEvent() - { - $this->object->edit('joomla', 'joomla-platform', 42, 'acunote', array('token' => '123456789'), array('push', 'faker')); - } - - /** - * Tests the get method - * - * @return void - * - * @since 12.3 - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/hooks/42') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testGetFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/hooks/42') - ->will($this->returnValue($this->response)); - - $this->object->get('joomla', 'joomla-platform', 42); - } - - /** - * Tests the getList method - * - * @return void - * - * @since 12.3 - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/hooks') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testGetListFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/hooks') - ->will($this->returnValue($this->response)); - - $this->object->getList('joomla', 'joomla-platform'); - } - - /** - * Tests the test method - * - * @return void - * - * @since 12.3 - */ - public function testTest() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/hooks/42/test') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->test('joomla', 'joomla-platform', 42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the test method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testTestFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/hooks/42/test') - ->will($this->returnValue($this->response)); - - $this->object->test('joomla', 'joomla-platform', 42); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubHttpTest.php b/tests/unit/suites/libraries/joomla/github/JGithubHttpTest.php deleted file mode 100644 index fc856a1000..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubHttpTest.php +++ /dev/null @@ -1,91 +0,0 @@ -options = new JRegistry; - $this->transport = $this->getMock('JHttpTransportStream', array('request'), array($this->options), 'CustomTransport', false); - - $this->object = new JGithubHttp($this->options, $this->transport); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - * - * @since 11.4 - */ - protected function tearDown() - { - } - - /** - * Tests the __construct method - * - * @return void - * - * @since 12.3 - */ - public function test__Construct() - { - // Verify the options are set in the object - $this->assertThat( - $this->object->getOption('userAgent'), - $this->equalTo('JGitHub/2.0') - ); - - $this->assertThat( - $this->object->getOption('timeout'), - $this->equalTo(120) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubIssuesTest.php b/tests/unit/suites/libraries/joomla/github/JGithubIssuesTest.php deleted file mode 100644 index e44815eece..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubIssuesTest.php +++ /dev/null @@ -1,777 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageIssues($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->title = 'My issue'; - $issue->assignee = 'JoeUser'; - $issue->milestone = '11.5'; - $issue->labels = array(); - $issue->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'My issue', 'These are my changes - please review them', 'JoeUser', '11.5', array()), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->title = 'My issue'; - $issue->assignee = 'JoeUser'; - $issue->milestone = '11.5'; - $issue->labels = array(); - $issue->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->create('joomla', 'joomla-platform', 'My issue', 'These are my changes - please review them', 'JoeUser', '11.5', array()); - } - - /** - * Tests the createComment method - * - * @return void - */ - public function testCreateComment() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues/523/comments', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->createComment('joomla', 'joomla-platform', 523, 'My Insightful Comment'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateCommentFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues/523/comments', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->createComment('joomla', 'joomla-platform', 523, 'My Insightful Comment'); - } - - /** - * Tests the createLabel method - * - * @return void - */ - public function testCreateLabel() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->name = 'My Insightful Label'; - $issue->color = 'My Insightful Color'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/labels', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->createLabel('joomla', 'joomla-platform', 'My Insightful Label', 'My Insightful Color'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createLabel method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateLabelFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->name = 'My Insightful Label'; - $issue->color = 'My Insightful Color'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/labels', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->createLabel('joomla', 'joomla-platform', 'My Insightful Label', 'My Insightful Color'); - } - - /** - * Tests the deleteComment method - * - * @return void - */ - public function testDeleteComment() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/issues/comments/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteComment('joomla', 'joomla-platform', 254); - } - - /** - * Tests the deleteComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testDeleteCommentFailure() - { - $this->response->code = 504; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/issues/comments/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteComment('joomla', 'joomla-platform', 254); - } - - /** - * Tests the deleteLabel method - * - * @return void - */ - public function testDeleteLabel() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/labels/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteLabel('joomla', 'joomla-platform', 254); - } - - /** - * Tests the deleteLabel method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testDeleteLabelFailure() - { - $this->response->code = 504; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/labels/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteLabel('joomla', 'joomla-platform', 254); - } - - /** - * Tests the edit method - * - * @return void - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->title = 'My issue'; - $issue->body = 'These are my changes - please review them'; - $issue->state = 'Closed'; - $issue->assignee = 'JoeAssignee'; - $issue->milestone = '12.2'; - $issue->labels = array('Fixed'); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 523, 'Closed', 'My issue', 'These are my changes - please review them', - 'JoeAssignee', '12.2', array('Fixed') - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->title = 'My issue'; - $issue->body = 'These are my changes - please review them'; - $issue->state = 'Closed'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->edit('joomla', 'joomla-platform', 523, 'Closed', 'My issue', 'These are my changes - please review them'); - } - - /** - * Tests the editComment method - * - * @return void - */ - public function testEditComment() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/comments/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->editComment('joomla', 'joomla-platform', 523, 'This comment is now even more insightful'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditCommentFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/comments/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->editComment('joomla', 'joomla-platform', 523, 'This comment is now even more insightful'); - } - - /** - * Tests the editLabel method - * - * @return void - */ - public function testEditLabel() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->name = 'This label is now even more insightful'; - $issue->color = 'This color is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/labels/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->editLabel('joomla', 'joomla-platform', 523, 'This label is now even more insightful', 'This color is now even more insightful'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editLabel method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditLabelFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->name = 'This label is now even more insightful'; - $issue->color = 'This color is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/labels/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->editLabel('joomla', 'joomla-platform', 523, 'This label is now even more insightful', 'This color is now even more insightful'); - } - - /** - * Tests the get method - * - * @return void - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/523') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/523') - ->will($this->returnValue($this->response)); - - $this->object->get('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getComment method - * - * @return void - */ - public function testGetComment() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/comments/523') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getComment('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetCommentFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/comments/523') - ->will($this->returnValue($this->response)); - - $this->object->getComment('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getComments method - * - * @return void - */ - public function testGetComments() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/523/comments') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getComments('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComments method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetCommentsFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/523/comments') - ->will($this->returnValue($this->response)); - - $this->object->getComments('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getLabel method - * - * @return void - */ - public function testGetLabel() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels/My Insightful Label') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getLabel('joomla', 'joomla-platform', 'My Insightful Label'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getLabel method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetLabelFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels/My Insightful Label') - ->will($this->returnValue($this->response)); - - $this->object->getLabel('joomla', 'joomla-platform', 'My Insightful Label'); - } - - /** - * Tests the getLabels method - * - * @return void - */ - public function testGetLabels() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getLabels('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getLabels method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetLabelsFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels') - ->will($this->returnValue($this->response)); - - $this->object->getLabels('joomla', 'joomla-platform'); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/issues') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/issues') - ->will($this->returnValue($this->response)); - - $this->object->getList(); - } - - /** - * Tests the getListByRepository method - * - * @return void - */ - public function testGetListByRepository() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListByRepository('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListByRepository method with all parameters - * - * @return void - */ - public function testGetListByRepositoryAll() - { - $date = new JDate('January 1, 2012 12:12:12'); - - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with( - '/repos/joomla/joomla-platform/issues?milestone=25&state=closed&assignee=none&' . - 'mentioned=joomla-jenkins&labels=bug&sort=created&direction=asc&since=2012-01-01T12:12:12+00:00' - ) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListByRepository( - 'joomla', - 'joomla-platform', - '25', - 'closed', - 'none', - 'joomla-jenkins', - 'bug', - 'created', - 'asc', - $date - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListByRepository method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListByRepositoryFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues') - ->will($this->returnValue($this->response)); - - $this->object->getListByRepository('joomla', 'joomla-platform'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubMetaTest.php b/tests/unit/suites/libraries/joomla/github/JGithubMetaTest.php deleted file mode 100644 index 9ec594f0ed..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubMetaTest.php +++ /dev/null @@ -1,123 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubMeta($this->options, $this->client); - } - - /** - * Tests the getMeta method - * - * @return void - * - * @since 13.1 - */ - public function testGetMeta() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $decodedResponse = array( - 'hooks' => array('127.0.0.1', '192.168.1.1'), - 'git' => array('127.0.0.1') - ); - - $this->client->expects($this->once()) - ->method('get') - ->with('/meta') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getMeta(), - $this->equalTo($decodedResponse) - ); - } - - /** - * Tests the getMeta method - failure - * - * @return void - * - * @since 13.1 - * - * @expectedException DomainException - */ - public function testGetMetaFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/meta') - ->will($this->returnValue($this->response)); - - $this->object->getMeta(); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubMilestonesTest.php b/tests/unit/suites/libraries/joomla/github/JGithubMilestonesTest.php deleted file mode 100644 index fb496d8309..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubMilestonesTest.php +++ /dev/null @@ -1,365 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubMilestones($this->options, $this->client); - } - - /** - * Test... - * - * @param string $name The method name. - * - * @return string - */ - protected function getMethod($name) - { - $class = new ReflectionClass('JGithubMilestones'); - $method = $class->getMethod($name); - $method->setAccessible(true); - - return $method; - } - - /** - * Tests the create method - * - * @return void - * - * @since 12.3 - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $milestone = new stdClass; - $milestone->title = 'My Milestone'; - $milestone->state = 'open'; - $milestone->description = 'This milestone is impossible'; - $milestone->due_on = '2012-12-25T20:09:31Z'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/milestones', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'My Milestone', 'open', 'This milestone is impossible', '2012-12-25T20:09:31Z'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testCreateFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - $milestone = new stdClass; - $milestone->title = 'My Milestone'; - $milestone->state = 'open'; - $milestone->description = 'This milestone is impossible'; - $milestone->due_on = '2012-12-25T20:09:31Z'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/milestones', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->object->create('joomla', 'joomla-platform', 'My Milestone', 'open', 'This milestone is impossible', '2012-12-25T20:09:31Z'); - } - - /** - * Tests the edit method - * - * @return void - * - * @since 12.3 - */ - public function testEdit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $milestone = new stdClass; - $milestone->state = 'closed'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/milestones/523', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 523, null, 'closed'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method with all parameters - * - * @return void - * - * @since 12.3 - */ - public function testEditAllParameters() - { - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $milestone = new stdClass; - $milestone->title = 'This is the revised title.'; - $milestone->state = 'closed'; - $milestone->description = 'This describes it perfectly.'; - $milestone->due_on = '2012-12-25T20:09:31Z'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/milestones/523', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 523, 'This is the revised title.', 'closed', 'This describes it perfectly.', - '2012-12-25T20:09:31Z'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testEditFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $milestone = new stdClass; - $milestone->state = 'closed'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/milestones/523', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->object->edit('joomla', 'joomla-platform', 523, null, 'closed'); - } - - /** - * Tests the get method - * - * @return void - * - * @since 12.3 - */ - public function testGet() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones/523') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testGetFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones/523') - ->will($this->returnValue($returnData)); - - $this->object->get('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getList method - * - * @return void - * - * @since 12.3 - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones?state=open&sort=due_date&direction=desc') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones?state=open&sort=due_date&direction=desc') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform'); - } - - /** - * Tests the delete method - * - * @return void - * - * @since 12.3 - */ - public function testDelete() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/milestones/254') - ->will($this->returnValue($returnData)); - - $this->object->delete('joomla', 'joomla-platform', 254); - } - - /** - * Tests the delete method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testDeleteFailure() - { - $returnData = new stdClass; - $returnData->code = 504; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/milestones/254') - ->will($this->returnValue($returnData)); - - $this->object->delete('joomla', 'joomla-platform', 254); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubObjectTest.php b/tests/unit/suites/libraries/joomla/github/JGithubObjectTest.php deleted file mode 100644 index 2aab088abd..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubObjectTest.php +++ /dev/null @@ -1,132 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubObjectMock($this->options, $this->client); - } - - /** - * Data provider method for the fetchUrl method tests. - * - * @return array - */ - public function fetchUrlData() - { - return array( - 'Standard github - no pagination data' => array('https://api.github.com', '/gists', 0, 0, 'https://api.github.com/gists'), - 'Enterprise github - no pagination data' => array('https://mygithub.com', '/gists', 0, 0, 'https://mygithub.com/gists'), - 'Standard github - page 3' => array('https://api.github.com', '/gists', 3, 0, 'https://api.github.com/gists?page=3'), - 'Enterprise github - page 3, 50 per page' => array('https://mygithub.com', '/gists', 3, 50, 'https://mygithub.com/gists?page=3&per_page=50'), - ); - } - - /** - * Tests the fetchUrl method - * - * @param string $apiUrl @todo - * @param string $path @todo - * @param integer $page @todo - * @param integer $limit @todo - * @param string $expected @todo - * - * @dataProvider fetchUrlData - * - * @return void - */ - public function testFetchUrl($apiUrl, $path, $page, $limit, $expected) - { - $this->options->set('api.url', $apiUrl); - - $this->assertThat( - $this->object->fetchUrl($path, $page, $limit), - $this->equalTo($expected) - ); - } - - /** - * Tests the fetchUrl method with basic authentication data - * - * @return void - */ - public function testFetchUrlBasicAuth() - { - $this->options->set('api.url', 'https://api.github.com'); - - $this->options->set('api.username', 'MyTestUser'); - $this->options->set('api.password', 'MyTestPass'); - - $this->assertThat( - $this->object->fetchUrl('/gists', 0, 0), - $this->equalTo('https://MyTestUser:MyTestPass@api.github.com/gists') - ); - } - - /** - * Tests the fetchUrl method using an oAuth token. - * - * @return void - */ - public function testFetchUrlToken() - { - $this->options->set('api.url', 'https://api.github.com'); - - $this->options->set('gh.token', 'MyTestToken'); - - $this->assertThat( - $this->object->fetchUrl('/gists', 0, 0), - $this->equalTo('https://api.github.com/gists?access_token=MyTestToken') - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageActivityTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageActivityTest.php deleted file mode 100644 index 3ac23d6074..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageActivityTest.php +++ /dev/null @@ -1,59 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageActivity($this->options, $this->client); - } - - /** - * Tests the getList method. - * - * @return void - * - * @since ¿ - */ - public function testConstruct() - { - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageAuthorizationsTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageAuthorizationsTest.php deleted file mode 100644 index 05b8400090..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageAuthorizationsTest.php +++ /dev/null @@ -1,557 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubPackageAuthorization($this->options, $this->client); - } - - /** - * Tests the createAuthorisation method - * - * @return void - * - * @since 12.3 - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $authorisation = new stdClass; - $authorisation->scopes = array('public_repo'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/authorizations', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create(array('public_repo'), 'My test app', 'http://www.joomla.org'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createAuthorisation method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testCreateFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $authorisation = new stdClass; - $authorisation->scopes = array('public_repo'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/authorizations', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->create(array('public_repo'), 'My test app', 'http://www.joomla.org'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the deleteAuthorisation method - * - * @return void - * - * @since 12.3 - */ - public function testDelete() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/authorizations/42') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->delete(42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the deleteAuthorisation method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testDeleteFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/authorizations/42') - ->will($this->returnValue($returnData)); - - try - { - $this->object->delete(42); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the editAuthorisation method - Add scopes - * - * @return void - * - * @since 12.3 - */ - public function testEditAddScopes() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $authorisation = new stdClass; - $authorisation->add_scopes = array('public_repo', 'gist'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/authorizations/42', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit(42, array(), array('public_repo', 'gist'), array(), 'My test app', 'http://www.joomla.org'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editAuthorisation method - Remove scopes - * - * @return void - * - * @since 12.3 - */ - public function testEditRemoveScopes() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $authorisation = new stdClass; - $authorisation->remove_scopes = array('public_repo', 'gist'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/authorizations/42', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit(42, array(), array(), array('public_repo', 'gist'), 'My test app', 'http://www.joomla.org'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editAuthorisation method - Scopes param - * - * @return void - * - * @since 12.3 - */ - public function testEditScopes() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $authorisation = new stdClass; - $authorisation->scopes = array('public_repo', 'gist'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/authorizations/42', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit(42, array('public_repo', 'gist'), array(), array(), 'My test app', 'http://www.joomla.org'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editAuthorisation method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testEditFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $authorisation = new stdClass; - $authorisation->add_scopes = array('public_repo', 'gist'); - $authorisation->note = 'My test app'; - $authorisation->note_url = 'http://www.joomla.org'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/authorizations/42', json_encode($authorisation)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->edit(42, array(), array('public_repo', 'gist'), array(), 'My test app', 'http://www.joomla.org'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the editAuthorisation method - too many scope params - * - * @return void - * - * @since 12.3 - * - * @expectedException RuntimeException - */ - public function testEditTooManyScopes() - { - $this->object->edit(42, array(), array('public_repo', 'gist'), array('public_repo', 'gist'), 'My test app', 'http://www.joomla.org'); - } - - /** - * Tests the getAuthorisation method - * - * @return void - * - * @since 12.3 - */ - public function testGet() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/authorizations/42') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->get(42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getAuthorisation method - failure - * - * @return void - * - * @since 12.1 - * - * @expectedException DomainException - */ - public function testGetFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/authorizations/42') - ->will($this->returnValue($returnData)); - - $this->object->get(42); - } - - /** - * Tests the getAuthorisations method - * - * @return void - * - * @since 12.3 - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/authorizations') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getAuthorisations method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/authorizations') - ->will($this->returnValue($returnData)); - - $this->object->getList(); - } - - /** - * Tests the getRateLimit method - * - * @return void - * - * @since 12.3 - */ - public function testGetRateLimit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/rate_limit') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getRateLimit(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getRateLimit method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testGetRateLimitFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/rate_limit') - ->will($this->returnValue($returnData)); - - $this->object->getRateLimit(); - } - - public function testGetAuthorizationLink() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = 'https://github.com/login/oauth/authorize?client_id=12345' - . '&redirect_uri=aaa&scope=bbb&state=ccc'; - - $this->assertThat( - $this->object->getAuthorizationLink('12345', 'aaa', 'bbb', 'ccc'), - $this->equalTo($returnData->body) - ); - } - - public function testRequestToken() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = ''; - - $this->client->expects($this->once()) - ->method('post') - ->with('https://github.com/login/oauth/access_token') - ->will($this->returnValue($returnData)); - - - $this->assertThat( - $this->object->requestToken('12345', 'aaa', 'bbb', 'ccc'), - $this->equalTo($returnData->body) - ); - } - public function testRequestTokenJson() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = ''; - - $this->client->expects($this->once()) - ->method('post') - ->with('https://github.com/login/oauth/access_token') - ->will($this->returnValue($returnData)); - - - $this->assertThat( - $this->object->requestToken('12345', 'aaa', 'bbb', 'ccc', 'json'), - $this->equalTo($returnData->body) - ); - } - public function testRequestTokenXml() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = ''; - - $this->client->expects($this->once()) - ->method('post') - ->with('https://github.com/login/oauth/access_token') - ->will($this->returnValue($returnData)); - - - $this->assertThat( - $this->object->requestToken('12345', 'aaa', 'bbb', 'ccc', 'xml'), - $this->equalTo($returnData->body) - ); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testRequestTokenInvalidFormat() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = ''; - - $this->object->requestToken('12345', 'aaa', 'bbb', 'ccc', 'invalid'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageGistsTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageGistsTest.php deleted file mode 100644 index 878e2ffd9d..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageGistsTest.php +++ /dev/null @@ -1,1168 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubPackageGists($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'files' => array( - 'file2.txt' => array('content' => 'This is the second file') - ), - 'public' => true, - 'description' => 'This is a gist' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create( - array( - 'file2.txt' => 'This is the second file' - ), - true, - 'This is a gist' - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method loading file content from a file - * - * @return void - */ - public function testCreateGistFromFile() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'files' => array( - 'gittest' => array('content' => 'GistContent' . "\n") - ), - 'public' => true, - 'description' => 'This is a gist' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create( - array( - __DIR__ . '/stubs/gittest' - ), - true, - 'This is a gist' - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method loading file content from a file - file does not exist - * - * @expectedException InvalidArgumentException - * - * @return void - */ - public function testCreateGistFromFileNotFound() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->sampleString; - - $this->object->create( - array( - JPATH_BASE . '/gittest_notfound' - ), - true, - 'This is a gist' - ); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreateFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array('files' => array(), 'public' => true, 'description' => 'This is a gist') - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists', $data) - ->will($this->returnValue($returnData)); - - try - { - $this->object->create(array(), true, 'This is a gist'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the createComment method - simulated failure - * - * @return void - */ - public function testCreateComment() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $gist = new stdClass; - $gist->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists/523/comments', json_encode($gist)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->comments->create(523, 'My Insightful Comment'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createComment method - simulated failure - * - * @return void - */ - public function testCreateCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $gist = new stdClass; - $gist->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists/523/comments', json_encode($gist)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->comments->create(523, 'My Insightful Comment'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the delete method - * - * @return void - */ - public function testDelete() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/254') - ->will($this->returnValue($returnData)); - - $this->object->delete(254); - } - - /** - * Tests the delete method - simulated failure - * - * @return void - */ - public function testDeleteFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/254') - ->will($this->returnValue($returnData)); - - try - { - $this->object->delete(254); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the deleteComment method - * - * @return void - */ - public function testDeleteComment() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/comments/254') - ->will($this->returnValue($returnData)); - - $this->object->comments->delete(254); - } - - /** - * Tests the deleteComment method - simulated failure - * - * @return void - */ - public function testDeleteCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/comments/254') - ->will($this->returnValue($returnData)); - - try - { - $this->object->comments->delete(254); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the edit method - * - * @return void - */ - public function testEdit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'description' => 'This is a gist', - 'public' => true, - 'files' => array( - 'file1.txt' => array('content' => 'This is the first file'), - 'file2.txt' => array('content' => 'This is the second file') - ) - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/gists/512', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit( - 512, - array( - 'file1.txt' => 'This is the first file', - 'file2.txt' => 'This is the second file' - ), - true, - 'This is a gist' - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - simulated failure - * - * @return void - */ - public function testEditFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'description' => 'This is a gist', - 'public' => true, - 'files' => array( - 'file1.txt' => array('content' => 'This is the first file'), - 'file2.txt' => array('content' => 'This is the second file') - ) - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/gists/512', $data) - ->will($this->returnValue($returnData)); - - try - { - $this->object->edit( - 512, - array( - 'file1.txt' => 'This is the first file', - 'file2.txt' => 'This is the second file' - ), - true, - 'This is a gist' - ); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the editComment method - * - * @return void - */ - public function testEditComment() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $gist = new stdClass; - $gist->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/gists/comments/523', json_encode($gist)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->comments->edit(523, 'This comment is now even more insightful'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editComment method - simulated failure - * - * @return void - */ - public function testEditCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $gist = new stdClass; - $gist->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/gists/comments/523', json_encode($gist)) - ->will($this->returnValue($returnData)); - - try - { - $this->object->comments->edit(523, 'This comment is now even more insightful'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the fork method - * - * @return void - */ - public function testFork() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists/523/fork') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->fork(523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the fork method - simulated failure - * - * @return void - */ - public function testForkFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/gists/523/fork') - ->will($this->returnValue($returnData)); - - try - { - $this->object->fork(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the get method - * - * @return void - */ - public function testGet() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->get(523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - simulated failure - * - * @return void - */ - public function testGetFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523') - ->will($this->returnValue($returnData)); - - try - { - $this->object->get(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getComment method - * - * @return void - */ - public function testGetComment() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/comments/523') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->comments->get(523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComment method - simulated failure - * - * @return void - */ - public function testGetCommentFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/comments/523') - ->will($this->returnValue($returnData)); - - try - { - $this->object->comments->get(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getComments method - * - * @return void - */ - public function testGetComments() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/comments') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->comments->getList(523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComments method - simulated failure - * - * @return void - */ - public function testGetCommentsFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/comments') - ->will($this->returnValue($returnData)); - - try - { - $this->object->comments->getList(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - simulated failure - * - * @return void - */ - public function testGetListFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getList(); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getListByUser method - * - * @return void - */ - public function testGetListByUser() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/gists') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getListByUser('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListByUser method - simulated failure - * - * @return void - */ - public function testGetListByUserFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/gists') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getListByUser('joomla'); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getListPublic method - * - * @return void - */ - public function testGetListPublic() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/public') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getListPublic(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListPublic method - simulated failure - * - * @return void - */ - public function testGetListPublicFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/public') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getListPublic(); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the getListStarred method - * - * @return void - */ - public function testGetListStarred() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/starred') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getListStarred(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListStarred method - simulated failure - * - * @return void - */ - public function testGetListStarredFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/starred') - ->will($this->returnValue($returnData)); - - try - { - $this->object->getListStarred(); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the isStarred method when the gist has been starred - * - * @return void - */ - public function testIsStarredTrue() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->isStarred(523), - $this->equalTo(true) - ); - } - - /** - * Tests the isStarred method when the gist has not been starred - * - * @return void - */ - public function testIsStarredFalse() - { - $returnData = new stdClass; - $returnData->code = 404; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->isStarred(523), - $this->equalTo(false) - ); - } - - /** - * Tests the isStarred method expecting a failure response - * - * @return void - */ - public function testIsStarredFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - try - { - $this->object->isStarred(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the star method - * - * @return void - */ - public function testStar() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/gists/523/star', '') - ->will($this->returnValue($returnData)); - - $this->object->star(523); - } - - /** - * Tests the star method - simulated failure - * - * @return void - */ - public function testStarFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 504; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/gists/523/star', '') - ->will($this->returnValue($returnData)); - - try - { - $this->object->star(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the unstar method - * - * @return void - */ - public function testUnstar() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - $this->object->unstar(523); - } - - /** - * Tests the unstar method - simulated failure - * - * @return void - */ - public function testUnstarFailure() - { - $exception = false; - - $returnData = new stdClass; - $returnData->code = 504; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/gists/523/star') - ->will($this->returnValue($returnData)); - - try - { - $this->object->unstar(523); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageGitignoreTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageGitignoreTest.php deleted file mode 100644 index cb7d7b46fa..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageGitignoreTest.php +++ /dev/null @@ -1,184 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageGitignore($this->options, $this->client); - } - - /** - * Tests the getList method. - * - * @return void - * - * @since ¿ - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = '[ - "Actionscript", - "Android", - "AppceleratorTitanium", - "Autotools", - "Bancha", - "C", - "C++" - ]'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gitignore/templates', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the get method. - * - * @return void - * - * @since ¿ - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = '{ - "name": "C", - "source": "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects (inc. Windows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app\n" - }'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gitignore/templates/C', array(), 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('C'), - $this->equalTo(json_decode($this->response->body)) - ); - - } - - /** - * Tests the get method with raw return data. - * - * @return void - * - * @since ¿ - */ - public function testGetRaw() - { - $this->response->code = 200; - $this->response->body = '# Object files - *.o - - # Libraries - *.lib - *.a - - # Shared objects (inc. Windows DLLs) - *.dll - *.so - *.so.* - *.dylib - - # Executables - *.exe - *.out - *.app -'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gitignore/templates/C', array('Accept' => 'application/vnd.github.raw+json'), 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('C', true), - $this->equalTo($this->response->body) - ); - } - - /** - * Tests the get method with failure. - * - * @expectedException DomainException - * - * @since ¿ - * @return void - */ - public function testGetFailure() - { - $this->response->code = 404; - $this->response->body = '{"message":"Not found"}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/gitignore/templates/X', array(), 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('X'), - $this->equalTo(json_decode($this->response->body)) - ); - } - -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageIssuesTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageIssuesTest.php deleted file mode 100644 index 74158024ed..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageIssuesTest.php +++ /dev/null @@ -1,794 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageIssues($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->title = 'My issue'; - $issue->assignee = 'JoeUser'; - $issue->milestone = '11.5'; - $issue->labels = array(); - $issue->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'My issue', 'These are my changes - please review them', 'JoeUser', '11.5', array()), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->title = 'My issue'; - $issue->assignee = 'JoeUser'; - $issue->milestone = '11.5'; - $issue->labels = array(); - $issue->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->create('joomla', 'joomla-platform', 'My issue', 'These are my changes - please review them', 'JoeUser', '11.5', array()); - } - - /** - * Tests the createComment method - * - * @return void - */ - public function testCreateComment() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues/523/comments', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->comments->create('joomla', 'joomla-platform', 523, 'My Insightful Comment'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateCommentFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->body = 'My Insightful Comment'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues/523/comments', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->comments->create('joomla', 'joomla-platform', 523, 'My Insightful Comment'); - } - - /** - * Tests the createLabel method - * @todo move - * @return void - * - public function testCreateLabel() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->name = 'My Insightful Label'; - $issue->color = 'My Insightful Color'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/labels', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->createLabel('joomla', 'joomla-platform', 'My Insightful Label', 'My Insightful Color'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the createLabel method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testCreateLabelFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->name = 'My Insightful Label'; - $issue->color = 'My Insightful Color'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/labels', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->createLabel('joomla', 'joomla-platform', 'My Insightful Label', 'My Insightful Color'); - } - */ - - /** - * Tests the deleteComment method - * @todo move - * @return void - * - public function testDeleteComment() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/issues/comments/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteComment('joomla', 'joomla-platform', 254); - } - */ - - /** - * Tests the deleteComment method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testDeleteCommentFailure() - { - $this->response->code = 504; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/issues/comments/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteComment('joomla', 'joomla-platform', 254); - } - */ - - /** - * Tests the deleteLabel method - * @todo move - * @return void - * - public function testDeleteLabel() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/labels/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteLabel('joomla', 'joomla-platform', 254); - } - */ - - /** - * Tests the deleteLabel method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testDeleteLabelFailure() - { - $this->response->code = 504; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/labels/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteLabel('joomla', 'joomla-platform', 254); - } - */ - - /** - * Tests the edit method - * - * @return void - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->title = 'My issue'; - $issue->body = 'These are my changes - please review them'; - $issue->state = 'Closed'; - $issue->assignee = 'JoeAssignee'; - $issue->milestone = '12.2'; - $issue->labels = array('Fixed'); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 523, 'Closed', 'My issue', 'These are my changes - please review them', - 'JoeAssignee', '12.2', array('Fixed') - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->title = 'My issue'; - $issue->body = 'These are my changes - please review them'; - $issue->state = 'Closed'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->edit('joomla', 'joomla-platform', 523, 'Closed', 'My issue', 'These are my changes - please review them'); - } - - /** - * Tests the editComment method - * @todo move - * @return void - * - public function testEditComment() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/comments/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->editComment('joomla', 'joomla-platform', 523, 'This comment is now even more insightful'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the editComment method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testEditCommentFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/comments/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->editComment('joomla', 'joomla-platform', 523, 'This comment is now even more insightful'); - } - */ - - /** - * Tests the editLabel method - * @todo move - * @return void - * - public function testEditLabel() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $issue = new stdClass; - $issue->name = 'This label is now even more insightful'; - $issue->color = 'This color is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/labels/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->editLabel('joomla', 'joomla-platform', 523, 'This label is now even more insightful', 'This color is now even more insightful'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the editLabel method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testEditLabelFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $issue = new stdClass; - $issue->name = 'This label is now even more insightful'; - $issue->color = 'This color is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/labels/523', json_encode($issue)) - ->will($this->returnValue($this->response)); - - $this->object->editLabel('joomla', 'joomla-platform', 523, 'This label is now even more insightful', 'This color is now even more insightful'); - } - */ - - /** - * Tests the get method - * - * @return void - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/523') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/523') - ->will($this->returnValue($this->response)); - - $this->object->get('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getComment method - * @todo move - * @return void - * - public function testGetComment() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/comments/523') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getComment('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the getComment method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testGetCommentFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/comments/523') - ->will($this->returnValue($this->response)); - - $this->object->getComment('joomla', 'joomla-platform', 523); - } - */ - - /** - * Tests the getComments method - * @todo move - * @return void - * - public function testGetComments() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/523/comments') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getComments('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the getComments method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testGetCommentsFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/523/comments') - ->will($this->returnValue($this->response)); - - $this->object->getComments('joomla', 'joomla-platform', 523); - } - */ - - /** - * Tests the getLabel method - * @todo move - * @return void - * - public function testGetLabel() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels/My Insightful Label') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getLabel('joomla', 'joomla-platform', 'My Insightful Label'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the getLabel method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testGetLabelFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels/My Insightful Label') - ->will($this->returnValue($this->response)); - - $this->object->getLabel('joomla', 'joomla-platform', 'My Insightful Label'); - } - */ - - /** - * Tests the getLabels method - * @todo move - * @return void - * - public function testGetLabels() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getLabels('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the getLabels method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testGetLabelsFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels') - ->will($this->returnValue($this->response)); - - $this->object->getLabels('joomla', 'joomla-platform'); - } - */ - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/issues') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/issues') - ->will($this->returnValue($this->response)); - - $this->object->getList(); - } - - /** - * Tests the getListByRepository method - * - * @return void - */ - public function testGetListByRepository() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListByRepository('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListByRepository method with all parameters - * - * @return void - */ - public function testGetListByRepositoryAll() - { - $date = new JDate('January 1, 2012 12:12:12'); - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with( - '/repos/joomla/joomla-platform/issues?milestone=25&state=closed&assignee=none&' . - 'mentioned=joomla-jenkins&labels=bug&sort=created&direction=asc&since=2012-01-01T12:12:12+00:00' - ) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListByRepository( - 'joomla', - 'joomla-platform', - '25', - 'closed', - 'none', - 'joomla-jenkins', - 'bug', - 'created', - 'asc', - $date - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getListByRepository method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListByRepositoryFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues') - ->will($this->returnValue($this->response)); - - $this->object->getListByRepository('joomla', 'joomla-platform'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageMarkdownTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageMarkdownTest.php deleted file mode 100644 index 7027ae8fd9..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageMarkdownTest.php +++ /dev/null @@ -1,124 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageMarkdown($this->options, $this->client); - } - - /** - * @covers JGithubPackageMarkdown::render - * @todo Implement testRender(). - */ - public function testRender() - { - $this->response->code = 200; - $this->response->body = '

Hello world github/linguist#1 cool, ' - . 'and #1!

'; - - $text = 'Hello world github/linguist#1 **cool**, and #1!'; - $mode = 'gfm'; - $context = 'github/gollum'; - - $data = str_replace('\\/', '/', json_encode( - array( - 'text' => $text, - 'mode' => $mode, - 'context' => $context - ) - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/markdown', $data, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->render($text, $mode, $context), - $this->equalTo($this->response->body) - ); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testRenderInvalidMode() - { - $this->assertThat( - $this->object->render('', 'xxx', 'github/gollum'), - $this->equalTo('') - ); - } - - /** - * @expectedException DomainException - */ - public function testRenderFailure() - { - $this->response->code = 404; - $this->response->body = ''; - - $text = 'Hello world github/linguist#1 **cool**, and #1!'; - $mode = 'gfm'; - $context = 'github/gollum'; - - $data = str_replace('\\/', '/', json_encode( - array( - 'text' => $text, - 'mode' => $mode, - 'context' => $context - ) - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/markdown', $data, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->render($text, $mode, $context), - $this->equalTo('') - ); - } - -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageOrgsTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageOrgsTest.php deleted file mode 100644 index 8165e85f90..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageOrgsTest.php +++ /dev/null @@ -1,120 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageOrgs($this->options, $this->client); - } - - /** - * @covers JGithubPackageOrgs::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/orgs') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgs::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgs::edit - * @todo Implement testEdit(). - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/orgs/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'email@example.com'), - $this->equalTo(json_decode($this->sampleString)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackagePullsTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackagePullsTest.php deleted file mode 100644 index 5399150cf5..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackagePullsTest.php +++ /dev/null @@ -1,818 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubPackagePulls($this->options, $this->client); - } - - /** - * Test... - * - * @param string $name The method name. - * - * @return string - */ - protected function getMethod($name) - { - $class = new ReflectionClass('JGithubPulls'); - $method = $class->getMethod($name); - $method->setAccessible(true); - - return $method; - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $pull = new stdClass; - $pull->title = 'My Pull Request'; - $pull->base = 'staging'; - $pull->head = 'joomla-jenkins:mychanges'; - $pull->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'My Pull Request', 'staging', 'joomla-jenkins:mychanges', - 'These are my changes - please review them'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - $pull = new stdClass; - $pull->title = 'My Pull Request'; - $pull->base = 'staging'; - $pull->head = 'joomla-jenkins:mychanges'; - $pull->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->object->create('joomla', 'joomla-platform', 'My Pull Request', 'staging', 'joomla-jenkins:mychanges', - 'These are my changes - please review them'); - } - - /** - * Tests the createComment method - * @todo move - * @return void - * - public function testCreateComment() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $pull = new stdClass; - $pull->body = 'My Insightful Comment'; - $pull->commit_id = 'abcde12345'; - $pull->path = '/path/to/file'; - $pull->position = 254; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/523/comments', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->createComment('joomla', 'joomla-platform', 523, 'My Insightful Comment', 'abcde12345', '/path/to/file', 254), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the createComment method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testCreateCommentFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - $pull = new stdClass; - $pull->body = 'My Insightful Comment'; - $pull->commit_id = 'abcde12345'; - $pull->path = '/path/to/file'; - $pull->position = 254; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/523/comments', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->object->createComment('joomla', 'joomla-platform', 523, 'My Insightful Comment', 'abcde12345', '/path/to/file', 254); - } - */ - - /** - * Tests the createCommentReply method - * @todo move - * @return void - * - public function testCreateCommentReply() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $pull = new stdClass; - $pull->body = 'My Insightful Comment'; - $pull->in_reply_to = 434; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/523/comments', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->createCommentReply('joomla', 'joomla-platform', 523, 'My Insightful Comment', 434), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the createCommentReply method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testCreateCommentReplyFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - $pull = new stdClass; - $pull->body = 'My Insightful Comment'; - $pull->in_reply_to = 434; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/523/comments', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->object->createCommentReply('joomla', 'joomla-platform', 523, 'My Insightful Comment', 434); - } - */ - - /** - * Tests the createFromIssue method - * - * @return void - */ - public function testCreateFromIssue() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $pull = new stdClass; - $pull->issue = 254; - $pull->base = 'staging'; - $pull->head = 'joomla-jenkins:mychanges'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->createFromIssue('joomla', 'joomla-platform', 254, 'staging', 'joomla-jenkins:mychanges'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createFromIssue method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFromIssueFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - $pull = new stdClass; - $pull->issue = 254; - $pull->base = 'staging'; - $pull->head = 'joomla-jenkins:mychanges'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->object->createFromIssue('joomla', 'joomla-platform', 254, 'staging', 'joomla-jenkins:mychanges'); - } - - /** - * Tests the deleteComment method - * @todo move - * @return void - * - public function testDeleteComment() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/pulls/comments/254') - ->will($this->returnValue($returnData)); - - $this->object->deleteComment('joomla', 'joomla-platform', 254); - } - */ - - /** - * Tests the deleteComment method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testDeleteCommentFailure() - { - $returnData = new stdClass; - $returnData->code = 504; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/pulls/comments/254') - ->will($this->returnValue($returnData)); - - $this->object->deleteComment('joomla', 'joomla-platform', 254); - } - */ - - /** - * Tests the edit method - * - * @return void - */ - public function testEdit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $pull = new stdClass; - $pull->title = 'My Pull Request'; - $pull->body = 'These are my changes - please review them'; - $pull->state = 'Closed'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/523', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 523, 'My Pull Request', 'These are my changes - please review them', 'Closed'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $pull = new stdClass; - $pull->title = 'My Pull Request'; - $pull->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/523', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->object->edit('joomla', 'joomla-platform', 523, 'My Pull Request', 'These are my changes - please review them'); - } - - /** - * Tests the editComment method - * @todo move - * @return void - * - public function testEditComment() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $pull = new stdClass; - $pull->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/comments/523', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->editComment('joomla', 'joomla-platform', 523, 'This comment is now even more insightful'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the editComment method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testEditCommentFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $pull = new stdClass; - $pull->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/comments/523', json_encode($pull)) - ->will($this->returnValue($returnData)); - - $this->object->editComment('joomla', 'joomla-platform', 523, 'This comment is now even more insightful'); - } - */ - - /** - * Tests the get method - * - * @return void - */ - public function testGet() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523') - ->will($this->returnValue($returnData)); - - $this->object->get('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getComment method - * @todo move - * @return void - * - public function testGetComment() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/comments/523') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getComment('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the getComment method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testGetCommentFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/comments/523') - ->will($this->returnValue($returnData)); - - $this->object->getComment('joomla', 'joomla-platform', 523); - } - */ - - /** - * Tests the getComments method - * @todo move - * @return void - * - public function testGetComments() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/comments') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getComments('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - */ - - /** - * Tests the getComments method - failure - * @todo move - * @expectedException DomainException - * - * @return void - * - public function testGetCommentsFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/comments') - ->will($this->returnValue($returnData)); - - $this->object->getComments('joomla', 'joomla-platform', 523); - } - */ - - /** - * Tests the getCommits method - * - * @return void - */ - public function testGetCommits() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/commits') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getCommits('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getCommits method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetCommitsFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/commits') - ->will($this->returnValue($returnData)); - - $this->object->getCommits('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getFiles method - * - * @return void - */ - public function testGetFiles() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/files') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getFiles('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getFiles method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetFilesFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/files') - ->will($this->returnValue($returnData)); - - $this->object->getFiles('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls?state=closed') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', 'closed'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform'); - } - - /** - * Tests the isMerged method when the pull request has been merged - * - * @return void - */ - public function testIsMergedTrue() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->isMerged('joomla', 'joomla-platform', 523), - $this->equalTo(true) - ); - } - - /** - * Tests the isMerged method when the pull request has not been merged - * - * @return void - */ - public function testIsMergedFalse() - { - $returnData = new stdClass; - $returnData->code = 404; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->isMerged('joomla', 'joomla-platform', 523), - $this->equalTo(false) - ); - } - - /** - * Tests the isMerged method when the request fails - * - * @expectedException DomainException - * - * @return void - */ - public function testIsMergedFailure() - { - $returnData = new stdClass; - $returnData->code = 504; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($returnData)); - - $this->object->isMerged('joomla', 'joomla-platform', 523); - } - - /** - * Tests the merge method - * - * @return void - */ - public function testMerge() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->merge('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the merge method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testMergeFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($returnData)); - - $this->object->merge('joomla', 'joomla-platform', 523); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageRepositoriesTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageRepositoriesTest.php deleted file mode 100644 index ac167c1318..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageRepositoriesTest.php +++ /dev/null @@ -1,410 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageRepositories($this->options, $this->client); - } - - /** - * @covers JGithubPackageRepositories::getListOwn - * @todo Implement testGetListOwn(). - */ - public function testGetListOwn() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/repos?type=all&sort=full_name&direction=asc', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListOwn(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::getListOwn - * @todo Implement testGetListOwn(). - * - * @expectedException RuntimeException - */ - public function testGetListOwnInvalidType() - { - $this->object->getListOwn('INVALID'); - } - - /** - * @covers JGithubPackageRepositories::getListOwn - * @todo Implement testGetListOwn(). - * - * @expectedException RuntimeException - */ - public function testGetListOwnInvalidSortField() - { - $this->object->getListOwn('all', 'INVALID'); - } - - /** - * @covers JGithubPackageRepositories::getListOwn - * @todo Implement testGetListOwn(). - * - * @expectedException RuntimeException - */ - public function testGetListOwnInvalidSortOrder() - { - $this->object->getListOwn('all', 'full_name', 'INVALID'); - } - - /** - * @covers JGithubPackageRepositories::getListUser - * @todo Implement testGetListUser(). - */ - public function testGetListUser() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/repos?type=all&sort=full_name&direction=asc', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListUser('joomla'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @expectedException RuntimeException - */ - public function testGetListUserInvalidType() - { - $this->object->getListUser('joomla', 'INVALID'); - } - - /** - * @expectedException RuntimeException - */ - public function testGetListUserInvalidSortField() - { - $this->object->getListUser('joomla', 'all', 'INVALID'); - } - - /** - * @expectedException RuntimeException - */ - public function testGetListUserInvalidSortOrder() - { - $this->object->getListUser('joomla', 'all', 'full_name', 'INVALID'); - } - - /** - * @covers JGithubPackageRepositories::getListOrg - * @todo Implement testGetListOrg(). - */ - public function testGetListOrg() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/repos?type=all', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListOrg('joomla'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @expectedException RuntimeException - */ - public function testGetListOrgInvalidType() - { - $this->object->getListOrg('joomla', 'INVALID'); - } - - /** - * @covers JGithubPackageRepositories::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repositories', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::create - * @todo Implement testCreate(). - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/user/repos', - '{"name":"joomla-test","description":"","homepage":"","private":false,"has_issues":false,' - . '"has_wiki":false,"has_downloads":false,"team_id":0,"auto_init":false,"gitignore_template":""}', - 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla-test'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-cms', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-cms'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::edit - * @todo Implement testEdit(). - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-test', - '{"name":"joomla-test-1","description":"","homepage":"","private":false,"has_issues":false,' - . '"has_wiki":false,"has_downloads":false,"default_branch":""}', 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-test', 'joomla-test-1'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::getListContributors - * @todo Implement testGetListContributors(). - */ - public function testGetListContributors() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-cms/contributors', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListContributors('joomla', 'joomla-cms'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::getListLanguages - * @todo Implement testGetListLanguages(). - */ - public function testGetListLanguages() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-cms/languages', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListLanguages('joomla', 'joomla-cms'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::getListTeams - * @todo Implement testGetListTeams(). - */ - public function testGetListTeams() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-cms/teams', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListTeams('joomla', 'joomla-cms'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::getListTags - * @todo Implement testGetListTags(). - */ - public function testGetListTags() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-cms/tags', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListTags('joomla', 'joomla-cms'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::getListBranches - * @todo Implement testGetListBranches(). - */ - public function testGetListBranches() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-cms/branches', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListBranches('joomla', 'joomla-cms'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::getBranch - * @todo Implement testGetBranch(). - */ - public function testGetBranch() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-cms/branches/master', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getBranch('joomla', 'joomla-cms', 'master'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageRepositories::delete - * @todo Implement testDelete(). - */ - public function testDelete() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-cms', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-cms'), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageSearchTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageSearchTest.php deleted file mode 100644 index b28ef93a12..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageSearchTest.php +++ /dev/null @@ -1,155 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageSearch($this->options, $this->client); - } - - /** - * @covers JGithubPackageSearch::issues - * @todo Implement testIssues(). - */ - public function testIssues() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/legacy/issues/search/joomla/joomla-platform/open/github') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->issues('joomla', 'joomla-platform', 'open', 'github'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageSearch::issues - * @todo Implement testIssues(). - * - * @expectedException UnexpectedValueException - */ - public function testIssuesInvalidState() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->object->issues('joomla', 'joomla-platform', 'invalid', 'github'); - } - - /** - * @covers JGithubPackageSearch::repositories - * @todo Implement testRepositories(). - */ - public function testRepositories() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/legacy/repos/search/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->repositories('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageSearch::users - * @todo Implement testUsers(). - */ - public function testUsers() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/legacy/user/search/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->users('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageSearch::email - * @todo Implement testEmail(). - */ - public function testEmail() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/legacy/user/email/email@joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->email('email@joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageUsersTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageUsersTest.php deleted file mode 100644 index d4d34f55a4..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageUsersTest.php +++ /dev/null @@ -1,361 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageUsers($this->options, $this->client); - } - - /** - * Tests the getUser method - * - * @return void - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = '{ - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat", - "name": "monalisa octocat", - "company": "GitHub", - "blog": "https://github.com/blog", - "location": "San Francisco", - "email": "octocat@github.com", - "hireable": false, - "bio": "There once was...", - "public_repos": 2, - "public_gists": 1, - "followers": 20, - "following": 0, - "html_url": "https://github.com/octocat", - "created_at": "2008-01-14T04:33:35Z", - "type": "User" -}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getUser method with failure - * - * @expectedException DomainException - * @return void - */ - public function testGetFailure() - { - $this->response->code = 404; - $this->response->body = '{"message":"Not Found"}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/nonexistentuser', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('nonexistentuser'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getAuthenticatedUser method - * - * @return void - */ - public function testGetAuthenticatedUser() - { - $this->response->code = 200; - $this->response->body = '{ - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat", - "name": "monalisa octocat", - "company": "GitHub", - "blog": "https://github.com/blog", - "location": "San Francisco", - "email": "octocat@github.com", - "hireable": false, - "bio": "There once was...", - "public_repos": 2, - "public_gists": 1, - "followers": 20, - "following": 0, - "html_url": "https://github.com/octocat", - "created_at": "2008-01-14T04:33:35Z", - "type": "User", - "total_private_repos": 100, - "owned_private_repos": 100, - "private_gists": 81, - "disk_usage": 10000, - "collaborators": 8, - "plan": { - "name": "Medium", - "space": 400, - "collaborators": 10, - "private_repos": 20 - } -}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getAuthenticatedUser('joomla'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the GetAuthenticatedUser method with failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetAuthenticatedUserFailure() - { - $this->response->code = 401; - $this->response->body = '{"message":"Requires authentication"}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getAuthenticatedUser(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getUsers method - * - * @return void - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = '[ - { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - } -], - { - "login": "elkuku", - "id": 33978, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/elkuku" - } -]'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getUsers method - * - * @return void - */ - public function testEdit() - { - $name = 'monalisa octocat'; - $email = 'octocat@github.com'; - $blog = 'https =>//github.com/blog'; - $company = 'GitHub'; - $location = 'San Francisco'; - $hireable = true; - $bio = 'There once...'; - - $this->response->code = 200; - $this->response->body = '{ - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat", - "name": "' . $name . '", - "company": "GitHub", - "blog": "https://github.com/blog", - "location": "San Francisco", - "email": "octocat@github.com", - "hireable": false, - "bio": "There once was...", - "public_repos": 2, - "public_gists": 1, - "followers": 20, - "following": 0, - "html_url": "https://github.com/octocat", - "created_at": "2008-01-14T04:33:35Z", - "type": "User", - "total_private_repos": 100, - "owned_private_repos": 100, - "private_gists": 81, - "disk_usage": 10000, - "collaborators": 8, - "plan": { - "name": "Medium", - "space": 400, - "collaborators": 10, - "private_repos": 20 - } -}'; - - $input = json_encode( - array( - 'name' => $name, - 'email' => $email, - 'blog' => $blog, - 'company' => $company, - 'location' => $location, - 'hireable' => $hireable, - 'bio' => $bio - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/user', $input, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit($name, $email, $blog, $company, $location, $hireable, $bio), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getUsers method - * - * @expectedException DomainException - * - * @return void - */ - public function testEditFailure() - { - $name = 'monalisa octocat'; - $email = 'octocat@github.com'; - $blog = 'https =>//github.com/blog'; - $company = 'GitHub'; - $location = 'San Francisco'; - $hireable = true; - $bio = 'There once...'; - - $this->response->code = 404; - $this->response->body = $this->errorString; - - $input = json_encode( - array( - 'name' => $name, - 'email' => $email, - 'blog' => $blog, - 'company' => $company, - 'location' => $location, - 'hireable' => $hireable, - 'bio' => $bio - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/user', $input, 0, 0) - ->will($this->returnValue($this->response)); - - //$this->object->edit($name, $email, $blog, $company, $location, $hireable, $bio); - - - $this->assertThat( - $this->object->edit($name, $email, $blog, $company, $location, $hireable, $bio), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPullsTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPullsTest.php deleted file mode 100644 index bf8bec3aa3..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubPullsTest.php +++ /dev/null @@ -1,782 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackagePulls($this->options, $this->client); - } - - /** - * Test... - * - * @param string $name The method name. - * - * @return string - */ - protected function getMethod($name) - { - $class = new ReflectionClass('JGithubPulls'); - $method = $class->getMethod($name); - $method->setAccessible(true); - - return $method; - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $pull = new stdClass; - $pull->title = 'My Pull Request'; - $pull->base = 'staging'; - $pull->head = 'joomla-jenkins:mychanges'; - $pull->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'My Pull Request', 'staging', 'joomla-jenkins:mychanges', - 'These are my changes - please review them'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $pull = new stdClass; - $pull->title = 'My Pull Request'; - $pull->base = 'staging'; - $pull->head = 'joomla-jenkins:mychanges'; - $pull->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->object->create('joomla', 'joomla-platform', 'My Pull Request', 'staging', 'joomla-jenkins:mychanges', - 'These are my changes - please review them'); - } - - /** - * Tests the createComment method - * - * @return void - */ - public function testCreateComment() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $pull = new stdClass; - $pull->body = 'My Insightful Comment'; - $pull->commit_id = 'abcde12345'; - $pull->path = '/path/to/file'; - $pull->position = 254; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/523/comments', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->createComment('joomla', 'joomla-platform', 523, 'My Insightful Comment', 'abcde12345', '/path/to/file', 254), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateCommentFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $pull = new stdClass; - $pull->body = 'My Insightful Comment'; - $pull->commit_id = 'abcde12345'; - $pull->path = '/path/to/file'; - $pull->position = 254; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/523/comments', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->object->createComment('joomla', 'joomla-platform', 523, 'My Insightful Comment', 'abcde12345', '/path/to/file', 254); - } - - /** - * Tests the createCommentReply method - * - * @return void - */ - public function testCreateCommentReply() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $pull = new stdClass; - $pull->body = 'My Insightful Comment'; - $pull->in_reply_to = 434; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/523/comments', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->createCommentReply('joomla', 'joomla-platform', 523, 'My Insightful Comment', 434), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createCommentReply method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateCommentReplyFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $pull = new stdClass; - $pull->body = 'My Insightful Comment'; - $pull->in_reply_to = 434; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/523/comments', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->object->createCommentReply('joomla', 'joomla-platform', 523, 'My Insightful Comment', 434); - } - - /** - * Tests the createFromIssue method - * - * @return void - */ - public function testCreateFromIssue() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $pull = new stdClass; - $pull->issue = 254; - $pull->base = 'staging'; - $pull->head = 'joomla-jenkins:mychanges'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->createFromIssue('joomla', 'joomla-platform', 254, 'staging', 'joomla-jenkins:mychanges'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the createFromIssue method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFromIssueFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - $pull = new stdClass; - $pull->issue = 254; - $pull->base = 'staging'; - $pull->head = 'joomla-jenkins:mychanges'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->object->createFromIssue('joomla', 'joomla-platform', 254, 'staging', 'joomla-jenkins:mychanges'); - } - - /** - * Tests the deleteComment method - * - * @return void - */ - public function testDeleteComment() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/pulls/comments/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteComment('joomla', 'joomla-platform', 254); - } - - /** - * Tests the deleteComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testDeleteCommentFailure() - { - $this->response->code = 504; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/pulls/comments/254') - ->will($this->returnValue($this->response)); - - $this->object->deleteComment('joomla', 'joomla-platform', 254); - } - - /** - * Tests the edit method - * - * @return void - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $pull = new stdClass; - $pull->title = 'My Pull Request'; - $pull->body = 'These are my changes - please review them'; - $pull->state = 'Closed'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/523', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 523, 'My Pull Request', 'These are my changes - please review them', 'Closed'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $pull = new stdClass; - $pull->title = 'My Pull Request'; - $pull->body = 'These are my changes - please review them'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/523', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->object->edit('joomla', 'joomla-platform', 523, 'My Pull Request', 'These are my changes - please review them'); - } - - /** - * Tests the editComment method - * - * @return void - */ - public function testEditComment() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $pull = new stdClass; - $pull->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/comments/523', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->editComment('joomla', 'joomla-platform', 523, 'This comment is now even more insightful'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the editComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditCommentFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $pull = new stdClass; - $pull->body = 'This comment is now even more insightful'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/comments/523', json_encode($pull)) - ->will($this->returnValue($this->response)); - - $this->object->editComment('joomla', 'joomla-platform', 523, 'This comment is now even more insightful'); - } - - /** - * Tests the get method - * - * @return void - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523') - ->will($this->returnValue($this->response)); - - $this->object->get('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getComment method - * - * @return void - */ - public function testGetComment() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/comments/523') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getComment('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComment method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetCommentFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/comments/523') - ->will($this->returnValue($this->response)); - - $this->object->getComment('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getComments method - * - * @return void - */ - public function testGetComments() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/comments') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getComments('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComments method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetCommentsFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/comments') - ->will($this->returnValue($this->response)); - - $this->object->getComments('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getCommits method - * - * @return void - */ - public function testGetCommits() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/commits') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getCommits('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getCommits method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetCommitsFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/commits') - ->will($this->returnValue($this->response)); - - $this->object->getCommits('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getFiles method - * - * @return void - */ - public function testGetFiles() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/files') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getFiles('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getFiles method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetFilesFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/files') - ->will($this->returnValue($this->response)); - - $this->object->getFiles('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls?state=closed') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', 'closed'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls') - ->will($this->returnValue($this->response)); - - $this->object->getList('joomla', 'joomla-platform'); - } - - /** - * Tests the isMerged method when the pull request has been merged - * - * @return void - */ - public function testIsMergedTrue() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->isMerged('joomla', 'joomla-platform', 523), - $this->equalTo(true) - ); - } - - /** - * Tests the isMerged method when the pull request has not been merged - * - * @return void - */ - public function testIsMergedFalse() - { - $this->response->code = 404; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->isMerged('joomla', 'joomla-platform', 523), - $this->equalTo(false) - ); - } - - /** - * Tests the isMerged method when the request fails - * - * @expectedException DomainException - * - * @return void - */ - public function testIsMergedFailure() - { - $this->response->code = 504; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($this->response)); - - $this->object->isMerged('joomla', 'joomla-platform', 523); - } - - /** - * Tests the merge method - * - * @return void - */ - public function testMerge() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->merge('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the merge method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testMergeFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/pulls/523/merge') - ->will($this->returnValue($this->response)); - - $this->object->merge('joomla', 'joomla-platform', 523); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubRefsTest.php b/tests/unit/suites/libraries/joomla/github/JGithubRefsTest.php deleted file mode 100644 index 3f2e5bbd73..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubRefsTest.php +++ /dev/null @@ -1,274 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubRefs($this->options, $this->client); - } - - /** - * Tests the get method - * - * @return void - */ - public function testGet() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/refs/heads/master') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 'heads/master'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - * - * @expectedException DomainException - * - * @return void - */ - public function testGetFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/refs/heads/master') - ->will($this->returnValue($returnData)); - - $this->object->get('joomla', 'joomla-platform', 'heads/master'); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'ref' => '/ref/heads/myhead', - 'sha' => 'This is the sha' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/refs', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', '/ref/heads/myhead', 'This is the sha'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'ref' => '/ref/heads/myhead', - 'sha' => 'This is the sha' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/refs', $data) - ->will($this->returnValue($returnData)); - - $this->object->create('joomla', 'joomla-platform', '/ref/heads/myhead', 'This is the sha'); - } - - /** - * Tests the edit method - * - * @return void - */ - public function testEdit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'force' => true, - 'sha' => 'This is the sha' - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/git/refs/heads/master', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 'heads/master', 'This is the sha', true), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'sha' => 'This is the sha' - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/git/refs/heads/master', $data) - ->will($this->returnValue($returnData)); - - $this->object->edit('joomla', 'joomla-platform', 'heads/master', 'This is the sha'); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/refs') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/refs') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubStatusesTest.php b/tests/unit/suites/libraries/joomla/github/JGithubStatusesTest.php deleted file mode 100644 index 22723be718..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubStatusesTest.php +++ /dev/null @@ -1,176 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubStatuses($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'state' => 'success', - 'target_url' => 'http://example.com/my_url', - 'description' => 'Success is the only option - failure is not.' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create( - 'joomla', - 'joomla-platform', - '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'success', - 'http://example.com/my_url', - 'Success is the only option - failure is not.' - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'state' => 'pending' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e', $data) - ->will($this->returnValue($returnData)); - - $this->object->create('joomla', 'joomla-platform', '6dcb09b5b57875f334f61aebed695e2e4193db5e', 'pending'); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', '6dcb09b5b57875f334f61aebed695e2e4193db5e'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform', '6dcb09b5b57875f334f61aebed695e2e4193db5e'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubTest.php b/tests/unit/suites/libraries/joomla/github/JGithubTest.php deleted file mode 100644 index ba5c2e93dc..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubTest.php +++ /dev/null @@ -1,285 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithub($this->options, $this->client); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @access protected - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Tests the magic __get method - gists - * - * @since 11.3 - * - * @return void - */ - public function test__GetGists() - { - $this->assertThat( - $this->object->gists, - $this->isInstanceOf('JGithubPackageGists') - ); - } - - /** - * Tests the magic __get method - issues - * - * @since 11.3 - * - * @return void - */ - public function test__GetIssues() - { - $this->assertThat( - $this->object->issues, - $this->isInstanceOf('JGithubPackageIssues') - ); - } - - /** - * Tests the magic __get method - pulls - * - * @since 11.3 - * - * @return void - */ - public function test__GetPulls() - { - $this->assertThat( - $this->object->pulls, - $this->isInstanceOf('JGithubPackagePulls') - ); - } - - /** - * Tests the magic __get method - refs - * - * @since 11.3 - * - * @return void - */ - public function test__GetRefs() - { - $this->assertThat( - $this->object->data->refs, - $this->isInstanceOf('JGithubPackageDataRefs') - ); - } - - /** - * Tests the magic __get method - forks - * - * @since 11.4 - * - * @return void - */ - public function test__GetForks() - { - $this->assertThat( - $this->object->repositories->forks, - $this->isInstanceOf('JGithubPackageRepositoriesForks') - ); - } - - /** - * Tests the magic __get method - commits - * - * @since 12.1 - * - * @return void - */ - public function test__GetCommits() - { - $this->assertThat( - $this->object->repositories->commits, - $this->isInstanceOf('JGithubPackageRepositoriesCommits') - ); - } - - /** - * Tests the magic __get method - milestones - * - * @since 12.3 - * - * @return void - */ - public function test__GetMilestones() - { - $this->assertThat( - $this->object->issues->milestones, - $this->isInstanceOf('JGithubPackageIssuesMilestones') - ); - } - - /** - * Tests the magic __get method - statuses - * - * @since 12.3 - * - * @return void - */ - public function test__GetStatuses() - { - $this->assertThat( - $this->object->repositories->statuses, - $this->isInstanceOf('JGithubPackageRepositoriesStatuses') - ); - } - - /** - * Tests the magic __get method - account - * - * @since 12.3 - * - * @return void - */ - public function test__GetAccount() - { - $this->assertThat( - $this->object->authorization, - $this->isInstanceOf('JGithubPackageAuthorization') - ); - } - - /** - * Tests the magic __get method - hooks - * - * @since 12.3 - * - * @return void - */ - public function test__GetHooks() - { - $this->assertThat( - $this->object->repositories->hooks, - $this->isInstanceOf('JGithubPackageRepositoriesHooks') - ); - } - - /** - * Tests the magic __get method - failure - * - * @since 11.3 - * @expectedException RuntimeException - * - * @return void - */ - public function test__GetFailure() - { - $this->assertThat( - $this->object->other, - $this->isNull() - ); - } - - /** - * Tests the magic __get method - failure - * - * @since 11.3 - * @expectedException RuntimeException - * - * @return void - */ - public function test__GetPackageFailure() - { - $this->assertThat( - $this->object->repositories->other, - $this->isNull() - ); - } - - /** - * Tests the setOption method - * - * @since 11.3 - * - * @return void - */ - public function testSetOption() - { - $this->object->setOption('api.url', 'https://example.com/settest'); - - $this->assertThat( - $this->options->get('api.url'), - $this->equalTo('https://example.com/settest') - ); - } - - /** - * Tests the getOption method - * - * @since 11.3 - * - * @return void - */ - public function testGetOption() - { - $this->options->set('api.url', 'https://example.com/gettest'); - - $this->assertThat( - $this->object->getOption('api.url', 'https://example.com/gettest'), - $this->equalTo('https://example.com/gettest') - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/JGithubUsersTest.php b/tests/unit/suites/libraries/joomla/github/JGithubUsersTest.php deleted file mode 100644 index 1a514d633a..0000000000 --- a/tests/unit/suites/libraries/joomla/github/JGithubUsersTest.php +++ /dev/null @@ -1,237 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageUsers($this->options, $this->client); - } - - /** - * Tests the getUser method - * - * @return void - */ - public function testGetUser() - { - $this->response->code = 200; - $this->response->body = '{ - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat", - "name": "monalisa octocat", - "company": "GitHub", - "blog": "https://github.com/blog", - "location": "San Francisco", - "email": "octocat@github.com", - "hireable": false, - "bio": "There once was...", - "public_repos": 2, - "public_gists": 1, - "followers": 20, - "following": 0, - "html_url": "https://github.com/octocat", - "created_at": "2008-01-14T04:33:35Z", - "type": "User" -}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getUser('joomla'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getUser method with failure - * - * @expectedException DomainException - * @return void - */ - public function testGetUserFailure() - { - $this->response->code = 404; - $this->response->body = '{"message":"Not Found"}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/nonexistentuser', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getUser('nonexistentuser'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getAuthenticatedUser method - * - * @return void - */ - public function testGetAuthenticatedUser() - { - $this->response->code = 200; - $this->response->body = '{ - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat", - "name": "monalisa octocat", - "company": "GitHub", - "blog": "https://github.com/blog", - "location": "San Francisco", - "email": "octocat@github.com", - "hireable": false, - "bio": "There once was...", - "public_repos": 2, - "public_gists": 1, - "followers": 20, - "following": 0, - "html_url": "https://github.com/octocat", - "created_at": "2008-01-14T04:33:35Z", - "type": "User", - "total_private_repos": 100, - "owned_private_repos": 100, - "private_gists": 81, - "disk_usage": 10000, - "collaborators": 8, - "plan": { - "name": "Medium", - "space": 400, - "collaborators": 10, - "private_repos": 20 - } -}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getAuthenticatedUser('joomla'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the GetAuthenticatedUser method with failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetAuthenticatedUserFailure() - { - $this->response->code = 401; - $this->response->body = '{"message":"Requires authentication"}'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getAuthenticatedUser(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getUsers method - * - * @return void - */ - public function testGetUsers() - { - $this->response->code = 200; - $this->response->body = '[ - { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - } -], - { - "login": "elkuku", - "id": 33978, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/elkuku" - } -]'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getUsers(), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityEventsTest.php b/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityEventsTest.php deleted file mode 100644 index d10ce33c60..0000000000 --- a/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityEventsTest.php +++ /dev/null @@ -1,349 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubPackageActivityEvents($this->options, $this->client); - } - - /** - * Tests the getPublic method - * - * @since 12.4 - * @return void - */ - public function testGetPublic() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $this->client->expects($this->once()) - ->method('get') - ->with('/events', 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getPublic(), - $this->equalTo(json_decode($returnData->body)) - ); - - } - - /** - * Tests the getRepository method - * - * @since 12.4 - * @return void - */ - public function testGetRepository() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/repos/' . $this->owner . '/' . $this->repo . '/events'; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getRepository($this->owner, $this->repo), - $this->equalTo(json_decode($returnData->body)) - ); - } - - /** - * Tests the getIssue method - * - * @since 12.4 - * @return void - */ - public function testGetIssue() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/repos/' . $this->owner . '/' . $this->repo . '/issues/events'; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getIssue($this->owner, $this->repo), - $this->equalTo(json_decode($returnData->body)) - ); - } - - /** - * Tests the getNetwork method - * - * @since 12.4 - * @return void - */ - public function testGetNetwork() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/networks/' . $this->owner . '/' . $this->repo . '/events'; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getNetwork($this->owner, $this->repo), - $this->equalTo(json_decode($returnData->body)) - ); - } - - /** - * Tests the getOrg method - * - * @since 12.4 - * @return void - */ - public function testGetOrg() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/orgs/' . $this->owner . '/events'; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getOrg($this->owner, $this->repo), - $this->equalTo(json_decode($returnData->body)) - ); - } - - /** - * Tests the getUser method - * - * @since 12.4 - * @return void - */ - public function testGetUser() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/users/' . $this->owner . '/received_events'; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getUser($this->owner), - $this->equalTo(json_decode($returnData->body)) - ); - } - - /** - * Tests the getUserPublic method - * - * @since 12.4 - * @return void - */ - public function testGetUserPublic() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/users/' . $this->owner . '/received_events/public'; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getUserPublic($this->owner), - $this->equalTo(json_decode($returnData->body)) - ); - } - - /** - * Tests the getByUser method - * - * @since 12.4 - * @return void - */ - public function testGetByUser() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/users/' . $this->owner . '/events'; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getByUser($this->owner), - $this->equalTo(json_decode($returnData->body)) - ); - } - - /** - * Tests the getByUserPublic method - * - * @since 12.4 - * @return void - */ - public function testGetByUserPublic() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/users/' . $this->owner . '/events/public'; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getByUserPublic($this->owner), - $this->equalTo(json_decode($returnData->body)) - ); - } - - /** - * Tests the getUserOrg method - * - * @since 12.4 - * @return void - */ - public function testGetUserOrg() - { - $returnData = new JHttpResponse; - $returnData->code = 200; - $returnData->body = $this->response; - - $path = '/users/' . $this->owner . '/events/orgs/' . $this->repo; - - $this->client->expects($this->once()) - ->method('get') - ->with($path, 0, 0) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getUserOrg($this->owner, $this->repo), - $this->equalTo(json_decode($returnData->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityNotificationsTest.php b/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityNotificationsTest.php deleted file mode 100644 index 10827958cf..0000000000 --- a/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityNotificationsTest.php +++ /dev/null @@ -1,415 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageActivityNotifications($this->options, $this->client); - } - - /** - * @covers JGithubPackageActivityNotifications::getList - * @todo Implement testGetList(). - * - * - GET /notifications - - Parameters - - all - Optional boolean true to show notifications marked as read. - participating - Optional boolean true to show only notifications in which the user is directly participating or mentioned. - since - Optional time filters out any notifications updated before the given time. The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Example: “2012-10-09T23:39:01Z”. - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/notifications?&all=1&participating=1', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityNotifications::getListRepository - * @todo Implement testGetListRepository(). - * - * - GET /repos/:owner/:repo/notifications - - Parameters - - all - Optional boolean true to show notifications marked as read. - participating - Optional boolean true to show only notifications in which the user is directly participating or mentioned. - since - Optional time filters out any notifications updated before the given time. The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Example: “2012-10-09T23:39:01Z”. - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - */ - public function testGetListRepository() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/notifications?&all=1&participating=1', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListRepository('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityNotifications::markRead - * @todo Implement testMarkRead(). - * - * - PUT /notifications - - Input - - unread - Boolean Changes the unread status of the threads. - read - Boolean Inverse of “unread”. - last_read_at - Optional Time Describes the last point that notifications were checked. Anything updated since this time will not be updated. Default: Now. Expected in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Example: “2012-10-09T23:39:01Z”. - - Response - - Status: 205 Reset Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testMarkRead() - { - $this->response->code = 205; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('put') - ->with('/notifications', '{"unread":true,"read":true}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->markRead(), - $this->equalTo($this->response->body) - ); - } - - public function testMarkReadLastRead() - { - $this->response->code = 205; - $this->response->body = ''; - - $date = new JDate('1966-09-14'); - $data = '{"unread":true,"read":true,"last_read_at":"1966-09-14T00:00:00+00:00"}'; - - $this->client->expects($this->once()) - ->method('put') - ->with('/notifications', $data, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->markRead(true, true, $date), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageActivityNotifications::markReadRepository - * @todo Implement testMarkReadRepository(). - * - * - PUT /repos/:owner/:repo/notifications - - Input - - unread - Boolean Changes the unread status of the threads. - read - Boolean Inverse of “unread”. - last_read_at - Optional Time Describes the last point that notifications were checked. Anything updated since this time will not be updated. Default: Now. Expected in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Example: “2012-10-09T23:39:01Z”. - - Response - - Status: 205 Reset Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testMarkReadRepository() - { - $this->response->code = 205; - $this->response->body = ''; - - $data = '{"unread":true,"read":true}'; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/notifications', $data, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->markReadRepository('joomla', 'joomla-platform', true, true), - $this->equalTo($this->response->body) - ); - } - - public function testMarkReadRepositoryLastRead() - { - $this->response->code = 205; - $this->response->body = ''; - - $date = new JDate('1966-09-14'); - $data = '{"unread":true,"read":true,"last_read_at":"1966-09-14T00:00:00+00:00"}'; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/notifications', $data, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->markReadRepository('joomla', 'joomla-platform', true, true, $date), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageActivityNotifications::viewThread - * @todo Implement testViewThread(). - * - * GET /notifications/threads/:id - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testViewThread() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/notifications/threads/1', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->viewThread(1), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityNotifications::markReadThread - * @todo Implement testMarkReadThread(). - * - * PATCH /notifications/threads/:id - - Input - - unread - Boolean Changes the unread status of the threads. - read - Boolean Inverse of “unread”. - - Response - - Status: 205 Reset Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testMarkReadThread() - { - $this->response->code = 205; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/notifications/threads/1', '{"unread":true,"read":true}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->markReadThread(1), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityNotifications::getThreadSubscription - * @todo Implement testGetThreadSubscription(). - * - * GET /notifications/threads/1/subscription - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testGetThreadSubscription() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/notifications/threads/1/subscription', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getThreadSubscription(1), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityNotifications::setThreadSubscription - * @todo Implement testSetThreadSubscription(). - * - * PUT /notifications/threads/1/subscription - - Input - - subscribed - boolean Determines if notifications should be received from this thread. - ignored - boolean Determines if all notifications should be blocked from this thread. - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - - */ - public function testSetThreadSubscription() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/notifications/threads/1/subscription', '{"subscribed":true,"ignored":false}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->setThreadSubscription(1, true, false), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityNotifications::deleteThreadSubscription - * @todo Implement testDeleteThreadSubscription(). - * - * DELETE /notifications/threads/1/subscription - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testDeleteThreadSubscription() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/notifications/threads/1/subscription', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->deleteThreadSubscription(1), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityStarringTest.php b/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityStarringTest.php deleted file mode 100644 index b19e6e0177..0000000000 --- a/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityStarringTest.php +++ /dev/null @@ -1,270 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageActivityStarring($this->options, $this->client); - } - - /** - * @covers JGithubPackageActivityStarring::getList - * @todo Implement testGetList(). - * - * GET /repos/:owner/:repo/stargazers - - # Legacy, using github.beta media type. - GET /repos/:owner/:repo/watchers - - Response - - Status: 200 OK - Link: ; rel="next", - ; rel="last" - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/stargazers', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityStarring::getRepositories - * @todo Implement testGetRepositories(). - * - * - GET /users/:user/starred - - # Legacy, using github.beta media type. - GET /users/:user/watched - - List repositories being watched by the authenticated user. - - GET /user/starred - - # Legacy, using github.beta media type. - GET /user/watched - - Response - - Status: 200 OK - Link: ; rel="next", - ; rel="last" - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testGetRepositories() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/starred', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getRepositories(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityStarring::check - * @todo Implement testCheck(). - * - * GET /user/starred/:owner/:repo - - # Legacy, using github.beta media type. - GET /user/watched/:owner/:repo - - Response if this repository is watched by you - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - Response if this repository is not watched by you - - Status: 404 Not Found - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testCheck() - { - $this->response->code = 204; - $this->response->body = true; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/starred/joomla/joomla-platform', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - public function testCheckFalse() - { - $this->response->code = 404; - $this->response->body = false; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/starred/joomla/joomla-platform', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testCheckUnexpected() - { - $this->response->code = 666; - $this->response->body = false; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/starred/joomla/joomla-platform', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityStarring::star - * @todo Implement testStar(). - * - * PUT /user/starred/:owner/:repo - - # Legacy, using github.beta media type. - PUT /user/watched/:owner/:repo - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testStar() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/user/starred/joomla/joomla-platform', '', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->star('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityStarring::unstar - * @todo Implement testUnstar(). - * - * DELETE /user/starred/:owner/:repo - - # Legacy, using github.beta media type. - DELETE /user/watched/:owner/:repo - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testUnstar() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/user/starred/joomla/joomla-platform', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->unstar('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityWatchingTest.php b/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityWatchingTest.php deleted file mode 100644 index 3c9c33de7b..0000000000 --- a/tests/unit/suites/libraries/joomla/github/activity/JGithubPackageActivityWatchingTest.php +++ /dev/null @@ -1,360 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageActivityWatching($this->options, $this->client); - } - - /** - * @covers JGithubPackageActivityWatching::getList - * @todo Implement testGetList(). - * - * GET /repos/:owner/:repo/subscribers - - Response - - Status: 200 OK - Link: ; rel="next", - ; rel="last" - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/subscribers', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityWatching::getRepositories - * @todo Implement testGetRepositories(). - * - * GET /users/:user/subscriptions - - List repositories being watched by the authenticated user. - - GET /user/subscriptions - - Response - - Status: 200 OK - Link: ; rel="next", - ; rel="last" - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - - */ - public function testGetRepositories() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/subscriptions', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getRepositories(), - $this->equalTo(json_decode($this->response->body)) - ); - } - - public function testGetRepositoriesUser() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/subscriptions', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getRepositories('joomla'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityWatching::getSubscription - * @todo Implement testGetSubscription(). - * - * GET /repos/:owner/:repo/subscription - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testGetSubscription() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/subscription', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getSubscription('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityWatching::setSubscription - * @todo Implement testSetSubscription(). - * - * PUT /repos/:owner/:repo/subscription - - Input - - subscribed - boolean Determines if notifications should be received from this repository. - ignored - boolean Determines if all notifications should be blocked from this repository. - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testSetSubscription() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/subscription', '{"subscribed":true,"ignored":false}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->setSubscription('joomla', 'joomla-platform', true, false), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageActivityWatching::deleteSubscription - * @todo Implement testDeleteSubscription(). - * - * DELETE /repos/:owner/:repo/subscription - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testDeleteSubscription() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/subscription', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->deleteSubscription('joomla', 'joomla-platform'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageActivityWatching::check - * @todo Implement testCheck(). - * - * GET /user/subscriptions/:owner/:repo - - Response if this repository is watched by you - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - Response if this repository is not watched by you - - Status: 404 Not Found - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testCheck() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/subscriptions/joomla/joomla-platform', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'joomla-platform'), - $this->equalTo(true) - ); - } - - public function testCheckFalse() - { - $this->response->code = 404; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/subscriptions/joomla/joomla-platform', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'joomla-platform'), - $this->equalTo(false) - ); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testCheckUnexpected() - { - $this->response->code = 666; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/subscriptions/joomla/joomla-platform', 0, 0) - ->will($this->returnValue($this->response)); - - $this->object->check('joomla', 'joomla-platform'); - } - - /** - * @covers JGithubPackageActivityWatching::watch - * @todo Implement testWatch(). - * - * PUT /user/subscriptions/:owner/:repo - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testWatch() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('put') - ->with('/user/subscriptions/joomla/joomla-platform', '', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->watch('joomla', 'joomla-platform'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageActivityWatching::unwatch - * @todo Implement testUnwatch(). - * - * DELETE /user/subscriptions/:owner/:repo - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testUnwatch() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/user/subscriptions/joomla/joomla-platform', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->unwatch('joomla', 'joomla-platform'), - $this->equalTo($this->response->body) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataBlobsTest.php b/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataBlobsTest.php deleted file mode 100644 index f7befce047..0000000000 --- a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataBlobsTest.php +++ /dev/null @@ -1,132 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageDataBlobs($this->options, $this->client); - } - - /** - * @covers JGithubPackageDataBlobs::get - * @todo Implement testGet(). - * - * GET /repos/:owner/:repo/git/blobs/:sha - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "content": "Content of the blob", - "encoding": "utf-8", - "sha": "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15", - "size": 100 - } - - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/blobs/12345', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', '12345'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageDataBlobs::create - * @todo Implement testCreate(). - * - * POST /repos/:owner/:repo/git/blobs - - Input - - { - "content": "Content of the blob", - "encoding": "utf-8" - } - - Response - - Status: 201 Created - Location: https://api.github.com/git/:owner/:repo/blob/:sha - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "sha": "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15" - } - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/blobs', '{"content":"Hello w\u00f6rld","encoding":"utf-8"}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'Hello wörld'), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataCommitsTest.php b/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataCommitsTest.php deleted file mode 100644 index 1584fc68c8..0000000000 --- a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataCommitsTest.php +++ /dev/null @@ -1,157 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageDataCommits($this->options, $this->client); - } - - /** - * @covers JGithubPackageDataCommits::get - * @todo Implement testGet(). - * - * GET /repos/:owner/:repo/git/commits/:sha - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/commits/12345', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', '12345'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageDataCommits::create - * @todo Implement testCreate(). - * - * POST /repos/:owner/:repo/git/commits - - Parameters - - message - String of the commit message - tree - String of the SHA of the tree object this commit points to - parents - Array of the SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided, for a merge commit, an array of more than one should be provided. - - Optional Parameters - - The committer section is optional and will be filled with the author data if omitted. If the author section is omitted, it will be filled in with the authenticated user’s information and the current date. - - author.name - String of the name of the author of the commit - author.email - String of the email of the author of the commit - author.date - Timestamp of when this commit was authored - committer.name - String of the name of the committer of the commit - committer.email - String of the email of the committer of the commit - committer.date - Timestamp of when this commit was committed - - Example Input - - { - "message": "my commit message", - "author": { - "name": "Scott Chacon", - "email": "schacon@gmail.com", - "date": "2008-07-09T16:13:30+12:00" - }, - "parents": [ - "7d1b31e74ee336d15cbd21741bc88a537ed063a0" - ], - "tree": "827efc6d56897b048c772eb4087f854f46256132" - } - - Response - - Status: 201 Created - Location: https://api.github.com/git/:owner/:repo/commit/:sha - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/commits', '{"message":"My Message","tree":"12345","parents":[]}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'My Message', '12345'), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataRefsTest.php b/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataRefsTest.php deleted file mode 100644 index ff24b95e34..0000000000 --- a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataRefsTest.php +++ /dev/null @@ -1,314 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageDataRefs($this->options, $this->client); - } - - /** - * Tests the get method - * - * @return void - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/refs/heads/master') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 'heads/master'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - * - * @expectedException DomainException - * - * @return void - */ - public function testGetFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/refs/heads/master') - ->will($this->returnValue($this->response)); - - $this->object->get('joomla', 'joomla-platform', 'heads/master'); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'ref' => '/ref/heads/myhead', - 'sha' => 'This is the sha' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/refs', $data) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', '/ref/heads/myhead', 'This is the sha'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $this->response->code = 501; - $this->response->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'ref' => '/ref/heads/myhead', - 'sha' => 'This is the sha' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/refs', $data) - ->will($this->returnValue($this->response)); - - $this->object->create('joomla', 'joomla-platform', '/ref/heads/myhead', 'This is the sha'); - } - - /** - * Tests the edit method - * - * @return void - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'force' => true, - 'sha' => 'This is the sha' - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/git/refs/heads/master', $data) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 'heads/master', 'This is the sha', true), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testEditFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'sha' => 'This is the sha' - ) - ); - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/git/refs/heads/master', $data) - ->will($this->returnValue($this->response)); - - $this->object->edit('joomla', 'joomla-platform', 'heads/master', 'This is the sha'); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/refs') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/refs') - ->will($this->returnValue($this->response)); - - $this->object->getList('joomla', 'joomla-platform'); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = ''; - - $ref = 'refs/heads/sc/featureA'; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/git/refs/' . $ref) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', $ref), - $this->equalTo('') - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testDeleteFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $ref = 'refs/heads/sc/featureA'; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/git/refs/' . $ref) - ->will($this->returnValue($this->response)); - - $this->object->delete('joomla', 'joomla-platform', $ref); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataTagsTest.php b/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataTagsTest.php deleted file mode 100644 index c17de92277..0000000000 --- a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataTagsTest.php +++ /dev/null @@ -1,137 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageDataTags($this->options, $this->client); - } - - /** - * @covers JGithubPackageDataTags::get - * @todo Implement testGet(). - * - * GET /repos/:owner/:repo/git/tags/:sha - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/tags/12345', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', '12345'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageDataTags::create - * @todo Implement testCreate(). - * - * POST /repos/:owner/:repo/git/tags - - Parameters - - tag - String of the tag - message - String of the tag message - object - String of the SHA of the git object this is tagging - type - String of the type of the object we’re tagging. Normally this is a commit but it can also be a tree or a blob. - tagger.name - String of the name of the author of the tag - tagger.email - String of the email of the author of the tag - tagger.date - Timestamp of when this object was tagged - - Response - - Status: 201 Created - Location: https://api.github.com/repos/:owner/:repo/git/tags/:sha - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $data = '{"tag":"0.1","message":"Message","object":"12345","type":"commit","tagger_name":"elkuku","tagger_email":"email@example.com","tagger_date":"123456789"}'; - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/tags', $data, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', '0.1', 'Message', '12345', 'commit', 'elkuku', 'email@example.com', '123456789'), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataTreesTest.php b/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataTreesTest.php deleted file mode 100644 index 423536ee79..0000000000 --- a/tests/unit/suites/libraries/joomla/github/data/JGithubPackageDataTreesTest.php +++ /dev/null @@ -1,173 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageDataTrees($this->options, $this->client); - } - - /** - * @covers JGithubPackageDataTrees::get - * @todo Implement testGet(). - * - * GET /repos/:owner/:repo/git/trees/:sha - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/trees/12345', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', '12345'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageDataTrees::getRecursively - * @todo Implement testGetRecursively(). - * - * GET /repos/:owner/:repo/git/trees/:sha?recursive=1 - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testGetRecursively() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/git/trees/12345?recursive=1', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getRecursively('joomla', 'joomla-platform', '12345'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageDataTrees::create - * @todo Implement testCreate(). - * - * POST /repos/:owner/:repo/git/trees - Input - - { - "tree": [ - { - "path": "file.rb", - "mode": "100644", - "type": "blob", - "sha": "44b4fc6d56897b048c772eb4087f854f46256132" - } - ] - } - - Response - - Status: 201 Created - Location: https://api.github.com/repos/:owner/:repo/git/trees/:sha - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "sha": "cd8274d15fa3ae2ab983129fb037999f264ba9a7", - "url": "https://api.github.com/repo/octocat/Hello-World/trees/cd8274d15fa3ae2ab983129fb037999f264ba9a7", - "tree": [ - { - "path": "file.rb", - "mode": "100644", - "type": "blob", - "size": 132, - "sha": "7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b", - "url": "https://api.github.com/octocat/Hello-World/git/blobs/7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b" - } - ] - } - - - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/git/trees', '{"tree":"12345","base_tree":"678"}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', '12345', '678'), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesAssigneesTest.php b/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesAssigneesTest.php deleted file mode 100644 index 18c1d8da67..0000000000 --- a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesAssigneesTest.php +++ /dev/null @@ -1,161 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageIssuesAssignees($this->options, $this->client); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = '[ - { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - } - ]'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/' . $this->owner . '/' . $this->repo . '/assignees', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList($this->owner, $this->repo), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * Tests the getList method - * Response: - * If the given assignee login belongs to an assignee for the repository, - * a 204 header with no content is returned. - * Otherwise a 404 status code is returned. - * - * @return void - */ - public function testCheck() - { - $this->response->code = 204; - $this->response->body = ''; - - $assignee = 'elkuku'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/' . $this->owner . '/' . $this->repo . '/assignees/' . $assignee, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check($this->owner, $this->repo, $assignee), - $this->equalTo(true) - ); - } - - /** - * Tests the getList method with a negative response - * Response: - * If the given assignee login belongs to an assignee for the repository, - * a 204 header with no content is returned. - * Otherwise a 404 status code is returned. - * - * @return void - */ - public function testCheckNo() - { - $this->response->code = 404; - $this->response->body = ''; - - $assignee = 'elkuku'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/' . $this->owner . '/' . $this->repo . '/assignees/' . $assignee, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check($this->owner, $this->repo, $assignee), - $this->equalTo(false) - ); - } - - /** - * Tests the getList method with a negative response - * Response: - * If the given assignee login belongs to an assignee for the repository, - * a 204 header with no content is returned. - * Otherwise a 404 status code is returned. - * - * @expectedException DomainException - * - * @return void - */ - public function testCheckException() - { - $this->response->code = 666; - $this->response->body = ''; - - $assignee = 'elkuku'; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/' . $this->owner . '/' . $this->repo . '/assignees/' . $assignee, 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check($this->owner, $this->repo, $assignee), - $this->equalTo(false) - ); - } - -} diff --git a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesCommentsTest.php b/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesCommentsTest.php deleted file mode 100644 index f7485ae67a..0000000000 --- a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesCommentsTest.php +++ /dev/null @@ -1,345 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageIssuesComments($this->options, $this->client); - } - - /** - * @covers JGithubPackageIssuesComments::getList - * @todo Implement testGetList(). - * - * GET /repos/:owner/:repo/issues/:number/comments - - Response - - Status: 200 OK - Link: ; rel="next", - ; rel="last" - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/1/comments', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', '1'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesComments::getRepositoryList - * @todo Implement testGetRepositoryList(). - * - * - GET /repos/:owner/:repo/issues/comments - - By default, Issue Comments are ordered by ascending ID. - Parameters - - sort - Optional String created or updated - direction - Optional String asc or desc. Ignored without sort parameter. - since - Optional String of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - */ - public function testGetRepositoryList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/comments?sort=created&direction=asc', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getRepositoryList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testGetRepositoryListInvalidSort() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->object->getRepositoryList('joomla', 'joomla-platform', 'invalid'); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testGetRepositoryListInvalidDirection() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->object->getRepositoryList('joomla', 'joomla-platform', 'created', 'invalid'); - } - - public function testGetRepositoryListSince() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $date = new JDate('1966-09-15 12:34:56'); - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/comments?sort=created&direction=asc&since=1966-09-15T12:34:56+00:00', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getRepositoryList('joomla', 'joomla-platform', 'created', 'asc', $date), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * - * Method to get a single comment. - - GET /repos/:owner/:repo/issues/comments/:id - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "id": 1, - "url": "https://api.github.com/repos/octocat/Hello-World/issues/comments/1", - "body": "Me too", - "user": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - }, - "created_at": "2011-04-14T16:00:49Z", - "updated_at": "2011-04-14T16:00:49Z" - } - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/comments/1', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 1), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesComments::edit - * @todo Implement testEdit(). - * - * PATCH /repos/:owner/:repo/issues/comments/:id - - Input - - body - Required string - - { - "body": "String" - } - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "id": 1, - "url": "https://api.github.com/repos/octocat/Hello-World/issues/comments/1", - "body": "Me too", - "user": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - }, - "created_at": "2011-04-14T16:00:49Z", - "updated_at": "2011-04-14T16:00:49Z" - } - - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/issues/comments/1', '{"body":"Hello"}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 1, 'Hello'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesComments::create - * @todo Implement testCreate(). - * - * POST /repos/:owner/:repo/issues/:number/comments - - Input - - body - Required string - - { - "body": "a new comment" - } - - Response - - Status: 201 Created - Location: https://api.github.com/repos/user/repo/issues/comments/1 - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "id": 1, - "url": "https://api.github.com/repos/octocat/Hello-World/issues/comments/1", - "body": "Me too", - "user": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - }, - "created_at": "2011-04-14T16:00:49Z", - "updated_at": "2011-04-14T16:00:49Z" - } - - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues/1/comments', '{"body":"Hello"}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 1, 'Hello'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesComments::delete - * @todo Implement testDelete(). - * - * DELETE /repos/:owner/:repo/issues/comments/:id - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/issues/comments/1', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', 1, 'Hello'), - $this->equalTo(true) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesEventsTest.php b/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesEventsTest.php deleted file mode 100644 index b85317dcd1..0000000000 --- a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesEventsTest.php +++ /dev/null @@ -1,148 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageIssuesEvents($this->options, $this->client); - } - - /** - * @covers JGithubPackageIssuesEvents::getList - * @todo Implement testGetList(). - * - * GET /repos/:owner/:repo/issues/:issue_number/events - - Response - - Status: 200 OK - Link: ; rel="next", - ; rel="last" - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/1/events', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', '1'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesEvents::getListRepository - * @todo Implement testGetListRepository(). - * - * GET /repos/:owner/:repo/issues/events - - Response - - Status: 200 OK - Link: ; rel="next", - ; rel="last" - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testGetListRepository() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/1/comments', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListRepository('joomla', 'joomla-platform', '1'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesEvents::get - * @todo Implement testGet(). - * - * GET /repos/:owner/:repo/issues/events/:id - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/events/1', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', '1'), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesLabelsTest.php b/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesLabelsTest.php deleted file mode 100644 index 257cfd5d35..0000000000 --- a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesLabelsTest.php +++ /dev/null @@ -1,473 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageIssuesLabels($this->options, $this->client); - } - - /** - * @covers JGithubPackageIssuesLabels::getList - * @todo Implement testGetList(). - * GET /repos/:owner/:repo/labels - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', '1'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::get - * @todo Implement testGet(). - * - * GET /repos/:owner/:repo/labels/:name - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/labels/1', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', '1'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::create - * @todo Implement testCreate(). - * - * POST /repos/:owner/:repo/labels - - Input - - name - Required string - color - Required string - 6 character hex code, without a leading #. - - { - "name": "API", - "color": "FFFFFF" - } - - Response - - Status: 201 Created - Location: https://api.github.com/repos/user/repo/labels/foo - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", - "name": "bug", - "color": "f29513" - } - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/labels', '{"name":"foobar","color":"red"}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'foobar', 'red'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @expectedException DomainException - */ - public function testCreateFailure() - { - $this->response->code = 404; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/labels', '{"name":"foobar","color":"red"}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'foobar', 'red'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::update - * @todo Implement testUpdate(). - * - * PATCH /repos/:owner/:repo/labels/:name - - Input - - name - Required string - color - Required string - 6 character hex code, without a leading #. - - { - "name": "API", - "color": "FFFFFF" - } - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", - "name": "bug", - "color": "f29513" - } - */ - public function testUpdate() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/labels/foobar', '{"name":"boofaz","color":"red"}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->update('joomla', 'joomla-platform', 'foobar', 'boofaz', 'red'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::delete - * @todo Implement testDelete(). - * - * DELETE /repos/:owner/:repo/labels/:name - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/labels/foobar', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', 'foobar'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::getListByIssue - * @todo Implement testGetListByIssue(). - * - * GET /repos/:owner/:repo/issues/:number/labels - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - - */ - public function testGetListByIssue() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/issues/1/labels', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListByIssue('joomla', 'joomla-platform', 1), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::add - * @todo Implement testAdd(). - * - * POST /repos/:owner/:repo/issues/:number/labels - - Input - - [ - "Label1", - "Label2" - ] - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - [ - { - "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", - "name": "bug", - "color": "f29513" - } - ] - */ - public function testAdd() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/issues/1/labels', '["A","B"]', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->add('joomla', 'joomla-platform', 1, array('A', 'B')), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::removeFromIssue - * @todo Implement testRemoveFromIssue(). - * - * DELETE /repos/:owner/:repo/issues/:number/labels/:name - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - [ - { - "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", - "name": "bug", - "color": "f29513" - } - ] - */ - public function testRemoveFromIssue() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/issues/1/labels/foobar', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->removeFromIssue('joomla', 'joomla-platform', 1, 'foobar'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::replace - * @todo Implement testReplace(). - * - * PUT /repos/:owner/:repo/issues/:number/labels - - Input - - [ - "Label1", - "Label2" - ] - - Sending an empty array ([]) will remove all Labels from the Issue. - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - [ - { - "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", - "name": "bug", - "color": "f29513" - } - ] - */ - public function testReplace() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/issues/1/labels', '["A","B"]', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->replace('joomla', 'joomla-platform', 1, array('A', 'B')), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::removeAllFromIssue - * @todo Implement testRemoveAllFromIssue(). - * - * DELETE /repos/:owner/:repo/issues/:number/labels - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - */ - public function testRemoveAllFromIssue() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/issues/1/labels', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->removeAllFromIssue('joomla', 'joomla-platform', 1), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackageIssuesLabels::getListByMilestone - * @todo Implement testGetListByMilestone(). - * - * GET /repos/:owner/:repo/milestones/:number/labels - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - [ - { - "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", - "name": "bug", - "color": "f29513" - } - ] - */ - public function testGetListByMilestone() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones/1/labels', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListByMilestone('joomla', 'joomla-platform', 1), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesMilestonesTest.php b/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesMilestonesTest.php deleted file mode 100644 index 1aae50dbb0..0000000000 --- a/tests/unit/suites/libraries/joomla/github/issues/JGithubPackageIssuesMilestonesTest.php +++ /dev/null @@ -1,365 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubPackageIssuesMilestones($this->options, $this->client); - } - - /** - * Test... - * - * @param string $name The method name. - * - * @return string - */ - protected function getMethod($name) - { - $class = new ReflectionClass('JGithubMilestones'); - $method = $class->getMethod($name); - $method->setAccessible(true); - - return $method; - } - - /** - * Tests the create method - * - * @return void - * - * @since 12.3 - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $milestone = new stdClass; - $milestone->title = 'My Milestone'; - $milestone->state = 'open'; - $milestone->description = 'This milestone is impossible'; - $milestone->due_on = '2012-12-25T20:09:31Z'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/milestones', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'My Milestone', 'open', 'This milestone is impossible', '2012-12-25T20:09:31Z'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testCreateFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - $milestone = new stdClass; - $milestone->title = 'My Milestone'; - $milestone->state = 'open'; - $milestone->description = 'This milestone is impossible'; - $milestone->due_on = '2012-12-25T20:09:31Z'; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/milestones', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->object->create('joomla', 'joomla-platform', 'My Milestone', 'open', 'This milestone is impossible', '2012-12-25T20:09:31Z'); - } - - /** - * Tests the edit method - * - * @return void - * - * @since 12.3 - */ - public function testEdit() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $milestone = new stdClass; - $milestone->state = 'closed'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/milestones/523', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 523, null, 'closed'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method with all parameters - * - * @return void - * - * @since 12.3 - */ - public function testEditAllParameters() - { - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $milestone = new stdClass; - $milestone->title = 'This is the revised title.'; - $milestone->state = 'closed'; - $milestone->description = 'This describes it perfectly.'; - $milestone->due_on = '2012-12-25T20:09:31Z'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/milestones/523', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 523, 'This is the revised title.', 'closed', 'This describes it perfectly.', - '2012-12-25T20:09:31Z'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testEditFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $milestone = new stdClass; - $milestone->state = 'closed'; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/milestones/523', json_encode($milestone)) - ->will($this->returnValue($returnData)); - - $this->object->edit('joomla', 'joomla-platform', 523, null, 'closed'); - } - - /** - * Tests the get method - * - * @return void - * - * @since 12.3 - */ - public function testGet() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones/523') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 523), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testGetFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones/523') - ->will($this->returnValue($returnData)); - - $this->object->get('joomla', 'joomla-platform', 523); - } - - /** - * Tests the getList method - * - * @return void - * - * @since 12.3 - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones?state=open&sort=due_date&direction=desc') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/milestones?state=open&sort=due_date&direction=desc') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform'); - } - - /** - * Tests the delete method - * - * @return void - * - * @since 12.3 - */ - public function testDelete() - { - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/milestones/254') - ->will($this->returnValue($returnData)); - - $this->object->delete('joomla', 'joomla-platform', 254); - } - - /** - * Tests the delete method - failure - * - * @expectedException DomainException - * - * @return void - * - * @since 12.3 - */ - public function testDeleteFailure() - { - $returnData = new stdClass; - $returnData->code = 504; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/milestones/254') - ->will($this->returnValue($returnData)); - - $this->object->delete('joomla', 'joomla-platform', 254); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/orgs/JGithubPackageOrgsMembersTest.php b/tests/unit/suites/libraries/joomla/github/orgs/JGithubPackageOrgsMembersTest.php deleted file mode 100644 index ba0550b17e..0000000000 --- a/tests/unit/suites/libraries/joomla/github/orgs/JGithubPackageOrgsMembersTest.php +++ /dev/null @@ -1,346 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageOrgsMembers($this->options, $this->client); - } - - /** - * @covers JGithubPackageOrgsMembers::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/members') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::getList - * @todo Implement testGetList(). - */ - public function testGetListNotAMember() - { - $this->response->code = 302; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/members') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla'), - $this->equalTo(false) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::getList - * @todo Implement testGetList(). - * - * @expectedException UnexpectedValueException - */ - public function testGetListUnexpected() - { - $this->response->code = 666; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/members') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::check - * @todo Implement testCheck(). - */ - public function testCheck() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'elkuku'), - $this->equalTo(true) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::check - * @todo Implement testCheck(). - */ - public function testCheckNoMember() - { - $this->response->code = 404; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'elkuku'), - $this->equalTo(false) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::check - * @todo Implement testCheck(). - */ - public function testCheckRequesterNoMember() - { - $this->response->code = 302; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'elkuku'), - $this->equalTo(false) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::check - * @todo Implement testCheck(). - * - * @expectedException UnexpectedValueException - */ - public function testCheckUnexpectedr() - { - $this->response->code = 666; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla', 'elkuku'), - $this->equalTo(false) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::remove - * @todo Implement testRemove(). - */ - public function testRemove() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/orgs/joomla/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->remove('joomla', 'elkuku'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::getListPublic - * @todo Implement testGetListPublic(). - */ - public function testGetListPublic() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/public_members') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListPublic('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::checkPublic - * @todo Implement testCheckPublic(). - */ - public function testCheckPublic() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/public_members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->checkPublic('joomla', 'elkuku'), - $this->equalTo(true) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::checkPublic - * @todo Implement testCheckPublic(). - */ - public function testCheckPublicNo() - { - $this->response->code = 404; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/public_members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->checkPublic('joomla', 'elkuku'), - $this->equalTo(false) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::checkPublic - * @todo Implement testCheckPublic(). - * - * @expectedException UnexpectedValueException - */ - public function testCheckPublicUnexpected() - { - $this->response->code = 666; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/public_members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->checkPublic('joomla', 'elkuku'), - $this->equalTo(false) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::publicize - * @todo Implement testPublicize(). - */ - public function testPublicize() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/orgs/joomla/public_members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->publicize('joomla', 'elkuku'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsMembers::conceal - * @todo Implement testConceal(). - */ - public function testConceal() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/orgs/joomla/public_members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->conceal('joomla', 'elkuku'), - $this->equalTo(json_decode($this->sampleString)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/orgs/JGithubPackageOrgsTeamsTest.php b/tests/unit/suites/libraries/joomla/github/orgs/JGithubPackageOrgsTeamsTest.php deleted file mode 100644 index d0bf406484..0000000000 --- a/tests/unit/suites/libraries/joomla/github/orgs/JGithubPackageOrgsTeamsTest.php +++ /dev/null @@ -1,432 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageOrgsTeams($this->options, $this->client); - } - - /** - * @covers JGithubPackageOrgsTeams::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/orgs/joomla/teams') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get(123), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::create - * @todo Implement testCreate(). - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/orgs/joomla/teams') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'TheTeam', array('joomla-platform'), 'admin'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::create - * @todo Implement testCreate(). - * - * @expectedException UnexpectedValueException - */ - public function testCreateWrongPermission() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->object->create('joomla', 'TheTeam', array('joomla-platform'), 'invalid'); - } - - /** - * @covers JGithubPackageOrgsTeams::edit - * @todo Implement testEdit(). - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/teams/123') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit(123, 'TheTeam', 'admin'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::edit - * @todo Implement testCreate(). - * - * @expectedException UnexpectedValueException - */ - public function testEditWrongPermission() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->object->edit(123, 'TheTeam', 'invalid'); - } - - /** - * @covers JGithubPackageOrgsTeams::delete - * @todo Implement testDelete(). - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/teams/123') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete(123), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::getListMembers - * @todo Implement testGetListMembers(). - */ - public function testGetListMembers() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123/members') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListMembers(123), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::isMember - * @todo Implement testIsMember(). - */ - public function testIsMember() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->isMember(123, 'elkuku'), - $this->equalTo(json_decode(true)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::isMember - * @todo Implement testIsMember(). - */ - public function testIsMemberNo() - { - $this->response->code = 404; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->isMember(123, 'elkuku'), - $this->equalTo(json_decode(false)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::isMember - * @todo Implement testIsMember(). - * - * @expectedException UnexpectedValueException - */ - public function testIsMemberUnexpected() - { - $this->response->code = 666; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->isMember(123, 'elkuku'), - $this->equalTo(json_decode(true)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::addMember - * @todo Implement testAddMember(). - */ - public function testAddMember() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/teams/123/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->addMember(123, 'elkuku'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::removeMember - * @todo Implement testRemoveMember(). - */ - public function testRemoveMember() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/teams/123/members/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->removeMember(123, 'elkuku'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::getListRepos - * @todo Implement testGetListRepos(). - */ - public function testGetListRepos() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123/repos') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListRepos(123), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::checkRepo - * @todo Implement testCheckRepo(). - */ - public function testCheckRepo() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123/repos/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->checkRepo(123, 'joomla'), - $this->equalTo(true) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::checkRepo - * @todo Implement testCheckRepo(). - */ - public function testCheckRepoNo() - { - $this->response->code = 404; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123/repos/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->checkRepo(123, 'joomla'), - $this->equalTo(false) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::checkRepo - * @todo Implement testCheckRepo(). - * - * @expectedException UnexpectedValueException - */ - public function testCheckRepoUnexpected() - { - $this->response->code = 666; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/teams/123/repos/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->checkRepo(123, 'joomla'), - $this->equalTo(true) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::addRepo - * @todo Implement testAddRepo(). - */ - public function testAddRepo() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/teams/123/repos/joomla/joomla-platform') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->addRepo(123, 'joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageOrgsTeams::removeRepo - * @todo Implement testRemoveRepo(). - */ - public function testRemoveRepo() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/teams/123/repos/joomla/joomla-platform') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->removeRepo(123, 'joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/pulls/JGithubPackagePullsCommentsTest.php b/tests/unit/suites/libraries/joomla/github/pulls/JGithubPackagePullsCommentsTest.php deleted file mode 100644 index 7656fb1e37..0000000000 --- a/tests/unit/suites/libraries/joomla/github/pulls/JGithubPackagePullsCommentsTest.php +++ /dev/null @@ -1,176 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackagePullsComments($this->options, $this->client); - } - - /** - * @covers JGithubPackagePullsComments::create - * @todo Implement testCreate(). - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/1/comments', '{"body":"The Body","commit_id":"123abc","path":"a\/b\/c","position":456}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 1, 'The Body', '123abc', 'a/b/c', 456), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackagePullsComments::createReply - * @todo Implement testCreateReply(). - */ - public function testCreateReply() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/pulls/1/comments', '{"body":"The Body","in_reply_to":456}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->createReply('joomla', 'joomla-platform', 1, 'The Body', 456), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackagePullsComments::delete - * @todo Implement testDelete(). - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/pulls/comments/456', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', 456), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackagePullsComments::edit - * @todo Implement testEdit(). - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/pulls/comments/456', '{"body":"Hello"}', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 456, 'Hello'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackagePullsComments::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/comments/456', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 456, 'Hello'), - $this->equalTo(json_decode($this->response->body)) - ); - } - - /** - * @covers JGithubPackagePullsComments::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/pulls/456/comments', 0, 0) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', 456), - $this->equalTo(json_decode($this->response->body)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesCollaboratorsTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesCollaboratorsTest.php deleted file mode 100644 index 9204d5d352..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesCollaboratorsTest.php +++ /dev/null @@ -1,182 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageRepositoriesCollaborators($this->options, $this->client); - } - - /** - * @covers JGithubPackageRepositoriesCollaborators::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/collaborators') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesCollaborators::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 204; - $this->response->body = true; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/collaborators/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 'elkuku'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageRepositoriesCollaborators::get - * @todo Implement testGet(). - */ - public function testGetNegative() - { - $this->response->code = 404; - $this->response->body = false; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/collaborators/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 'elkuku'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageRepositoriesCollaborators::get - * @todo Implement testGet(). - * - * @expectedException UnexpectedValueException - */ - public function testGetUnexpected() - { - $this->response->code = 666; - $this->response->body = null; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/collaborators/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 'elkuku'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageRepositoriesCollaborators::add - * @todo Implement testAdd(). - */ - public function testAdd() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put') - ->with('/repos/joomla/joomla-platform/collaborators/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->add('joomla', 'joomla-platform', 'elkuku'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesCollaborators::remove - * @todo Implement testRemove(). - */ - public function testRemove() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/collaborators/elkuku') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->remove('joomla', 'joomla-platform', 'elkuku'), - $this->equalTo(json_decode($this->sampleString)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesCommentsTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesCommentsTest.php deleted file mode 100644 index 87c72c60d4..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesCommentsTest.php +++ /dev/null @@ -1,180 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageRepositoriesComments($this->options, $this->client); - } - - /** - * @covers JGithubPackageRepositoriesComments::getListRepository - * @todo Implement testGetListRepository(). - */ - public function testGetListRepository() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/comments') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListRepository('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesComments::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/commits/123/comments') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', '123'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesComments::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/comments/123') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 123), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesComments::edit - * @todo Implement testEdit(). - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/comments/123') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 123, 'My Comment'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesComments::delete - * @todo Implement testDelete(). - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/comments/123') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', 123), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesComments::create - * @todo Implement testCreate(). - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/commits/123abc/comments') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', '123abc', 'My Comment', 456, 'path/file.php', 789), - $this->equalTo(json_decode($this->sampleString)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesContentsTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesContentsTest.php deleted file mode 100644 index 37a205e38e..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesContentsTest.php +++ /dev/null @@ -1,195 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageRepositoriesContents($this->options, $this->client); - } - - /** - * @covers JGithubPackageRepositoriesContents::getReadme - * @todo Implement testGetReadme(). - */ - public function testGetReadme() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/readme') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getReadme('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesContents::getReadme - * @todo Implement testGetReadme(). - */ - public function testGetReadmeRef() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/readme?ref=123abc') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getReadme('joomla', 'joomla-platform', '123abc'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesContents::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/contents?path=path/to/file.php') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 'path/to/file.php'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesContents::get - * @todo Implement testGet(). - */ - public function testGetRef() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/contents?path=path/to/file.php&ref=123abc') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 'path/to/file.php', '123abc'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesContents::getArchiveLink - * @todo Implement testGetArchiveLink(). - */ - public function testGetArchiveLink() - { - $this->response->code = 302; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/zipball') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getArchiveLink('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesContents::getArchiveLink - * @todo Implement testGetArchiveLink(). - */ - public function testGetArchiveLinkRef() - { - $this->response->code = 302; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/zipball?ref=123abc') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getArchiveLink('joomla', 'joomla-platform', 'zipball', '123abc'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesContents::getArchiveLink - * @todo Implement testGetArchiveLink(). - * - * @expectedException UnexpectedValueException - */ - public function testGetArchiveLinkInvalidFormat() - { - $this->response->code = 302; - $this->response->body = $this->sampleString; - - $this->object->getArchiveLink('joomla', 'joomla-platform', 'invalid'); - } - -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesDownloadsTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesDownloadsTest.php deleted file mode 100644 index 44425c6a94..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesDownloadsTest.php +++ /dev/null @@ -1,160 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageRepositoriesDownloads($this->options, $this->client); - } - - /** - * @covers JGithubPackageRepositoriesDownloads::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/downloads') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesDownloads::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/downloads/123abc') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', '123abc'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesDownloads::create - * @todo Implement testCreate(). - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/downloads') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'aaa.zip', 1234, 'Description', 'content_type'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesDownloads::upload - * @todo Implement testUpload(). - */ - public function testUpload() - { - $this->response->code = 201; - $this->response->body = true; - - $this->client->expects($this->once()) - ->method('post') - ->with('https://github.s3.amazonaws.com/') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->upload('joomla', 'joomla-platform', 123, 'a/b/aaa.zip', 'acl', 201, 'aaa.zip', '123abc', '123abc', '123abc','content_type', '@aaa.zip'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageRepositoriesDownloads::delete - * @todo Implement testDelete(). - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/downloads/123') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', 123), - $this->equalTo(json_decode($this->sampleString)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesForksTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesForksTest.php deleted file mode 100644 index e4eda5525f..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesForksTest.php +++ /dev/null @@ -1,169 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubPackageRepositoriesForks($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 202; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'org' => 'jenkins-jools' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/forks', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'jenkins-jools'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array() - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/forks', $data) - ->will($this->returnValue($returnData)); - - $this->object->create('joomla', 'joomla-platform', ''); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/forks') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/forks') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesHooksTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesHooksTest.php deleted file mode 100644 index dcf819baee..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesHooksTest.php +++ /dev/null @@ -1,470 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageRepositoriesHooks($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - * - * @since 12.3 - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $hook = new stdClass; - $hook->name = 'acunote'; - $hook->config = array('token' => '123456789'); - $hook->events = array('push', 'public'); - $hook->active = true; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/hooks', json_encode($hook)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'acunote', array('token' => '123456789'), array('push', 'public')), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testCreateFailure() - { - $exception = false; - - $this->response->code = 500; - $this->response->body = $this->errorString; - - $hook = new stdClass; - $hook->name = 'acunote'; - $hook->config = array('token' => '123456789'); - $hook->events = array('push', 'public'); - $hook->active = true; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/hooks', json_encode($hook)) - ->will($this->returnValue($this->response)); - - try - { - $this->object->create('joomla', 'joomla-platform', 'acunote', array('token' => '123456789'), array('push', 'public')); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the create method - unauthorised event - * - * @return void - * - * @since 12.3 - * - * @expectedException RuntimeException - */ - public function testCreateUnauthorisedEvent() - { - $this->object->create('joomla', 'joomla-platform', 'acunote', array('token' => '123456789'), array('push', 'faker')); - } - - /** - * Tests the delete method - * - * @return void - * - * @since 12.3 - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/hooks/42') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', 42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the delete method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testDeleteFailure() - { - $exception = false; - - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/hooks/42') - ->will($this->returnValue($this->response)); - - try - { - $this->object->delete('joomla', 'joomla-platform', 42); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the edit method - * - * @return void - * - * @since 12.3 - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $hook = new stdClass; - $hook->name = 'acunote'; - $hook->config = array('token' => '123456789'); - $hook->events = array('push', 'public'); - $hook->add_events = array('watch'); - $hook->remove_events = array('watch'); - $hook->active = true; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/hooks/42', json_encode($hook)) - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 42, 'acunote', array('token' => '123456789'), - array('push', 'public'), array('watch'), array('watch') - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the edit method - simulated failure - * - * @return void - * - * @since 12.3 - */ - public function testEditFailure() - { - $exception = false; - - $this->response->code = 500; - $this->response->body = $this->errorString; - - $hook = new stdClass; - $hook->name = 'acunote'; - $hook->config = array('token' => '123456789'); - $hook->events = array('push', 'public'); - $hook->add_events = array('watch'); - $hook->remove_events = array('watch'); - $hook->active = true; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/hooks/42', json_encode($hook)) - ->will($this->returnValue($this->response)); - - try - { - $this->object->edit('joomla', 'joomla-platform', 42, 'acunote', array('token' => '123456789'), - array('push', 'public'), array('watch'), array('watch') - ); - } - catch (DomainException $e) - { - $exception = true; - - $this->assertThat( - $e->getMessage(), - $this->equalTo(json_decode($this->errorString)->message) - ); - } - $this->assertTrue($exception); - } - - /** - * Tests the edit method - unauthorised event - * - * @return void - * - * @since 12.3 - * - * @expectedException RuntimeException - */ - public function testEditUnauthorisedEvent() - { - $this->object->edit('joomla', 'joomla-platform', 42, 'acunote', array('token' => '123456789'), array('invalid')); - } - - /** - * Tests the edit method - unauthorised event - * - * @return void - * - * @since 12.3 - * - * @expectedException RuntimeException - */ - public function testEditUnauthorisedAddEvent() - { - $this->object->edit('joomla', 'joomla-platform', 42, 'acunote', array('token' => '123456789'), array('push'), array('invalid')); - } - - /** - * Tests the edit method - unauthorised event - * - * @return void - * - * @since 12.3 - * - * @expectedException RuntimeException - */ - public function testEditUnauthorisedRemoveEvent() - { - $this->object->edit('joomla', 'joomla-platform', 42, 'acunote', array('token' => '123456789'), array('push'), array('push'), array('invalid')); - } - - /** - * Tests the get method - * - * @return void - * - * @since 12.3 - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/hooks/42') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the get method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testGetFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/hooks/42') - ->will($this->returnValue($this->response)); - - $this->object->get('joomla', 'joomla-platform', 42); - } - - /** - * Tests the getList method - * - * @return void - * - * @since 12.3 - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/hooks') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testGetListFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/hooks') - ->will($this->returnValue($this->response)); - - $this->object->getList('joomla', 'joomla-platform'); - } - - /** - * Tests the test method - * - * @return void - * - * @since 12.3 - */ - public function testTest() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/hooks/42/test') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->test('joomla', 'joomla-platform', 42), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the test method - failure - * - * @return void - * - * @since 12.3 - * - * @expectedException DomainException - */ - public function testTestFailure() - { - $this->response->code = 500; - $this->response->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/hooks/42/test') - ->will($this->returnValue($this->response)); - - $this->object->test('joomla', 'joomla-platform', 42); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesKeysTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesKeysTest.php deleted file mode 100644 index 62db69450a..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesKeysTest.php +++ /dev/null @@ -1,250 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageRepositoriesKeys($this->options, $this->client); - } - - /** - * @covers JGithubPackageRepositoriesKeys::getList - * @todo Implement testGetList(). - * - * GET /repos/:owner/:repo/keys - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - [ - { - "id": 1, - "key": "ssh-rsa AAA...", - "url": "https://api.github.com/user/keys/1", - "title": "octocat@octomac" - } - ] - - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/keys') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesKeys::get - * @todo Implement testGet(). - * - * GET /repos/:owner/:repo/keys/:id - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "id": 1, - "key": "ssh-rsa AAA...", - "url": "https://api.github.com/user/keys/1", - "title": "octocat@octomac" - } - - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/keys/1') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get('joomla', 'joomla-platform', 1), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesKeys::create - * @todo Implement testCreate(). - * - * POST /repos/:owner/:repo/keys - - Input - - { - "title": "octocat@octomac", - "key": "ssh-rsa AAA..." - } - - Response - - Status: 201 Created - Location: https://api.github.com/user/repo/keys/1 - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "id": 1, - "key": "ssh-rsa AAA...", - "url": "https://api.github.com/user/keys/1", - "title": "octocat@octomac" - } - - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/keys') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('joomla', 'joomla-platform', 'email@example.com', '123abc'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesKeys::edit - * @todo Implement testEdit(). - * - * PATCH /repos/:owner/:repo/keys/:id - - Input - - { - "title": "octocat@octomac", - "key": "ssh-rsa AAA..." - } - - Response - - Status: 200 OK - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "id": 1, - "key": "ssh-rsa AAA...", - "url": "https://api.github.com/user/keys/1", - "title": "octocat@octomac" - } - - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/repos/joomla/joomla-platform/keys/1') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit('joomla', 'joomla-platform', 1, 'email@example.com', '123abc'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageRepositoriesKeys::delete - * @todo Implement testDelete(). - * - * DELETE /repos/:owner/:repo/keys/:id - - Response - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = true; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/repos/joomla/joomla-platform/keys/1') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('joomla', 'joomla-platform', 1), - $this->equalTo($this->response->body) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesMergingTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesMergingTest.php deleted file mode 100644 index 898b919bea..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesMergingTest.php +++ /dev/null @@ -1,265 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageRepositoriesMerging($this->options, $this->client); - } - - /** - * @covers JGithubPackageRepositoriesMerging::perform - * @todo Implement testPerform(). - * - * POST /repos/:owner/:repo/merges - - Input - - base - Required string - The name of the base branch that the head will be merged into. - head - Required string - The head to merge. This can be a branch name or a commit SHA1. - commit_message - Optional string - Commit message to use for the merge commit. If omitted, a default message will be used. - - { - "base": "master", - "head": "cool_feature", - "commit_message": "Shipped cool_feature!" - } - - Successful Response (The resulting merge commit) - - Status: 201 Created - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "commit": { - "sha": "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", - "commit": { - "author": { - "name": "The Octocat", - "date": "2012-03-06T15:06:50-08:00", - "email": "octocat@nowhere.com" - }, - "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", - "message": "Shipped cool_feature!", - "tree": { - "sha": "b4eecafa9be2f2006ce1b709d6857b07069b4608", - "url": "https://api.github.com/repos/octocat/Hello-World/git/trees/b4eecafa9be2f2006ce1b709d6857b07069b4608" - }, - "committer": { - "name": "The Octocat", - "date": "2012-03-06T15:06:50-08:00", - "email": "octocat@nowhere.com" - } - }, - "author": { - "gravatar_id": "7ad39074b0584bc555d0417ae3e7d974", - "avatar_url": "https://secure.gravatar.com/avatar/7ad39074b0584bc555d0417ae3e7d974?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png", - "url": "https://api.github.com/users/octocat", - "id": 583231, - "login": "octocat" - }, - "parents": [ - { - "sha": "553c2077f0edc3d5dc5d17262f6aa498e69d6f8e", - "url": "https://api.github.com/repos/octocat/Hello-World/commits/553c2077f0edc3d5dc5d17262f6aa498e69d6f8e" - }, - { - "sha": "762941318ee16e59dabbacb1b4049eec22f0d303", - "url": "https://api.github.com/repos/octocat/Hello-World/commits/762941318ee16e59dabbacb1b4049eec22f0d303" - } - ], - "url": "https://api.github.com/repos/octocat/Hello-World/commits/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", - "committer": { - "gravatar_id": "7ad39074b0584bc555d0417ae3e7d974", - "avatar_url": "https://secure.gravatar.com/avatar/7ad39074b0584bc555d0417ae3e7d974?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png", - "url": "https://api.github.com/users/octocat", - "id": 583231, - "login": "octocat" - } - } - } - - No-op response (base already contains the head, nothing to merge) - - Status: 204 No Content - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - Merge conflict response - - Status: 409 Conflict - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "message": "Merge Conflict" - } - - Missing base response - - Status: 404 Not Found - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "message": "Base does not exist" - } - - Missing head response - - Status: 404 Not Found - X-RateLimit-Limit: 5000 - X-RateLimit-Remaining: 4999 - - { - "message": "Head does not exist" - } - - */ - public function testPerform() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/merges') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->perform('joomla', 'joomla-platform', '123', '456', 'My Message'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testPerformNoOp() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/merges') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->perform('joomla', 'joomla-platform', '123', '456', 'My Message'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testPerformMissing() - { - $this->response->code = 404; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/merges') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->perform('joomla', 'joomla-platform', '123', '456', 'My Message'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testPerformConflict() - { - $this->response->code = 409; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/merges') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->perform('joomla', 'joomla-platform', '123', '456', 'My Message'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testPerformUnexpected() - { - $this->response->code = 666; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/merges') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->perform('joomla', 'joomla-platform', '123', '456', 'My Message'), - $this->equalTo(json_decode($this->sampleString)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesStatusesTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesStatusesTest.php deleted file mode 100644 index 663cc49317..0000000000 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesStatusesTest.php +++ /dev/null @@ -1,199 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - - $this->object = new JGithubPackageRepositoriesStatuses($this->options, $this->client); - } - - /** - * Tests the create method - * - * @return void - */ - public function testCreate() - { - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - // Build the request data. - $data = json_encode( - array( - 'state' => 'success', - 'target_url' => 'http://example.com/my_url', - 'description' => 'Success is the only option - failure is not.' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e', $data) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->create( - 'joomla', - 'joomla-platform', - '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'success', - 'http://example.com/my_url', - 'Success is the only option - failure is not.' - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the create method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testCreateFailure() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'state' => 'pending' - ) - ); - - $this->client->expects($this->once()) - ->method('post') - ->with('/repos/joomla/joomla-platform/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e', $data) - ->will($this->returnValue($returnData)); - - $this->object->create('joomla', 'joomla-platform', '6dcb09b5b57875f334f61aebed695e2e4193db5e', 'pending'); - } - - /** - * Tests the create method - failure - * - * @expectedException InvalidArgumentException - * - * @return void - */ - public function testCreateInvalidState() - { - $returnData = new stdClass; - $returnData->code = 501; - $returnData->body = $this->errorString; - - // Build the request data. - $data = json_encode( - array( - 'state' => 'pending' - ) - ); - - $this->object->create('joomla', 'joomla-platform', '6dcb09b5b57875f334f61aebed695e2e4193db5e', 'invalid'); - } - - /** - * Tests the getList method - * - * @return void - */ - public function testGetList() - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e') - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getList('joomla', 'joomla-platform', '6dcb09b5b57875f334f61aebed695e2e4193db5e'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getList method - failure - * - * @expectedException DomainException - * - * @return void - */ - public function testGetListFailure() - { - $returnData = new stdClass; - $returnData->code = 500; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/repos/joomla/joomla-platform/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e') - ->will($this->returnValue($returnData)); - - $this->object->getList('joomla', 'joomla-platform', '6dcb09b5b57875f334f61aebed695e2e4193db5e'); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/stubs/JGithubObjectMock.php b/tests/unit/suites/libraries/joomla/github/stubs/JGithubObjectMock.php deleted file mode 100644 index a65d85bbd6..0000000000 --- a/tests/unit/suites/libraries/joomla/github/stubs/JGithubObjectMock.php +++ /dev/null @@ -1,37 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageUsersEmails($this->options, $this->client); - } - - /** - * @covers JGithubPackageUsersEmails::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/emails') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersEmails::add - * @todo Implement testAdd(). - */ - public function testAdd() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/user/emails') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->add('email@example.com'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersEmails::delete - * @todo Implement testDelete(). - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/user/emails') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete('email@example.com'), - $this->equalTo(json_decode($this->sampleString)) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersFollowersTest.php b/tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersFollowersTest.php deleted file mode 100644 index a122a8c473..0000000000 --- a/tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersFollowersTest.php +++ /dev/null @@ -1,242 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageUsersFollowers($this->options, $this->client); - } - - /** - * @covers JGithubPackageUsersFollowers::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/followers') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersFollowers::getList - * @todo Implement testGetList(). - */ - public function testGetListWithUser() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/followers') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersFollowers::getListFollowedBy - * @todo Implement testGetListFollowedBy(). - */ - public function testGetListFollowedBy() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/following') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListFollowedBy(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersFollowers::getListFollowedBy - * @todo Implement testGetListFollowedBy(). - */ - public function testGetListFollowedByWithUser() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/following') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListFollowedBy('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersFollowers::check - * @todo Implement testCheck(). - */ - public function testCheck() - { - $this->response->code = 204; - $this->response->body = true; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/following/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageUsersFollowers::check - * @todo Implement testCheck(). - */ - public function testCheckNo() - { - $this->response->code = 404; - $this->response->body = false; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/following/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageUsersFollowers::check - * @todo Implement testCheck(). - * - * @expectedException UnexpectedValueException - */ - public function testCheckUnexpected() - { - $this->response->code = 666; - $this->response->body = false; - - $this->client->expects($this->once()) - ->method('get') - ->with('/user/following/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->check('joomla'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageUsersFollowers::follow - * @todo Implement testFollow(). - */ - public function testFollow() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('put') - ->with('/user/following/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->follow('joomla'), - $this->equalTo($this->response->body) - ); - } - - /** - * @covers JGithubPackageUsersFollowers::unfollow - * @todo Implement testUnfollow(). - */ - public function testUnfollow() - { - $this->response->code = 204; - $this->response->body = ''; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/user/following/joomla') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->unfollow('joomla'), - $this->equalTo($this->response->body) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersKeysTest.php b/tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersKeysTest.php deleted file mode 100644 index 62b276005d..0000000000 --- a/tests/unit/suites/libraries/joomla/github/users/JGithubPackageUsersKeysTest.php +++ /dev/null @@ -1,180 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JGithubHttp', array('get', 'post', 'delete', 'patch', 'put')); - $this->response = $this->getMock('JHttpResponse'); - - $this->object = new JGithubPackageUsersKeys($this->options, $this->client); - } - - /** - * @covers JGithubPackageUsersKeys::getListUser - * @todo Implement testGetListUser(). - */ - public function testGetListUser() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/joomla/keys') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getListUser('joomla'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersKeys::getList - * @todo Implement testGetList(). - */ - public function testGetList() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/keys') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->getList(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersKeys::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('get') - ->with('/users/keys/1') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->get(1), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersKeys::create - * @todo Implement testCreate(). - */ - public function testCreate() - { - $this->response->code = 201; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post') - ->with('/users/keys') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->create('email@example.com', '12345'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersKeys::edit - * @todo Implement testEdit(). - */ - public function testEdit() - { - $this->response->code = 200; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('patch') - ->with('/users/keys/1') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->edit(1, 'email@example.com', '12345'), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * @covers JGithubPackageUsersKeys::delete - * @todo Implement testDelete(). - */ - public function testDelete() - { - $this->response->code = 204; - $this->response->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with('/users/keys/1') - ->will($this->returnValue($this->response)); - - $this->assertThat( - $this->object->delete(1), - $this->equalTo(json_decode($this->sampleString)) - ); - } -}