From b104af78c32492345fd28b5179c1db9fa8291e23 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 5 Oct 2025 17:16:04 +0200 Subject: [PATCH 1/4] [ticket/17555] Only run unit tests on windows runners PHPBB-17555 --- .github/workflows/tests.yml | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dade39ed28..3b4a08a8f9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -480,42 +480,18 @@ jobs: include: - php: '7.4' db: "postgres" - type: 'unit' - php: '8.0' db: "postgres" - type: 'unit' - php: '8.1' db: "postgres" - type: 'unit' - php: '8.2' db: "postgres" - type: 'unit' - php: '8.3' db: "postgres" - type: 'unit' - php: '8.4' db: "postgres" - type: 'unit' - - php: '7.4' - db: "postgres" - type: 'functional' - - php: '8.0' - db: "postgres" - type: 'functional' - - php: '8.1' - db: "postgres" - type: 'functional' - - php: '8.2' - db: "postgres" - type: 'functional' - - php: '8.3' - db: "postgres" - type: 'functional' - - php: '8.4' - db: "postgres" - type: 'functional' - name: Windows - PHP ${{ matrix.php }} - ${{ matrix.db }} - ${{ matrix.type }} + name: Windows - PHP ${{ matrix.php }} - ${{ matrix.db }} steps: - name: Prepare git for Windows @@ -643,16 +619,5 @@ jobs: Set-MpPreference -ExclusionPath "${env:PGDATA}" # Exclude PGDATA directory from Windows Defender - name: Run unit tests - if: ${{ matrix.type == 'unit' }} run: | phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --exclude-group functional - - name: Run unit tests - if: ${{ matrix.type == 'functional' }} - timeout-minutes: 45 - env: - PHPBB_FUNCTIONAL_TIMEOUT: 30 - SYMFONY_DEPRECATIONS_HELPER: disabled - PHPBB_TEST_REDIS_HOST: '' - PHPBB_TEST_MEMCACHED_HOST: '' - run: | - phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --group functional From 7e22d7ad24cf78b1629b3f8c32f3ae066b990fd2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 5 Oct 2025 20:53:21 +0200 Subject: [PATCH 2/4] [ticket/17555] Reduce callbacks to external URLs in unit tests PHPBB-17555 --- tests/avatar/manager_test.php | 10 +++++++--- tests/console/update/check_test.php | 27 ++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index dbcf6dae7e..669c551511 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -57,7 +57,11 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case new \phpbb\mimetype\content_guesser, ); $guesser = new \phpbb\mimetype\guesser($guessers); - $imagesize = new \FastImageSize\FastImageSize(); + $imagesize = $this->getMockBuilder('\FastImageSize\FastImageSize') + ->setMethods(['getImageSize']) + ->getMock(); + $imagesize->method('getImageSize') + ->willReturn(['width' => 80, 'height' => 80, 'mime' => 'image/jpeg']); $dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_dispatcher = $dispatcher; @@ -405,9 +409,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case { return array( array('127.0.0.1:91?foo.jpg', 80, 80, array('AVATAR_URL_INVALID')), - array(gethostbyname('secure.gravatar.com') . '/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), + array('127.0.0.1/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), array('secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80), - array(gethostbyname('secure.gravatar.com') . ':120/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), + array('127.0.0.1:120/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), array('secure.gravatar.com:80/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), array('secure.gravatar.com:80?55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), array('secure.gravatar.com?55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), // should be a 404 diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php index 2578eb21cc..5768808464 100644 --- a/tests/console/update/check_test.php +++ b/tests/console/update/check_test.php @@ -94,7 +94,32 @@ class phpbb_console_command_check_test extends phpbb_test_case ->getMock(); $config = new \phpbb\config\config(array('version' => $current_version)); - $this->version_helper = new \phpbb\version_helper($cache, $config, new \phpbb\file_downloader()); + $this->version_helper = $this->getMockBuilder('\phpbb\version_helper') + ->setConstructorArgs([$cache, $config, new \phpbb\file_downloader()]) + ->setMethods(['get_latest_version', 'get_suggested_updates']) + ->getMock(); + $this->version_helper->method('get_suggested_updates') + ->willReturnCallback(function($force_update = false, $force_cache = false) use ($config) + { + if ($config['version'] === '100000') + { + return []; + } + else if ($config['version'] === '0') + { + return [ + [ + 'version' => '100000', + 'stability' => 'stable', + 'download_url' => 'https://www.phpbb.com/downloads/', + ], + ]; + } + else + { + throw new \phpbb\exception\runtime_exception('VERSIONCHECK_FAIL'); + } + }); $container = new phpbb_mock_container_builder; $container->set('version_helper', $this->version_helper); From b3b5e328f91181363cfe8259ace7ec628caa19d4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 5 Oct 2025 21:52:57 +0200 Subject: [PATCH 3/4] [ticket/17555] Properly mock version helper return PHPBB-17555 --- tests/console/update/check_test.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php index 5768808464..a00b49f0d1 100644 --- a/tests/console/update/check_test.php +++ b/tests/console/update/check_test.php @@ -109,9 +109,10 @@ class phpbb_console_command_check_test extends phpbb_test_case { return [ [ - 'version' => '100000', - 'stability' => 'stable', - 'download_url' => 'https://www.phpbb.com/downloads/', + 'current' => '100000', + 'announcement' => 'https://www.phpbb.com/downloads/', + 'eol' => null, + 'security' => false, ], ]; } From 2a65b0ee2eda609d65e5725313b9e467e6de88fd Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 6 Oct 2025 17:06:30 +0200 Subject: [PATCH 4/4] [ticket/17555] Use retries for windows tests PHPBB-17555 --- .github/workflows/tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3b4a08a8f9..b6e7f1fe9f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -619,5 +619,8 @@ jobs: Set-MpPreference -ExclusionPath "${env:PGDATA}" # Exclude PGDATA directory from Windows Defender - name: Run unit tests - run: | - phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --exclude-group functional + uses: nick-fields/retry@v3 + with: + timeout_minutes: 15 + max_attempts: 3 + command: phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --exclude-group functional