From 4241d3de621125077dd4becf1ad2b6f5a584c06c Mon Sep 17 00:00:00 2001 From: Adam Leach Date: Wed, 9 Sep 2015 17:06:10 +0100 Subject: [PATCH 1/2] Added an additional field of avatarId to IssueTypes as Jira Cloud is now returning this field via the api and causing the call to fail --- composer.json | 5 ++++ src/Jira/IssueType.php | 3 +++ tests/Jira/IssueTypeTest.php | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/Jira/IssueTypeTest.php diff --git a/composer.json b/composer.json index 3388fd6..f420fdf 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,11 @@ "chobie\\" : "src" } }, + "autoload-dev": { + "psr-4": { + "chobie\\Tests\\": "tests" + } + }, "extra": { "branch-alias": { "dev-master": "2.0-dev" diff --git a/src/Jira/IssueType.php b/src/Jira/IssueType.php index 66db032..eca0cc2 100644 --- a/src/Jira/IssueType.php +++ b/src/Jira/IssueType.php @@ -38,6 +38,8 @@ class IssueType protected $subtask; + protected $avatarId; + private $acceptable_keys = array( "self", "id", @@ -45,6 +47,7 @@ class IssueType "iconUrl", "name", "subtask", + "avatarId", ); public function __construct($types) diff --git a/tests/Jira/IssueTypeTest.php b/tests/Jira/IssueTypeTest.php new file mode 100644 index 0000000..be03d05 --- /dev/null +++ b/tests/Jira/IssueTypeTest.php @@ -0,0 +1,45 @@ + "https://hosted.atlassian.net/rest/api/2/issuetype/4", + 'id' => "4", + 'description' => "An improvement or enhancement to an existing feature or task.", + 'iconUrl' => "https://hosted.atlassian.net/secure/viewavatar?size=xsmall&avatarId=1&avatarType=issuetype", + 'name' => "Improvement", + 'subtask' => false, + 'avatarId' => 1 + ); + $issueType = new IssueType($issueTypeSource); + $this->assertEquals($issueType->getId(), $issueTypeSource['id']); + $this->assertEquals($issueType->getDescription(), $issueTypeSource['description']); + $this->assertEquals($issueType->getIconUrl(), $issueTypeSource['iconUrl']); + $this->assertEquals($issueType->getName(), $issueTypeSource['name']); + $this->assertEquals($issueType->getAvatarId(), $issueTypeSource['avatarId']); + } + + public function testHandlesSingleIssueTypeWithoutAvatarId() + { + $issueTypeSource = array( + 'self' => "https://hosted.atlassian.net/rest/api/2/issuetype/4", + 'id' => "4", + 'description' => "An improvement or enhancement to an existing feature or task.", + 'iconUrl' => "https://hosted.atlassian.net/secure/viewavatar?size=xsmall&avatarId=1&avatarType=issuetype", + 'name' => "Improvement", + 'subtask' => false + ); + $issueType = new IssueType($issueTypeSource); + $this->assertEquals($issueType->getId(), $issueTypeSource['id']); + $this->assertEquals($issueType->getDescription(), $issueTypeSource['description']); + $this->assertEquals($issueType->getIconUrl(), $issueTypeSource['iconUrl']); + $this->assertEquals($issueType->getName(), $issueTypeSource['name']); + } +} From 3292dfb72fc5acbe396164d1b3addcf1b4ac055d Mon Sep 17 00:00:00 2001 From: Adam Leach Date: Wed, 9 Sep 2015 17:11:24 +0100 Subject: [PATCH 2/2] Adding missing getter to pass tests --- src/Jira/IssueType.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Jira/IssueType.php b/src/Jira/IssueType.php index eca0cc2..35d3de5 100644 --- a/src/Jira/IssueType.php +++ b/src/Jira/IssueType.php @@ -85,4 +85,9 @@ public function getIconUrl() { return $this->iconUrl; } -} \ No newline at end of file + + public function getAvatarId() + { + return $this->avatarId; + } +}