Skip to content

Commit 94749da

Browse files
committed
issue
1 parent 02cc4e0 commit 94749da

File tree

5 files changed

+87
-32
lines changed

5 files changed

+87
-32
lines changed

src/issue/Issue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Issue {
99
*/
1010
public $expand;
1111

12-
/* @var string */
12+
/* @var string */
1313
public $self;
1414

1515
/* @var string */

src/issue/IssueField.php

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
namespace JiraRestApi\Issue;
44

55
class IssueField {
6+
public function __construct() {
7+
$this->project = new \JiraRestApi\Project\Project();
8+
$this->reporter = new \JiraRestApi\Issue\Reporter();
9+
$this->assignee = new \JiraRestApi\Issue\Reporter();
10+
$this->priority = new \JiraRestApi\Issue\Priority();
11+
}
12+
613
/** @var string */
714
public $summary;
815

@@ -18,7 +25,7 @@ class IssueField {
1825
/** @var string */
1926
public $timespent;
2027

21-
/** @var string */
28+
/** @var Reporter */
2229
public $reporter;
2330

2431
/** @var DateTime */
@@ -30,7 +37,7 @@ class IssueField {
3037
/** @var string */
3138
public $description;
3239

33-
/** @var string */
40+
/** @var Priority */
3441
public $priority;
3542

3643
/** @var IssueStatus */
@@ -39,19 +46,41 @@ class IssueField {
3946
/** @var string */
4047
public $labels;
4148

42-
/** @var string */
49+
/** @var JiraRestApi\Project\Project */
4350
public $project;
4451

4552
/** @var string */
4653
public $environment;
4754

4855
/** @var string */
4956
public $components;
57+
58+
/** @var Comments */
59+
public $comment;
5060

5161
/** @var string */
52-
public $versions;
62+
public $votes;
5363

54-
64+
/** @var string */
65+
public $resolution;
66+
67+
/** @var string */
68+
public $fixVersions;
69+
70+
/** @var Reporter */
71+
public $creator;
72+
73+
/** @var string */
74+
public $watches;
75+
76+
/** @var string */
77+
public $worklog;
78+
79+
/** @var Reporter */
80+
public $assignee;
81+
82+
/** @var string */
83+
public $versions;
5584
}
5685

5786
?>

src/issue/IssueService.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,21 @@ public function get($issueIdOrKey) {
3535
*
3636
* @return created issue key
3737
*/
38-
public function create($issue) {
39-
$ret = $this->exec($this->uri, null);
38+
public function create($issueField) {
39+
$issue = new Issue();
40+
$issue->fields = $issueField;
4041

41-
$this->log->addInfo("Result=\n" . $ret );
42+
$data = json_encode($issue);
4243

43-
$prj = $this->json_mapper->map(
44-
json_decode($ret), new Project()
45-
);
44+
$this->log->addInfo("Create Issue=\n" . $data );
4645

47-
return $prj;
46+
$ret = $this->exec($this->uri, $data, "POST");
47+
48+
$issue = $this->json_mapper->map(
49+
json_decode($ret), new Issue()
50+
);
51+
52+
return $issue;
4853
}
4954
}
5055

src/issue/Priority.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace JiraRestApi\Issue;
4+
5+
class Priority {
6+
/* @var string */
7+
public $self;
8+
9+
/* @var string */
10+
public $iconUrl;
11+
12+
/* @var string */
13+
public $name;
14+
15+
/* @var string */
16+
public $id;
17+
}
18+
19+
?>

tests/IssueTest.php

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
11
<?php
22

33
use JiraRestApi\Issue\IssueService;
4+
use JiraRestApi\Issue\IssueField;
45

56
class IssueTest extends PHPUnit_Framework_TestCase
67
{
78
public function testIssue()
89
{
9-
//$this->markTestIncomplete();
10+
$this->markTestIncomplete();
1011
try {
1112
$issueService = new IssueService(getHostConfig(), getOptions());
1213

1314
$issue = $issueService->get('TEST-867');
1415

1516
file_put_contents('jira-issue.json', json_encode($issue, JSON_PRETTY_PRINT));
1617

17-
print_r($issue->fields->assignee);
18-
/*
19-
foreach ($issue->components as $c) {
20-
echo ("COM : " . $c->name . "\n");
21-
}
22-
*/
18+
print_r($issue->fields->versions[0]);
19+
20+
//foreach ($issue->fields->comment->comments as $c) {
21+
// echo ("comment : " . $c->body . "\n");
22+
//}
23+
2324
} catch (HTTPException $e) {
2425
$this->assertTrue(FALSE, $e->getMessage());
2526
}
2627
}
2728

2829
public function testCreateIssue()
2930
{
30-
$this->markTestIncomplete();
31+
//$this->markTestIncomplete();
3132
try {
32-
$issueService = new IssueService(getHostConfig(), getOptions());
33+
$issueField = new IssueField();
34+
$issueField->project->name = "TEST";
35+
$issueField->summary = "something's wrong";
36+
$issueField->reporter->name = "smithers";
37+
$issueField->assignee->name = "homer";
38+
$issueField->priority->name = "Critical";
39+
$issueField->description = "Full description for issue";
3340

34-
$issue = new Issue();
35-
$issue = $issueService->getAllProjects();
41+
//$issueService = new IssueService(getHostConfig(), getOptions());
3642

37-
$i = 0;
38-
foreach ($issue as $p) {
39-
echo sprintf("Project Key:%s, Id:%s, Name:%s, projectCategory: %s\n",
40-
$p->key, $p->id, $p->name, $p->projectCategory['name']
41-
);
42-
43-
}
43+
//$ret = $issueService->create($issueField);
44+
45+
//print_r($ret);
4446
} catch (HTTPException $e) {
45-
$this->assertTrue(FALSE, $e->getMessage());
47+
$this->assertTrue(FALSE, "Create Failed : " . $e->getMessage());
4648
}
4749
}
4850
//

0 commit comments

Comments
 (0)