File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,19 @@ protected function setUp(): void
2828 */
2929 public function testDownloadPackage (): void
3030 {
31- $ actual = $ this ->upgrade ->downloadPackage ('3.1.15 ' );
32- $ this ->assertIsString ($ actual );
31+ if (!$ this ->isNetworkAvailable ()) {
32+ $ this ->markTestSkipped ('Network not available ' );
33+ }
34+
35+ try {
36+ $ actual = $ this ->upgrade ->downloadPackage ('3.1.15 ' );
37+ $ this ->assertIsString ($ actual );
38+ } catch (Exception $ e ) {
39+ if (str_contains ($ e ->getMessage (), 'timeout ' ) || str_contains ($ e ->getMessage (), 'connection ' )) {
40+ $ this ->markTestSkipped ('Network timeout: ' . $ e ->getMessage ());
41+ }
42+ throw $ e ;
43+ }
3344
3445 $ this ->expectException ('phpMyFAQ\Core\Exception ' );
3546 $ this ->upgrade ->downloadPackage ('1.2.3 ' );
@@ -87,4 +98,13 @@ public function testGetPathForNonNightly(): void
8798
8899 $ this ->assertEquals ('' , $ this ->upgrade ->getPath ());
89100 }
101+
102+ private function isNetworkAvailable (): bool
103+ {
104+ $ context = stream_context_create ([
105+ 'http ' => ['timeout ' => 5 ]
106+ ]);
107+
108+ return @file_get_contents ('https://download.phpmyfaq.de ' , false , $ context ) !== false ;
109+ }
90110}
You can’t perform that action at this time.
0 commit comments