Skip to content

Commit 9e33545

Browse files
committed
Explicitly test for optional parameters
Empty parameters are no longer sent by default
1 parent 1361f31 commit 9e33545

1 file changed

Lines changed: 41 additions & 12 deletions

File tree

tests/ClientTest.php

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testContainerCreate()
3939
{
4040
$json = array();
4141
$config = array();
42-
$this->expectRequestFlow('post', '/containers/create?name=', $this->createResponseJson($json), 'expectJson');
42+
$this->expectRequestFlow('post', '/containers/create', $this->createResponseJson($json), 'expectJson');
4343

4444
$this->expectPromiseResolveWith($json, $this->client->containerCreate($config));
4545
}
@@ -64,7 +64,7 @@ public function testContainerInspect()
6464
public function testContainerTop()
6565
{
6666
$json = array();
67-
$this->expectRequestFlow('get', '/containers/123/top?ps_args=', $this->createResponseJson($json), 'expectJson');
67+
$this->expectRequestFlow('get', '/containers/123/top', $this->createResponseJson($json), 'expectJson');
6868

6969
$this->expectPromiseResolveWith($json, $this->client->containerTop(123));
7070
}
@@ -113,7 +113,7 @@ public function testContainerWait()
113113

114114
public function testContainerKill()
115115
{
116-
$this->expectRequestFlow('post', '/containers/123/kill?signal=', $this->createResponse(), 'expectEmpty');
116+
$this->expectRequestFlow('post', '/containers/123/kill', $this->createResponse(), 'expectEmpty');
117117

118118
$this->expectPromiseResolveWith('', $this->client->containerKill(123));
119119
}
@@ -170,11 +170,18 @@ public function testContainerUnpause()
170170

171171
public function testContainerRemove()
172172
{
173-
$this->expectRequestFlow('delete', '/containers/123?v=0&force=0', $this->createResponse(), 'expectEmpty');
173+
$this->expectRequestFlow('delete', '/containers/123', $this->createResponse(), 'expectEmpty');
174174

175175
$this->expectPromiseResolveWith('', $this->client->containerRemove(123, false, false));
176176
}
177177

178+
public function testContainerRemoveVolumeForce()
179+
{
180+
$this->expectRequestFlow('delete', '/containers/123?v=1&force=1', $this->createResponse(), 'expectEmpty');
181+
182+
$this->expectPromiseResolveWith('', $this->client->containerRemove(123, true, true));
183+
}
184+
178185
public function testContainerResize()
179186
{
180187
$this->expectRequestFlow('get', '/containers/123/resize?w=800&h=600', $this->createResponse(), 'expectEmpty');
@@ -205,17 +212,25 @@ public function testContainerCopyStream()
205212
public function testImageList()
206213
{
207214
$json = array();
208-
$this->expectRequestFlow('get', '/images/json?all=0', $this->createResponseJson($json), 'expectJson');
215+
$this->expectRequestFlow('get', '/images/json', $this->createResponseJson($json), 'expectJson');
209216

210217
$this->expectPromiseResolveWith($json, $this->client->imageList());
211218
}
212219

220+
public function testImageListAll()
221+
{
222+
$json = array();
223+
$this->expectRequestFlow('get', '/images/json?all=1', $this->createResponseJson($json), 'expectJson');
224+
225+
$this->expectPromiseResolveWith($json, $this->client->imageList(true));
226+
}
227+
213228
public function testImageCreate()
214229
{
215230
$json = array();
216231
$stream = $this->getMock('React\Stream\ReadableStreamInterface');
217232

218-
$this->expectRequest('post', '/images/create?fromImage=busybox&fromSrc=&repo=&tag=&registry=', $this->createResponseJsonStream($json));
233+
$this->expectRequest('post', '/images/create?fromImage=busybox', $this->createResponseJsonStream($json));
219234
$this->streamingParser->expects($this->once())->method('parseJsonStream')->will($this->returnValue($stream));
220235
$this->streamingParser->expects($this->once())->method('deferredStream')->with($this->equalTo($stream), $this->equalTo('progress'))->will($this->returnPromise($json));
221236

@@ -226,7 +241,7 @@ public function testImageCreateStream()
226241
{
227242
$stream = $this->getMock('React\Stream\ReadableStreamInterface');
228243

229-
$this->expectRequest('post', '/images/create?fromImage=busybox&fromSrc=&repo=&tag=&registry=', $this->createResponseJsonStream(array()));
244+
$this->expectRequest('post', '/images/create?fromImage=busybox', $this->createResponseJsonStream(array()));
230245
$this->streamingParser->expects($this->once())->method('parseJsonStream')->will($this->returnValue($stream));
231246

232247
$this->assertSame($stream, $this->client->imageCreateStream('busybox'));
@@ -253,7 +268,7 @@ public function testImagePush()
253268
$json = array();
254269
$stream = $this->getMock('React\Stream\ReadableStreamInterface');
255270

256-
$this->expectRequest('post', '/images/123/push?tag=', $this->createResponseJsonStream($json));
271+
$this->expectRequest('post', '/images/123/push', $this->createResponseJsonStream($json));
257272
$this->streamingParser->expects($this->once())->method('parseJsonStream')->will($this->returnValue($stream));
258273
$this->streamingParser->expects($this->once())->method('deferredStream')->with($this->equalTo($stream), $this->equalTo('progress'))->will($this->returnPromise($json));
259274

@@ -264,7 +279,7 @@ public function testImagePushStream()
264279
{
265280
$stream = $this->getMock('React\Stream\ReadableStreamInterface');
266281

267-
$this->expectRequest('post', '/images/123/push?tag=', $this->createResponseJsonStream(array()));
282+
$this->expectRequest('post', '/images/123/push', $this->createResponseJsonStream(array()));
268283
$this->streamingParser->expects($this->once())->method('parseJsonStream')->will($this->returnValue($stream));
269284

270285
$this->assertSame($stream, $this->client->imagePushStream('123'));
@@ -286,16 +301,30 @@ public function testImagePushCustomRegistry()
286301

287302
public function testImageTag()
288303
{
289-
$this->expectRequestFlow('post', '/images/123/tag?repo=test&tag=&force=0', $this->createResponse(), 'expectEmpty');
304+
$this->expectRequestFlow('post', '/images/123/tag?repo=test', $this->createResponse(), 'expectEmpty');
290305

291306
$this->expectPromiseResolveWith('', $this->client->imageTag('123', 'test'));
292307
}
293308

309+
public function testImageTagNameForce()
310+
{
311+
$this->expectRequestFlow('post', '/images/123/tag?repo=test&tag=tag&force=1', $this->createResponse(), 'expectEmpty');
312+
313+
$this->expectPromiseResolveWith('', $this->client->imageTag('123', 'test', 'tag', true));
314+
}
315+
294316
public function testImageRemove()
295317
{
296-
$this->expectRequestFlow('delete', '/images/123?force=0&noprune=0', $this->createResponse(), 'expectEmpty');
318+
$this->expectRequestFlow('delete', '/images/123', $this->createResponse(), 'expectEmpty');
319+
320+
$this->expectPromiseResolveWith('', $this->client->imageRemove('123'));
321+
}
322+
323+
public function testImageRemoveForceNoprune()
324+
{
325+
$this->expectRequestFlow('delete', '/images/123?force=1&noprune=1', $this->createResponse(), 'expectEmpty');
297326

298-
$this->expectPromiseResolveWith('', $this->client->imageRemove('123', 'test'));
327+
$this->expectPromiseResolveWith('', $this->client->imageRemove('123', true, true));
299328
}
300329

301330
public function testImageSearch()

0 commit comments

Comments
 (0)