Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8cdc90

Browse files
committed
improve ftp support detection in testing suite
1 parent ad49689 commit e8cdc90

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/Symfony/Component/Finder/Tests/Iterator/RecursiveDirectoryIteratorTest.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@
1515

1616
class RecursiveDirectoryIteratorTest extends IteratorTestCase
1717
{
18+
protected function skipIfNoFtpSupport(): void
19+
{
20+
if (!in_array('ftp', stream_get_wrappers(), true) || !ini_get('allow_url_fopen')) {
21+
$this->markTestSkipped('Unsupported stream "ftp".');
22+
}
23+
}
24+
1825
/**
1926
* @group network
2027
*/
2128
public function testRewindOnFtp()
2229
{
23-
try {
24-
$i = new RecursiveDirectoryIterator('ftp://speedtest:[email protected]/', \RecursiveDirectoryIterator::SKIP_DOTS);
25-
} catch (\UnexpectedValueException $e) {
26-
$this->markTestSkipped('Unsupported stream "ftp".');
27-
}
30+
$this->skipIfNoFtpSupport();
31+
32+
$i = new RecursiveDirectoryIterator('ftp://speedtest:[email protected]/', \RecursiveDirectoryIterator::SKIP_DOTS);
2833

2934
$i->rewind();
3035

@@ -36,11 +41,9 @@ public function testRewindOnFtp()
3641
*/
3742
public function testSeekOnFtp()
3843
{
39-
try {
40-
$i = new RecursiveDirectoryIterator('ftp://speedtest:[email protected]/', \RecursiveDirectoryIterator::SKIP_DOTS);
41-
} catch (\UnexpectedValueException $e) {
42-
$this->markTestSkipped('Unsupported stream "ftp".');
43-
}
44+
$this->skipIfNoFtpSupport();
45+
46+
$i = new RecursiveDirectoryIterator('ftp://speedtest:[email protected]/', \RecursiveDirectoryIterator::SKIP_DOTS);
4447

4548
$contains = [
4649
'ftp://speedtest:[email protected]'.\DIRECTORY_SEPARATOR.'test100Mb.db',

0 commit comments

Comments
 (0)