Skip to content

Commit ec5841d

Browse files
committed
Remotes
1 parent f65e6d3 commit ec5841d

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

tests/suites/StreamTest.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Phrity\Net\Test;
1111

12+
use ErrorException;
1213
use InvalidArgumentException;
1314
use PHPUnit\Framework\TestCase;
1415
use Phrity\Net\{
@@ -349,10 +350,11 @@ public function testDirectoryStream(): void
349350

350351
public function testRemoteStream(): void
351352
{
352-
$remote = fopen('https://phrity.sirn.se/', 'r');
353-
if (!$remote) {
354-
$this->markTestSkipped('Could not reach online research.');
355-
}
353+
$remote = (new ErrorHandler())->with(function () {
354+
return fopen('https://phrity.sirn.se/', 'r');
355+
}, function (ErrorException $exception) {
356+
$this->markTestSkipped('Could not reach online resource.');
357+
});
356358
$stream = new Stream($remote);
357359
$this->assertEquals('http', $stream->getMetadata('wrapper_type'));
358360
$this->assertEquals('tcp_socket/ssl', $stream->getMetadata('stream_type'));
@@ -377,10 +379,11 @@ public function testRemoteStream(): void
377379

378380
public function testContext(): void
379381
{
380-
$remote = fopen('https://phrity.sirn.se/', 'r');
381-
if (!$remote) {
382-
$this->markTestSkipped('Could not reach online research.');
383-
}
382+
$remote = (new ErrorHandler())->with(function () {
383+
return fopen('https://phrity.sirn.se/', 'r');
384+
}, function (ErrorException $exception) {
385+
$this->markTestSkipped('Could not reach online resource.');
386+
});
384387
$stream = new Stream($remote);
385388
$context = $stream->getContext();
386389
$this->assertInstanceOf(Context::class, $context);
@@ -390,10 +393,11 @@ public function testContext(): void
390393

391394
public function testSeekOnRemoteError(): void
392395
{
393-
$remote = fopen('https://phrity.sirn.se/', 'r');
394-
if (!$remote) {
395-
$this->markTestSkipped('Could not reach online research.');
396-
}
396+
$remote = (new ErrorHandler())->with(function () {
397+
return fopen('https://phrity.sirn.se/', 'r');
398+
}, function (ErrorException $exception) {
399+
$this->markTestSkipped('Could not reach online resource.');
400+
});
397401
$stream = new Stream($remote);
398402
$this->expectException(StreamException::class);
399403
$this->expectExceptionCode(StreamException::NOT_SEEKABLE);

0 commit comments

Comments
 (0)