diff --git a/.github/config-test.inc.php b/.github/config-test.inc.php index 65c6f743b72..674ea5f0e8f 100644 --- a/.github/config-test.inc.php +++ b/.github/config-test.inc.php @@ -3,7 +3,7 @@ $config = []; // Database configuration -$config['db_dsnw'] = 'sqlite:////tmp/sqlite.db?mode=0646'; +$config['db_dsnw'] = 'sqlite:///' . sys_get_temp_dir() . '/roundcube-test-sqlite.db?mode=0646'; // Test user credentials $config['tests_username'] = 'test'; diff --git a/.github/workflows/browser_tests.yml b/.github/workflows/browser_tests.yml index 69c4a075307..9503b711d43 100644 --- a/.github/workflows/browser_tests.yml +++ b/.github/workflows/browser_tests.yml @@ -1,4 +1,4 @@ -name: browser_tests +name: E2E on: push: @@ -14,8 +14,10 @@ jobs: strategy: fail-fast: true + matrix: + php: ["8.1"] - name: Browser Tests + name: Linux / PHP ${{ matrix.php }} steps: - name: Checkout code @@ -24,7 +26,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: ${{ matrix.php }} extensions: dom, curl, fileinfo, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, ldap, intl, pspell tools: composer:v2 coverage: none diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cb3884a1919..c5e02ef585e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: tests +name: Unit on: push: @@ -8,7 +8,7 @@ permissions: contents: read jobs: - linux_tests: + tests_linux: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" @@ -17,7 +17,7 @@ jobs: matrix: php: ["7.3", "7.4", "8.0", "8.1", "8.2", "8.3"] - name: PHP ${{ matrix.php }}/Linux + name: Linux / PHP ${{ matrix.php }} steps: - name: Checkout code @@ -43,10 +43,6 @@ jobs: cp composer.json-dist composer.json composer require "kolab/net_ldap3:~1.1.1" --no-update - - name: Fix PHPUnit for PHP 8.2 - run: composer config platform.php 8.1 - if: matrix.php >= 8.2 - - name: Install dependencies run: composer install --prefer-dist --no-interaction --no-progress @@ -62,3 +58,41 @@ jobs: with: name: Logs path: logs/errors.log + + tests_windows: + runs-on: windows-latest + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + + strategy: + fail-fast: true + matrix: + php: ["7.3", "7.4", "8.0", "8.1", "8.2", "8.3"] + + name: Windows / PHP ${{ matrix.php }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, fileinfo, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, gd, ldap, intl + tools: composer:v2 + coverage: none + ini-values: error_reporting=E_ALL + + - name: Setup composer + run: | + cp composer.json-dist composer.json + composer require "kolab/net_ldap3:~1.1.1" --no-update + + - name: Install dependencies + run: composer install --prefer-dist --no-interaction --no-progress + + - name: Roundcube configuration + run: cp .github/config-test.inc.php config/config-test.inc.php + + - name: Execute tests + run: vendor/bin/phpunit -c tests/phpunit.xml diff --git a/tests/.gitattributes b/tests/.gitattributes new file mode 100644 index 00000000000..0434e910539 --- /dev/null +++ b/tests/.gitattributes @@ -0,0 +1,5 @@ +# prevent git EOL conversion +/src/sql/*.sql -text +/src/format-flowed.txt -text +/src/format-flowed-unfolded.txt -text +*.php eol=lf diff --git a/tests/ActionTestCase.php b/tests/ActionTestCase.php index 5122d6bea78..2133b8b9607 100644 --- a/tests/ActionTestCase.php +++ b/tests/ActionTestCase.php @@ -113,8 +113,9 @@ public static function initDB($file = null) } else if ($dsn['phptype'] == 'sqlite') { $db->closeConnection(); + // delete database file - system(sprintf('rm -f %s', escapeshellarg($dsn['database']))); + unlink($dsn['database']); // load sample test data self::loadSQLScript($db, 'init'); diff --git a/tests/Framework/Rcube.php b/tests/Framework/Rcube.php index a61c6da9956..c15bea049f8 100644 --- a/tests/Framework/Rcube.php +++ b/tests/Framework/Rcube.php @@ -69,6 +69,13 @@ function test_encrypt_and_decrypt() */ function test_exec() { + if (PHP_OS_FAMILY === 'Windows') { + $this->assertSame('', rcube::exec('where.exe unknown-command-123 2> nul')); + $this->assertSame('12', rcube::exec('set /a 10 + {v}', ['v' => '2'])); + + return; + } + $this->assertSame('', rcube::exec('which unknown-command-123')); $this->assertSame("2038\n", rcube::exec('date --date={date} +%Y', ['date' => '@2147483647'])); // TODO: More cases diff --git a/tests/Framework/TnefDecoder.php b/tests/Framework/TnefDecoder.php index 91f16779058..16b5937ea33 100644 --- a/tests/Framework/TnefDecoder.php +++ b/tests/Framework/TnefDecoder.php @@ -57,7 +57,7 @@ function test_rtf2text() $body = file_get_contents(TESTS_DIR . 'src/sample.rtf'); $text = rcube_tnef_decoder::rtf2text($body); - $this->assertMatchesRegularExpression('/^[a-zA-Z1-6!&<,> \n\.]+$/', $text); + $this->assertMatchesRegularExpression('/^[a-zA-Z1-6!&<,> \n\r\.]+$/', $text); $this->assertTrue(strpos($text, 'Alex Skolnick') !== false); $this->assertTrue(strpos($text, 'Heading 1') !== false); $this->assertTrue(strpos($text, 'Heading 2') !== false); diff --git a/tests/Rcmail/Install.php b/tests/Rcmail/Install.php index 691415104bc..8735c4ad975 100644 --- a/tests/Rcmail/Install.php +++ b/tests/Rcmail/Install.php @@ -74,6 +74,10 @@ function test_check_mime_detection() /** * Test check_mime_extensions() method + * + * Windows feature request: https://github.com/php/php-src/issues/12918 + * + * @requires OSFAMILY Linux */ function test_check_mime_extensions() {