Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<null>
* @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(
Expand All @@ -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<null>
* @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(
Expand Down
14 changes: 14 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,27 @@ 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');

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

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');

Expand Down