diff --git a/lib/Gitlab/Api/Environments.php b/lib/Gitlab/Api/Environments.php index 48270a633..28e40f511 100644 --- a/lib/Gitlab/Api/Environments.php +++ b/lib/Gitlab/Api/Environments.php @@ -45,4 +45,14 @@ public function remove($project_id, $environment_id) { return $this->delete($this->getProjectPath($project_id, 'environments/' . $environment_id)); } + + /** + * @param int $project_id + * @param string $environment_id + * @return mixed + */ + public function stop($project_id, $environment_id) + { + return $this->post($this->getProjectPath($project_id, 'environments/'.$this->encodePath($environment_id).'/stop')); + } } diff --git a/lib/Gitlab/Client.php b/lib/Gitlab/Client.php index a8d593571..1662187c3 100644 --- a/lib/Gitlab/Client.php +++ b/lib/Gitlab/Client.php @@ -254,6 +254,22 @@ public function version() return new Api\Version($this); } + /** + * @return Api\Deployments + */ + public function deployments() + { + return new Api\Deployments($this); + } + + /** + * @return Api\Environments + */ + public function environments() + { + return new Api\Environments($this); + } + /** * @param string $name * @@ -317,6 +333,12 @@ public function api($name) case 'version': return $this->version(); + case 'environments': + return $this->environments(); + + case 'deployments': + return $this->deployments(); + default: throw new InvalidArgumentException('Invalid endpoint: "'.$name.'"'); } diff --git a/test/Gitlab/Tests/Api/EnvironmentsTest.php b/test/Gitlab/Tests/Api/EnvironmentsTest.php index 5715ea315..935c0e67c 100644 --- a/test/Gitlab/Tests/Api/EnvironmentsTest.php +++ b/test/Gitlab/Tests/Api/EnvironmentsTest.php @@ -73,6 +73,21 @@ public function shouldRemoveEnvironment() $this->assertEquals($expectedBool, $api->remove(1, 3)); } + /** + * @test + */ + public function shouldStopEnvironment() + { + $expectedBool = true; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with('projects/1/environments/3/stop') + ->will($this->returnValue($expectedBool)); + $this->assertEquals($expectedBool, $api->stop(1, 3)); + } + protected function getApiClass() { return 'Gitlab\Api\Environments';