From 030f0d526b3920f96742e6f0085f7359c9ecfda3 Mon Sep 17 00:00:00 2001 From: toimtoimtoim Date: Sun, 27 Nov 2016 11:08:42 +0200 Subject: [PATCH] Fix tests on Linux (Ubuntu 16.4/Php7) --- tests/ModbusMaster/MockServerTestCase.php | 5 +++++ tests/ModbusMaster/ModbusExceptionTest.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/ModbusMaster/MockServerTestCase.php b/tests/ModbusMaster/MockServerTestCase.php index b6e93fd..b22f309 100644 --- a/tests/ModbusMaster/MockServerTestCase.php +++ b/tests/ModbusMaster/MockServerTestCase.php @@ -23,6 +23,11 @@ abstract class MockServerTestCase extends TestCase $clientData[] = $output; }); + if ('WIN' !== strtoupper(substr(PHP_OS, 0, 3))) { + // wait to spin up. needed for linux. unnessecary on Windows 10. + // Ugly but even with 150ms sleep test run faster on Linux + usleep(150000); + } $closure($port); }); diff --git a/tests/ModbusMaster/ModbusExceptionTest.php b/tests/ModbusMaster/ModbusExceptionTest.php index f1b04fc..3d0db1f 100644 --- a/tests/ModbusMaster/ModbusExceptionTest.php +++ b/tests/ModbusMaster/ModbusExceptionTest.php @@ -21,7 +21,7 @@ class ModbusExceptionTest extends MockServerTestCase public function testPortClosedException() { $this->expectException(IOException::class); - $this->expectExceptionMessage('socket_connect() failed. Reason: ()No connection could be made because the target machine actively refused it.'); + $this->expectExceptionMessage('socket_connect() failed. Reason:'); $modbus = new ModbusMasterTcp('127.0.0.1'); $modbus->setSocketTimeout(0.2, 0.2);