Skip to content

Commit 2cdfade

Browse files
committed
Fix tests to support latest Docker version
1 parent d9f16d2 commit 2cdfade

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tests/FunctionalClientTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,21 @@ public function testCreateConnectDisconnectAndRemoveNetwork()
477477
// get all events between starting and removing for this container
478478
$promise = $this->client->events($start, $end, array('network' => array($network['Id'])));
479479
$ret = \React\Async\await($promise);
480+
assert(is_array($ret));
481+
482+
$actions = array(); // array_column($ret, 'Action'); // PHP 5.5+
483+
foreach ($ret as $one) {
484+
$actions[] = $one['Action'];
485+
}
480486

481-
// expects "create", "disconnect", "destroy" events ("connect" will be skipped because we don't start the container)
482-
$this->assertCount(3, $ret);
483-
$this->assertEquals('create', $ret[0]['Action']);
484-
$this->assertEquals('disconnect', $ret[1]['Action']);
485-
$this->assertEquals('destroy', $ret[2]['Action']);
487+
// expect 2 events as of ~2025, 3 in earlier versions
488+
if (count($actions) === 2) {
489+
// expects only "create" and "destroy" events (no "connect" / "disconnect" because we don't start the container)
490+
$this->assertEquals(array('create', 'destroy'), $actions);
491+
} else {
492+
// expects "create", "disconnect", "destroy" events ("connect" will be skipped because we don't start the container)
493+
$this->assertEquals(array('create', 'disconnect', 'destroy'), $actions);
494+
}
486495
}
487496

488497
/**

0 commit comments

Comments
 (0)