Skip to content

Commit 51e3a2d

Browse files
committed
add manual and test case for PR #155
1 parent 72cf7fd commit 51e3a2d

File tree

6 files changed

+132
-68
lines changed

6 files changed

+132
-68
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ $iss = new IssueService(new ArrayConfiguration(
151151
- [Get Users from group](#get-users-from-group)
152152
- [Add User to group](#add-user-to-group)
153153

154+
### Priority
155+
- [Get All Priority list](#get-all-priority-list)
156+
- [Get Priority](#get-priority)
157+
154158
#### Get Project Info
155159

156160
[See Jira API reference](https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/project-getProject)
@@ -1445,6 +1449,50 @@ try {
14451449

14461450
```
14471451

1452+
#### Get All Priority list
1453+
1454+
[See Jira API reference](https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/priority)
1455+
1456+
```php
1457+
<?php
1458+
require 'vendor/autoload.php';
1459+
1460+
use JiraRestApi\Priority\PriorityService;
1461+
use JiraRestApi\JiraException;
1462+
1463+
try {
1464+
$ps = new PriorityService();
1465+
1466+
$p = $ps->getAll();
1467+
1468+
var_dump($p);
1469+
} catch (JiraException $e) {
1470+
print("Error Occured! " . $e->getMessage());
1471+
}
1472+
```
1473+
1474+
#### Get Priority
1475+
1476+
[See Jira API reference](https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/priority)
1477+
1478+
```php
1479+
<?php
1480+
require 'vendor/autoload.php';
1481+
1482+
use JiraRestApi\Priority\PriorityService;
1483+
use JiraRestApi\JiraException;
1484+
1485+
try {
1486+
$ps = new PriorityService();
1487+
1488+
$p = $ps->get($priorityId = 1);
1489+
1490+
var_dump($p);
1491+
} catch (JiraException $e) {
1492+
print("Error Occured! " . $e->getMessage());
1493+
}
1494+
```
1495+
14481496
# License
14491497

14501498
Apache V2 License

src/Issue/Priority.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ class Priority implements \JsonSerializable
1616
/** @var string */
1717
public $id;
1818

19+
/** @var string */
20+
public $statusColor;
21+
22+
/** @var string */
23+
public $description;
24+
1925
public function jsonSerialize()
2026
{
2127
return array_filter(get_object_vars($this));

src/Priority/Priority.php

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/Priority/PriorityService.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace JiraRestApi\Priority;
44

5+
use \JiraRestApi\Issue\Priority;
6+
57
/**
68
* Class to query priority.
79
*/
@@ -19,8 +21,6 @@ class PriorityService extends \JiraRestApi\JiraClient
1921
*/
2022
public function getAll()
2123
{
22-
$queryParam = '?'.http_build_query();
23-
2424
$ret = $this->exec($this->uri, null);
2525

2626
$this->log->addInfo("Result=\n".$ret);
@@ -34,4 +34,25 @@ public function getAll()
3434

3535
return $priorities;
3636
}
37+
38+
/**
39+
* get specific priority info
40+
*
41+
* @param $priorityId priority id
42+
* @return \JiraRestApi\Priority\Priority
43+
*
44+
* @throws \JiraRestApi\JiraException
45+
* @throws \JsonMapper_Exception
46+
*/
47+
public function get($priorityId)
48+
{
49+
$ret = $this->exec($this->uri."/$priorityId", null);
50+
51+
$this->log->addInfo("Result=\n".$ret);
52+
53+
$priority = $this->json_mapper->map(json_decode($ret), new Priority());
54+
55+
return $priority;
56+
57+
}
3758
}

tests/CustomFieldsTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public function testGetFields()
1515
$ret = $fieldService->getAllFields(Field::CUSTOM);
1616
Dumper::dump($ret);
1717

18+
file_put_contents("custom-field.json", json_encode($ret, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));
19+
1820
$ids = array_map(function($cf) {
1921
// extract custom field id
2022
preg_match('/\d+/', $cf->id, $matches);
@@ -51,14 +53,15 @@ public function testGetFieldOptions($ids)
5153

5254
public function testCreateFields()
5355
{
54-
$this->markTestSkipped();
56+
//$this->markTestSkipped();
5557
try {
5658
$field = new Field();
5759

58-
$field->setName('New custom field')
60+
$field->setName('다중 선택이')
5961
->setDescription('Custom field for picking groups')
60-
->setType('com.atlassian.jira.plugin.system.customfieldtypes:grouppicker')
61-
->setSearcherKey('com.atlassian.jira.plugin.system.customfieldtypes:grouppickersearcher');
62+
->setType("com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect")
63+
// ->setSearcherKey('com.atlassian.jira.plugin.system.customfieldtypes:grouppickersearcher')
64+
;
6265

6366
$fieldService = new FieldService();
6467

tests/PriorityTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
use JiraRestApi\Dumper;
4+
use JiraRestApi\HTTPException;
5+
6+
use JiraRestApi\Priority\PriorityService;
7+
8+
class PriorityTest extends PHPUnit_Framework_TestCase
9+
{
10+
public function testAllPriority()
11+
{
12+
try {
13+
$ps = new PriorityService();
14+
15+
$pl = $ps->getAll();
16+
17+
$this->assertGreaterThan(1, count($pl));
18+
19+
var_dump($pl);
20+
21+
$priority = $pl[count($pl) - 1];
22+
23+
return $priority;
24+
25+
} catch (JiraException $e) {
26+
$this->assertTrue(FALSE, "add Comment Failed : " . $e->getMessage());
27+
}
28+
}
29+
30+
/**
31+
* @depends testAllPriority
32+
*
33+
*/
34+
public function testPriority($priority)
35+
{
36+
try {
37+
$ps = new PriorityService();
38+
39+
$pl = $ps->get($priority->id);
40+
41+
$this->assertEquals($priority->id, $pl->id);
42+
$this->assertEquals($priority->description, $pl->description);
43+
44+
} catch (JiraException $e) {
45+
$this->assertTrue(FALSE, "add Comment Failed : " . $e->getMessage());
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)