Skip to content

Commit

Permalink
Merge branch 'KnpLabs:master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes authored Mar 25, 2024
2 parents 7fc5507 + 71fec50 commit bdfd9ff
Show file tree
Hide file tree
Showing 21 changed files with 180 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
coverage: none

- name: Install Composer Dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Run phpunit
run: vendor/bin/phpunit --verbose
Expand All @@ -41,7 +41,7 @@ jobs:
coverage: none

- name: Install Composer Dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Run phpstan
run: vendor/bin/phpstan analyse --no-progress
10 changes: 10 additions & 0 deletions CHANGELOG-3.X.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 3.14.1

### Fixed
- Handle case of GitHub returning 204 No Content in some scenarios ([tomcorbett](https://github.com/tomcorbett)) [#1135](https://github.com/KnpLabs/php-github-api/issues/1135)

## 3.14.0

### Added
- Allow php-http/cache-plugin v2 ([GrahamCampbell](https://github.com/GrahamCampbell)) [#1134](https://github.com/KnpLabs/php-github-api/issues/1134)

## 3.13.0

### Added
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"require": {
"php": "^7.2.5 || ^8.0",
"ext-json": "*",
"php-http/cache-plugin": "^1.7.1",
"php-http/cache-plugin": "^1.7.1|^2.0",
"php-http/client-common": "^2.3",
"php-http/discovery": "^1.12",
"php-http/httplug": "^2.2",
Expand Down Expand Up @@ -52,7 +52,7 @@
"extra": {
"branch-alias": {
"dev-2.x": "2.20.x-dev",
"dev-master": "3.13-dev"
"dev-master": "3.14-dev"
}
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion lib/Github/Api/Issue/Labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function deleteLabel($username, $repository, $label)
public function update($username, $repository, $label, $newName, $color)
{
$params = [
'name' => $newName,
'name' => $newName,
'color' => $color,
];

Expand Down
6 changes: 3 additions & 3 deletions lib/Github/Api/Issue/Milestones.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function all($username, $repository, array $params = [])
}

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones', array_merge([
'page' => 1,
'state' => 'open',
'sort' => 'due_date',
'page' => 1,
'state' => 'open',
'sort' => 'due_date',
'direction' => 'asc',
], $params));
}
Expand Down
14 changes: 7 additions & 7 deletions lib/Github/Api/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ public function create(
$path = null !== $organization ? '/orgs/'.$organization.'/repos' : '/user/repos';

$parameters = [
'name' => $name,
'description' => $description,
'homepage' => $homepage,
'private' => ($visibility ?? ($public ? 'public' : 'private')) === 'private',
'has_issues' => $hasIssues,
'has_wiki' => $hasWiki,
'name' => $name,
'description' => $description,
'homepage' => $homepage,
'private' => ($visibility ?? ($public ? 'public' : 'private')) === 'private',
'has_issues' => $hasIssues,
'has_wiki' => $hasWiki,
'has_downloads' => $hasDownloads,
'auto_init' => $autoInit,
'auto_init' => $autoInit,
'has_projects' => $hasProjects,
];

Expand Down
4 changes: 2 additions & 2 deletions lib/Github/Api/Repository/Contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function update($username, $repository, $path, $content, $message, $sha,
$parameters = [
'content' => base64_encode($content),
'message' => $message,
'sha' => $sha,
'sha' => $sha,
];

if (null !== $branch) {
Expand Down Expand Up @@ -221,7 +221,7 @@ public function rm($username, $repository, $path, $message, $sha, $branch = null

$parameters = [
'message' => $message,
'sha' => $sha,
'sha' => $sha,
];

if (null !== $branch) {
Expand Down
4 changes: 4 additions & 0 deletions lib/Github/ResultPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public function fetch(AbstractApi $api, string $method, array $parameters = []):
$api = $closure($api);
$result = $api->$method(...$parameters);

if ($result === '' && $this->client->getLastResponse()->getStatusCode() === 204) {
$result = [];
}

$this->postFetch(true);

return $result ? $result : [];
Expand Down
18 changes: 9 additions & 9 deletions test/Github/Tests/Api/CurrentUser/MembershipsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ public function shouldGetMemberships()
[
'organization' => [
'login' => 'octocat',
'id' => 1,
'id' => 1,
],
'user' => [
'user' => [
'login' => 'defunkt',
'id' => 3,
'id' => 3,
],
],
[
'organization' => [
'login' => 'invitocat',
'id' => 2,
'id' => 2,
],
'user' => [
'user' => [
'login' => 'defunkt',
'id' => 3,
'id' => 3,
],
],
];
Expand All @@ -51,11 +51,11 @@ public function shouldGetMembershipsForOrganization()
$expectedValue = [
'organization' => [
'login' => 'invitocat',
'id' => 2,
'id' => 2,
],
'user' => [
'user' => [
'login' => 'defunkt',
'id' => 3,
'id' => 3,
],
];

Expand Down
4 changes: 2 additions & 2 deletions test/Github/Tests/Api/GistsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ public function shouldUpdateGist()
'files' => [
'filename.txt' => [
'filename' => 'new_name.txt',
'content' => 'content',
'content' => 'content',
],
'filename_new.txt' => [
'content' => 'content new',
'content' => 'content new',
],
],
];
Expand Down
10 changes: 5 additions & 5 deletions test/Github/Tests/Api/GitData/TreesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public function shouldCreateTreeUsingSha()
'path' => 'path',
'mode' => 'mode',
'type' => 'type',
'sha' => '1234',
'sha' => '1234',
],
[
'path' => 'htap',
'mode' => 'edom',
'type' => 'epyt',
'sha' => '4321',
'sha' => '4321',
],
],
];
Expand Down Expand Up @@ -118,7 +118,7 @@ public function shouldNotCreateTreeWithoutPathParam()
'tree' => [
'mode' => 'mode',
'type' => 'type',
'content' => 'content',
'content' => 'content',
],
];

Expand All @@ -139,7 +139,7 @@ public function shouldNotCreateTreeWithoutModeParam()
'tree' => [
'path' => 'path',
'type' => 'type',
'content' => 'content',
'content' => 'content',
],
];

Expand All @@ -160,7 +160,7 @@ public function shouldNotCreateTreeWithoutTypeParam()
'tree' => [
'path' => 'path',
'mode' => 'mode',
'content' => 'content',
'content' => 'content',
],
];

Expand Down
4 changes: 2 additions & 2 deletions test/Github/Tests/Api/GraphQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function shouldTestGraphQL()

$api->expects($this->once())
->method('post')
->with($this->equalTo('/graphql'), $this->equalTo(['query'=>'bar']))
->with($this->equalTo('/graphql'), $this->equalTo(['query' => 'bar']))
->will($this->returnValue('foo'));

$result = $api->execute('bar');
Expand Down Expand Up @@ -44,7 +44,7 @@ public function shouldJSONEncodeGraphQLVariables()
$api->expects($this->once())
->method('post')
->with('/graphql', $this->equalTo([
'query'=>'bar',
'query' => 'bar',
'variables' => '{"variable":"foo"}',
]));

Expand Down
10 changes: 5 additions & 5 deletions test/Github/Tests/Api/IssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function shouldGetIssuesUsingAdditionalParameters()
$data = [
'state' => 'open',
'milestone' => '*',
'assignee' => 'l3l0',
'assignee' => 'l3l0',
'mentioned' => 'l3l0',
'labels' => 'bug,@high',
'sort' => 'created',
'labels' => 'bug,@high',
'sort' => 'created',
'direction' => 'asc',
];
$sentData = $data + [
Expand Down Expand Up @@ -77,7 +77,7 @@ public function shouldCreateIssue()
{
$data = [
'title' => 'some title',
'body' => 'some body',
'body' => 'some body',
];

$api = $this->getApiMock();
Expand All @@ -95,7 +95,7 @@ public function shouldNotCreateIssueWithoutTitle()
{
$this->expectException(MissingArgumentException::class);
$data = [
'body' => 'some body',
'body' => 'some body',
];

$api = $this->getApiMock();
Expand Down
28 changes: 14 additions & 14 deletions test/Github/Tests/Api/PullRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ public function shouldMergePullRequestWithMergeMethod()
public function shouldCreatePullRequestUsingTitle()
{
$data = [
'base' => 'master',
'head' => 'virtualtestbranch',
'base' => 'master',
'head' => 'virtualtestbranch',
'title' => 'TITLE: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
];

$api = $this->getApiMock();
Expand All @@ -263,8 +263,8 @@ public function shouldCreatePullRequestUsingTitle()
public function shouldCreatePullRequestUsingIssueId()
{
$data = [
'base' => 'master',
'head' => 'virtualtestbranch',
'base' => 'master',
'head' => 'virtualtestbranch',
'issue' => 25,
];

Expand All @@ -282,10 +282,10 @@ public function shouldCreatePullRequestUsingIssueId()
public function shouldCreateDraftPullRequest()
{
$data = [
'base' => 'master',
'head' => 'virtualtestbranch',
'base' => 'master',
'head' => 'virtualtestbranch',
'title' => 'TITLE: Testing draft pull-request creation from PHP Github API',
'body' => 'BODY: Testing draft pull-request creation from PHP Github API',
'body' => 'BODY: Testing draft pull-request creation from PHP Github API',
'draft' => 'true',
];

Expand All @@ -304,9 +304,9 @@ public function shouldNotCreatePullRequestWithoutBase()
{
$this->expectException(MissingArgumentException::class);
$data = [
'head' => 'virtualtestbranch',
'head' => 'virtualtestbranch',
'title' => 'TITLE: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
];

$api = $this->getApiMock();
Expand All @@ -323,9 +323,9 @@ public function shouldNotCreatePullRequestWithoutHead()
{
$this->expectException(MissingArgumentException::class);
$data = [
'base' => 'master',
'base' => 'master',
'title' => 'TITLE: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
];

$api = $this->getApiMock();
Expand All @@ -342,8 +342,8 @@ public function shouldNotCreatePullRequestUsingTitleButWithoutBody()
{
$this->expectException(MissingArgumentException::class);
$data = [
'base' => 'master',
'head' => 'virtualtestbranch',
'base' => 'master',
'head' => 'virtualtestbranch',
'title' => 'TITLE: Testing pull-request creation from PHP Github API',
];

Expand Down
Loading

0 comments on commit bdfd9ff

Please sign in to comment.