Skip to content

Commit 65ff01a

Browse files
committed
Merge pull request #28 from clue-labs/timeout
Timeout $t is optional for containerStop() and containerRestart()
2 parents 63f2fd7 + 9b6c7c3 commit 65ff01a

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/Client.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,12 @@ public function containerStart($container, $config = array())
311311
/**
312312
* Stop the container id
313313
*
314-
* @param string $container container ID
315-
* @param int $t number of seconds to wait before killing the container
314+
* @param string $container container ID
315+
* @param null|int $t (optional) number of seconds to wait before killing the container
316316
* @return Promise Promise<null>
317317
* @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#stop-a-container
318318
*/
319-
public function containerStop($container, $t)
319+
public function containerStop($container, $t = null)
320320
{
321321
return $this->browser->post(
322322
$this->uri->expand(
@@ -332,12 +332,12 @@ public function containerStop($container, $t)
332332
/**
333333
* Restart the container id
334334
*
335-
* @param string $container container ID
336-
* @param int $t number of seconds to wait before killing the container
335+
* @param string $container container ID
336+
* @param null|int $t (optional) number of seconds to wait before killing the container
337337
* @return Promise Promise<null>
338338
* @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#restart-a-container
339339
*/
340-
public function containerRestart($container, $t)
340+
public function containerRestart($container, $t = null)
341341
{
342342
return $this->browser->post(
343343
$this->uri->expand(

tests/ClientTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,27 @@ public function testContainerStart()
143143
}
144144

145145
public function testContainerStop()
146+
{
147+
$this->expectRequestFlow('post', '/containers/123/stop', $this->createResponse(), 'expectEmpty');
148+
149+
$this->expectPromiseResolveWith('', $this->client->containerStop(123));
150+
}
151+
152+
public function testContainerStopTimeout()
146153
{
147154
$this->expectRequestFlow('post', '/containers/123/stop?t=10', $this->createResponse(), 'expectEmpty');
148155

149156
$this->expectPromiseResolveWith('', $this->client->containerStop(123, 10));
150157
}
151158

152159
public function testContainerRestart()
160+
{
161+
$this->expectRequestFlow('post', '/containers/123/restart', $this->createResponse(), 'expectEmpty');
162+
163+
$this->expectPromiseResolveWith('', $this->client->containerRestart(123));
164+
}
165+
166+
public function testContainerRestartTimeout()
153167
{
154168
$this->expectRequestFlow('post', '/containers/123/restart?t=10', $this->createResponse(), 'expectEmpty');
155169

0 commit comments

Comments
 (0)