Skip to content

Commit 60ecc19

Browse files
committed
Fix networkConnect() to send $endpointConfig as JSON object
1 parent a6b0b5b commit 60ecc19

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎src/Client.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ public function networkConnect($network, $container, $endpointConfig = array())
15411541
),
15421542
array(
15431543
'Container' => $container,
1544-
'EndpointConfig' => $endpointConfig ? json_encode($endpointConfig) : null
1544+
'EndpointConfig' => $endpointConfig ? $endpointConfig : null
15451545
)
15461546
)->then(array($this->parser, 'expectJson'));
15471547
}

‎tests/ClientTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,15 @@ public function testNetworkConnect()
770770
$this->expectPromiseResolveWith($json, $this->client->networkConnect(123, $config));
771771
}
772772

773+
public function testNetworkConnectWithEndpointConfig()
774+
{
775+
$json = array();
776+
$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)));
777+
$this->parser->expects($this->once())->method('expectJson')->willReturn($json);
778+
779+
$this->expectPromiseResolveWith($json, $this->client->networkConnect(123, 'abc', array('Aliases' => array('foo'))));
780+
}
781+
773782
public function testNetworkDisconnect()
774783
{
775784
$this->browser->expects($this->once())->method('post')->with('networks/123/disconnect', $this->anything(), '{"Container":"abc","Force":false}')->willReturn(\React\Promise\resolve($this->createResponse()));

‎tests/FunctionalClientTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public function testCreateConnectDisconnectAndRemoveNetwork()
454454
$this->assertNotNull($network['Id']);
455455
$this->assertEquals('', $network['Warning']);
456456

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

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

0 commit comments

Comments
 (0)