Skip to content

Commit 8ce2cfe

Browse files
committed
- implemented Move issues to Sprint
- fixed #523 added createdDate property
1 parent 1306db5 commit 8ce2cfe

File tree

3 files changed

+75
-5
lines changed

3 files changed

+75
-5
lines changed

src/Sprint/Sprint.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ class Sprint implements \JsonSerializable
2929

3030
public string $originBoardId;
3131

32+
public string $createdDate;
33+
3234
public string $goal;
3335

36+
public array $issues;
37+
3438
public function setNameAsString(string $sprintName): self
3539
{
3640
$this->name = $sprintName;
@@ -51,18 +55,38 @@ public function setOriginBoardIdAsStringOrInt(string|int $originBoardId): self
5155

5256
return $this;
5357
}
54-
55-
public function setStartDateAsDateTime(DateTimeInterface $startDate, $format = 'Y-m-d'): static
58+
public function setStartDateAsDateTime(\DateTimeInterface $startDate, string $format = 'Y-m-d'): static
5659
{
5760
$this->startDate = $startDate->format($format);
5861

5962
return $this;
6063
}
6164

62-
public function setEndDateAsDateTime(DateTimeInterface $endDate, $format = 'Y-m-d'): static
65+
public function setStartDateAsString(string $startDate): static
66+
{
67+
$this->startDate = $startDate;
68+
69+
return $this;
70+
}
71+
72+
public function setEndDateAsDateTime(\DateTimeInterface $endDate, string $format = 'Y-m-d'): static
6373
{
6474
$this->endDate = $endDate->format($format);
6575

6676
return $this;
6777
}
78+
79+
public function setEndDateAsString(string $endDate): static
80+
{
81+
$this->endDate = $endDate;
82+
83+
return $this;
84+
}
85+
86+
public function setMoveIssues(array $issues): static
87+
{
88+
$this->issues = $issues;
89+
90+
return $this;
91+
}
6892
}

src/Sprint/SprintService.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,18 @@ public function createSprint(Sprint $sprint): Sprint
7979
new Sprint()
8080
);
8181
}
82+
83+
/**
84+
* @see https://docs.atlassian.com/jira-software/REST/9.11.0/#agile/1.0/sprint-moveIssuesToSprint
85+
*/
86+
public function moveIssues2Sprint(int $sprintId, Sprint $sprint): bool
87+
{
88+
$data = json_encode($sprint);
89+
90+
$ret = $this->exec($this->uri.'/'.$sprintId.'/issue', $data);
91+
92+
$this->log->debug('moveIssues2Sprint result='.var_export($ret, true));
93+
94+
return $ret;
95+
}
8296
}

tests/SPrintTest.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ public function get_sprints(int $sprintId) : int
7171
* @depends get_sprints
7272
*
7373
* @param int $sprintId
74-
* @return void
74+
* @return int
7575
*/
76-
public function get_issues_in_sprints(int $sprintId)
76+
public function get_issues_in_sprints(int $sprintId) : int
7777
{
7878
try {
7979
$sps = new SprintService();
@@ -82,8 +82,40 @@ public function get_issues_in_sprints(int $sprintId)
8282

8383
$this->assertNotNull($sprint);
8484
Dumper::dump($sprint);
85+
86+
return $sprintId;
8587
} catch (Exception $e) {
8688
$this->fail('testSearch Failed : '.$e->getMessage());
8789
}
8890
}
91+
92+
/**
93+
* @test
94+
* @depends get_issues_in_sprints
95+
*
96+
* @param int $sprintId
97+
* @return int
98+
*/
99+
public function move_issues_to_sprints(int $sprintId) : int
100+
{
101+
try {
102+
$sp = (new Sprint())
103+
->setMoveIssues([
104+
"MOBL-1",
105+
"MOBL-5",
106+
])
107+
108+
;
109+
110+
$sps = new SprintService();
111+
112+
$sprint = $sps->moveIssues2Sprint($sprintId, $sp);
113+
114+
$this->assertNotNull($sprint);
115+
116+
return $sprintId;
117+
} catch (Exception $e) {
118+
$this->fail('move_issues_to_sprints Failed : '.$e->getMessage());
119+
}
120+
}
89121
}

0 commit comments

Comments
 (0)