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
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ public function networkConnect($network, $container, $endpointConfig = array())
),
array(
'Container' => $container,
'EndpointConfig' => $endpointConfig ? json_encode($endpointConfig) : null
'EndpointConfig' => $endpointConfig ? $endpointConfig : null
)
)->then(array($this->parser, 'expectJson'));
}
Expand All @@ -1567,7 +1567,7 @@ public function networkDisconnect($network, $container, $force = false)
),
array(
'Container' => $container,
'Force' => $this->boolArg($force)
'Force' => (bool) $force
)
)->then(array($this->parser, 'expectEmpty'));
}
Expand Down
21 changes: 19 additions & 2 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -770,14 +770,31 @@ public function testNetworkConnect()
$this->expectPromiseResolveWith($json, $this->client->networkConnect(123, $config));
}

public function testNetworkDisconnect()
public function testNetworkConnectWithEndpointConfig()
{
$json = array();
$this->expectRequestFlow('post', 'networks/123/disconnect', $this->createResponse(), 'expectEmpty');
$this->browser->expects($this->once())->method('post')->with('networks/123/connect', $this->anything(), '{"Container":"abc","EndpointConfig":{"Aliases":["foo"]}}')->willReturn(\React\Promise\resolve($this->createResponseJson($json)));
$this->parser->expects($this->once())->method('expectJson')->willReturn($json);

$this->expectPromiseResolveWith($json, $this->client->networkConnect(123, 'abc', array('Aliases' => array('foo'))));
}

public function testNetworkDisconnect()
{
$this->browser->expects($this->once())->method('post')->with('networks/123/disconnect', $this->anything(), '{"Container":"abc","Force":false}')->willReturn(\React\Promise\resolve($this->createResponse()));
$this->parser->expects($this->once())->method('expectEmpty')->willReturn('');

$this->expectPromiseResolveWith('', $this->client->networkDisconnect(123, 'abc'));
}

public function testNetworkDisconnectForce()
{
$this->browser->expects($this->once())->method('post')->with('networks/123/disconnect', $this->anything(), '{"Container":"abc","Force":true}')->willReturn(\React\Promise\resolve($this->createResponse()));
$this->parser->expects($this->once())->method('expectEmpty')->willReturn('');

$this->expectPromiseResolveWith('', $this->client->networkDisconnect(123, 'abc', true));
}

public function testNetworkPrune()
{
$json = array();
Expand Down
4 changes: 2 additions & 2 deletions tests/FunctionalClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,12 @@ public function testCreateConnectDisconnectAndRemoveNetwork()
$this->assertNotNull($network['Id']);
$this->assertEquals('', $network['Warning']);

$promise = $this->client->networkConnect($network['Id'], $container['Id']);
$promise = $this->client->networkConnect($network['Id'], $container['Id'], array('Aliases' => array('foo')));
$ret = \React\Async\await($promise);

$this->assertEquals('', $ret);

$promise = $this->client->networkDisconnect($network['Id'], $container['Id'], false);
$promise = $this->client->networkDisconnect($network['Id'], $container['Id'], true);
$ret = \React\Async\await($promise);

$this->assertEquals('', $ret);
Expand Down