Skip to content

Commit 3548b4a

Browse files
authored
[11.10] Add support for Schedules::takeOwnership and Schedules::play (#748)
1 parent c1c0483 commit 3548b4a

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

src/Api/Schedules.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,26 @@ public function removeVariable($project_id, int $schedule_id, string $variable_k
113113

114114
return $this->delete($this->getProjectPath($project_id, $path));
115115
}
116+
117+
/**
118+
* @param int|string $project_id
119+
* @param int $schedule_id
120+
*
121+
* @return mixed
122+
*/
123+
public function takeOwnership($project_id, int $schedule_id)
124+
{
125+
return $this->post($this->getProjectPath($project_id, 'pipeline_schedules/'.self::encodePath($schedule_id)).'/take_ownership');
126+
}
127+
128+
/**
129+
* @param int|string $project_id
130+
* @param int $schedule_id
131+
*
132+
* @return mixed
133+
*/
134+
public function play($project_id, int $schedule_id)
135+
{
136+
return $this->post($this->getProjectPath($project_id, 'pipeline_schedules/'.self::encodePath($schedule_id)).'/play');
137+
}
116138
}

tests/Api/ScheduleTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,40 @@ public function shouldRemoveScheduleVariable(): void
202202
$this->assertEquals($expectedBool, $api->removeVariable(1, 2, 'FOO_BAR'));
203203
}
204204

205+
/**
206+
* @test
207+
*/
208+
public function shouldTakeOwnership(): void
209+
{
210+
$expectedBool = true;
211+
212+
$api = $this->getApiMock();
213+
$api->expects($this->once())
214+
->method('post')
215+
->with('projects/1/pipeline_schedules/2/take_ownership')
216+
->will($this->returnValue($expectedBool))
217+
;
218+
219+
$this->assertEquals($expectedBool, $api->takeOwnership(1, 2));
220+
}
221+
222+
/**
223+
* @test
224+
*/
225+
public function shouldPlay(): void
226+
{
227+
$expectedBool = true;
228+
229+
$api = $this->getApiMock();
230+
$api->expects($this->once())
231+
->method('post')
232+
->with('projects/1/pipeline_schedules/2/play')
233+
->will($this->returnValue($expectedBool))
234+
;
235+
236+
$this->assertEquals($expectedBool, $api->play(1, 2));
237+
}
238+
205239
protected function getApiClass()
206240
{
207241
return Schedules::class;

0 commit comments

Comments
 (0)