From b6715ad6c694439b41cd7e564af0080453ef7357 Mon Sep 17 00:00:00 2001 From: Philipp Fehre Date: Fri, 30 Dec 2022 14:14:03 +0100 Subject: [PATCH] Skip sslip.io tests if DNS is not configured In case sslip.io DNS is not configured correctly on the running host the tests will fail, skip instead in this case as the failure would not be related to a failing code but dependend on the running hosts DNS configuration. --- tests/Adapter/Http/FileGetContentsTest.php | 8 +++++++- tests/Adapter/Http/SymfonyHttpClientTest.php | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/Adapter/Http/FileGetContentsTest.php b/tests/Adapter/Http/FileGetContentsTest.php index b920c0f..0d93314 100644 --- a/tests/Adapter/Http/FileGetContentsTest.php +++ b/tests/Adapter/Http/FileGetContentsTest.php @@ -31,7 +31,13 @@ public function testFetch() public function testFetchUnderscores() { - $client = new SymfonyHttpClient('http://_.127.0.0.1.sslip.io:9999'); + $sslipHostname = '_.127.0.0.1.sslip.io'; + if (!gethostbynamel($sslipHostname)) { + $this->markTestSkipped( + "{$sslipHostname} does not resolve, sslip DNS is not configured correctly, skipping." + ); + } + $client = new SymfonyHttpClient("http://{$sslipHostname}:9999"); $this->assertStringStartsWith('# CacheTool', $client->fetch('README.md')); } diff --git a/tests/Adapter/Http/SymfonyHttpClientTest.php b/tests/Adapter/Http/SymfonyHttpClientTest.php index ec2da62..a557ad3 100644 --- a/tests/Adapter/Http/SymfonyHttpClientTest.php +++ b/tests/Adapter/Http/SymfonyHttpClientTest.php @@ -31,7 +31,13 @@ public function testFetch() public function testFetchUnderscores() { - $client = new SymfonyHttpClient('http://_.127.0.0.1.sslip.io:9999'); + $sslipHostname = '_.127.0.0.1.sslip.io'; + if (!gethostbynamel($sslipHostname)) { + $this->markTestSkipped( + "{$sslipHostname} does not resolve, sslip DNS is not configured correctly, skipping." + ); + } + $client = new SymfonyHttpClient("http://{$sslipHostname}:9999"); $this->assertStringStartsWith('# CacheTool', $client->fetch('README.md')); }