diff --git a/src/Client.php b/src/Client.php index 40aebe3..9303184 100644 --- a/src/Client.php +++ b/src/Client.php @@ -311,12 +311,12 @@ public function containerStart($container, $config = array()) /** * Stop the container id * - * @param string $container container ID - * @param int $t number of seconds to wait before killing the container + * @param string $container container ID + * @param null|int $t (optional) number of seconds to wait before killing the container * @return Promise Promise * @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#stop-a-container */ - public function containerStop($container, $t) + public function containerStop($container, $t = null) { return $this->browser->post( $this->uri->expand( @@ -332,12 +332,12 @@ public function containerStop($container, $t) /** * Restart the container id * - * @param string $container container ID - * @param int $t number of seconds to wait before killing the container + * @param string $container container ID + * @param null|int $t (optional) number of seconds to wait before killing the container * @return Promise Promise * @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#restart-a-container */ - public function containerRestart($container, $t) + public function containerRestart($container, $t = null) { return $this->browser->post( $this->uri->expand( diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 192e029..7aa7992 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -143,6 +143,13 @@ public function testContainerStart() } public function testContainerStop() + { + $this->expectRequestFlow('post', '/containers/123/stop', $this->createResponse(), 'expectEmpty'); + + $this->expectPromiseResolveWith('', $this->client->containerStop(123)); + } + + public function testContainerStopTimeout() { $this->expectRequestFlow('post', '/containers/123/stop?t=10', $this->createResponse(), 'expectEmpty'); @@ -150,6 +157,13 @@ public function testContainerStop() } public function testContainerRestart() + { + $this->expectRequestFlow('post', '/containers/123/restart', $this->createResponse(), 'expectEmpty'); + + $this->expectPromiseResolveWith('', $this->client->containerRestart(123)); + } + + public function testContainerRestartTimeout() { $this->expectRequestFlow('post', '/containers/123/restart?t=10', $this->createResponse(), 'expectEmpty');