diff --git a/lib/Formats/GitHub.php b/lib/Formats/GitHub.php index 06ebe1e..d508d59 100644 --- a/lib/Formats/GitHub.php +++ b/lib/Formats/GitHub.php @@ -101,7 +101,9 @@ class GitHub { } if(!empty($data['labels'])) { - $entry['category'] = $data['labels']; + $entry['category'] = array_map(function($l){ + return $l['name']; + }, $data['labels']); } $entry['published'] = $data['created_at']; diff --git a/tests/GitHubTest.php b/tests/GitHubTest.php index 99f5334..4ab5272 100644 --- a/tests/GitHubTest.php +++ b/tests/GitHubTest.php @@ -56,6 +56,18 @@ class GitHubTest extends PHPUnit_Framework_TestCase { $this->assertContains('> sebsel', $data['data']['content']['text']); } + public function testGitHubIssueWithCategory() { + $url = 'https://github.com/aaronpk/XRay/issues/20'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('entry', $data['data']['type']); + $this->assertContains('silo', $data['data']['category']); + } + public function testGitHubRepo() { $url = 'https://github.com/aaronpk/XRay'; $response = $this->parse(['url' => $url]); diff --git a/tests/data/api.github.com/repos_aaronpk_XRay_issues_20 b/tests/data/api.github.com/repos_aaronpk_XRay_issues_20 new file mode 100644 index 0000000..1f3ac57 --- /dev/null +++ b/tests/data/api.github.com/repos_aaronpk_XRay_issues_20 @@ -0,0 +1,95 @@ +HTTP/1.1 200 OK +Server: GitHub.com +Date: Sat, 22 Apr 2017 21:40:46 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 2949 +Status: 200 OK +X-RateLimit-Limit: 60 +X-RateLimit-Remaining: 51 +X-RateLimit-Reset: 1492900051 +Cache-Control: public, max-age=60, s-maxage=60 +Vary: Accept +ETag: "2e3e539de3e0bc6453a1330f364c2798" +Last-Modified: Sat, 22 Apr 2017 21:23:40 GMT +X-GitHub-Media-Type: github.v3; format=json +Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval +Access-Control-Allow-Origin: * +Content-Security-Policy: default-src 'none' +Strict-Transport-Security: max-age=31536000; includeSubdomains; preload +X-Content-Type-Options: nosniff +X-Frame-Options: deny +X-XSS-Protection: 1; mode=block +Vary: Accept-Encoding +X-Served-By: 77fbfb53269bbb85f82f23584d59f7c1 +X-GitHub-Request-Id: E449:2FCF:1C52A08:239875B:58FBCDDD + +{ + "url": "https://api.github.com/repos/aaronpk/XRay/issues/20", + "repository_url": "https://api.github.com/repos/aaronpk/XRay", + "labels_url": "https://api.github.com/repos/aaronpk/XRay/issues/20/labels{/name}", + "comments_url": "https://api.github.com/repos/aaronpk/XRay/issues/20/comments", + "events_url": "https://api.github.com/repos/aaronpk/XRay/issues/20/events", + "html_url": "https://github.com/aaronpk/XRay/issues/20", + "id": 199968615, + "number": 20, + "title": "Parse GitHub posts", + "user": { + "login": "aaronpk", + "id": 113001, + "avatar_url": "https://avatars2.githubusercontent.com/u/113001?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/aaronpk", + "html_url": "https://github.com/aaronpk", + "followers_url": "https://api.github.com/users/aaronpk/followers", + "following_url": "https://api.github.com/users/aaronpk/following{/other_user}", + "gists_url": "https://api.github.com/users/aaronpk/gists{/gist_id}", + "starred_url": "https://api.github.com/users/aaronpk/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/aaronpk/subscriptions", + "organizations_url": "https://api.github.com/users/aaronpk/orgs", + "repos_url": "https://api.github.com/users/aaronpk/repos", + "events_url": "https://api.github.com/users/aaronpk/events{/privacy}", + "received_events_url": "https://api.github.com/users/aaronpk/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 519686101, + "url": "https://api.github.com/repos/aaronpk/XRay/labels/silo", + "name": "silo", + "color": "1d76db", + "default": false + } + ], + "state": "closed", + "locked": false, + "assignee": null, + "assignees": [ + + ], + "milestone": null, + "comments": 0, + "created_at": "2017-01-11T00:04:28Z", + "updated_at": "2017-04-22T21:23:40Z", + "closed_at": "2017-04-22T21:23:40Z", + "body": "* [x] Issues\r\n* [x] Issue comments\r\n", + "closed_by": { + "login": "aaronpk", + "id": 113001, + "avatar_url": "https://avatars2.githubusercontent.com/u/113001?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/aaronpk", + "html_url": "https://github.com/aaronpk", + "followers_url": "https://api.github.com/users/aaronpk/followers", + "following_url": "https://api.github.com/users/aaronpk/following{/other_user}", + "gists_url": "https://api.github.com/users/aaronpk/gists{/gist_id}", + "starred_url": "https://api.github.com/users/aaronpk/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/aaronpk/subscriptions", + "organizations_url": "https://api.github.com/users/aaronpk/orgs", + "repos_url": "https://api.github.com/users/aaronpk/repos", + "events_url": "https://api.github.com/users/aaronpk/events{/privacy}", + "received_events_url": "https://api.github.com/users/aaronpk/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file