diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a0d36cbcd..075327d89 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,10 +30,10 @@ jobs: run: npm run test phpUnitTests: strategy: - max-parallel: 6 + max-parallel: 8 matrix: operatingSystem: [ubuntu-latest, windows-latest] - phpVersion: ['7.2', '7.3', '7.4'] + phpVersion: ['7.2', '7.3', '7.4', '8.0'] fail-fast: false runs-on: ${{ matrix.operatingSystem }} name: ${{ matrix.operatingSystem }} / PHP ${{ matrix.phpVersion }} diff --git a/composer.json b/composer.json index e2a7c703b..61f8d3d19 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ } ], "require": { - "php": ">=7.2", + "php": ">=7.2.9", "october/rain": "1.1.*", "october/system": "1.1.*", "october/backend": "1.1.*", @@ -45,8 +45,7 @@ "fzaninotto/faker": "~1.9", "squizlabs/php_codesniffer": "3.*", "php-parallel-lint/php-parallel-lint": "^1.0", - "meyfa/phpunit-assert-gd": "^2.0.0", - "dms/phpunit-arraysubset-asserts": "^0.1.0" + "dms/phpunit-arraysubset-asserts": "^0.1.0|^0.2.1" }, "autoload-dev": { "classmap": [ @@ -76,10 +75,7 @@ ] }, "config": { - "preferred-install": "dist", - "platform": { - "php": "7.2.5" - } + "preferred-install": "dist" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/modules/backend/classes/BackendController.php b/modules/backend/classes/BackendController.php index 481df7ae1..9e708db37 100644 --- a/modules/backend/classes/BackendController.php +++ b/modules/backend/classes/BackendController.php @@ -111,6 +111,14 @@ class BackendController extends ControllerBase self::extendableExtendCallback($callback); } + /** + * @inheritDoc + */ + public function callAction($method, $parameters) + { + return parent::callAction($method, array_values($parameters)); + } + /** * Pass unhandled URLs to the CMS Controller, if it exists * @@ -210,7 +218,7 @@ class BackendController extends ControllerBase * Look for a Plugin controller */ if (count($params) >= 2) { - list($author, $plugin) = $params; + [$author, $plugin] = $params; $pluginCode = ucfirst($author) . '.' . ucfirst($plugin); if (PluginManager::instance()->isDisabled($pluginCode)) { diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index c4e64b6ba..a0790ed2e 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -617,7 +617,7 @@ class Controller extends ControllerBase $pageHandler = $this->action . '_' . $handler; if ($this->methodExists($pageHandler)) { - $result = call_user_func_array([$this, $pageHandler], $this->params); + $result = call_user_func_array([$this, $pageHandler], array_values($this->params)); return $result ?: true; } @@ -625,7 +625,7 @@ class Controller extends ControllerBase * Process page global handler (onSomething) */ if ($this->methodExists($handler)) { - $result = call_user_func_array([$this, $handler], $this->params); + $result = call_user_func_array([$this, $handler], array_values($this->params)); return $result ?: true; } @@ -662,7 +662,7 @@ class Controller extends ControllerBase { $this->addViewPath($widget->getViewPaths()); - $result = call_user_func_array([$widget, $handler], $this->params); + $result = call_user_func_array([$widget, $handler], array_values($this->params)); $this->vars = $widget->vars + $this->vars; diff --git a/modules/system/classes/CombineAssets.php b/modules/system/classes/CombineAssets.php index 17ec7c2bd..49b05268b 100644 --- a/modules/system/classes/CombineAssets.php +++ b/modules/system/classes/CombineAssets.php @@ -464,7 +464,7 @@ class CombineAssets */ protected function setHashOnCombinerFilters($hash) { - $allFilters = call_user_func_array('array_merge', $this->getFilters()); + $allFilters = array_merge(...array_values($this->getFilters())); foreach ($allFilters as $filter) { if (method_exists($filter, 'setHash')) { diff --git a/tests/TestCase.php b/tests/TestCase.php index 8d569525b..a4d5b1569 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,4 +1,7 @@ setAccessible(true); return $property->setValue($object, $value); } + + /** + * Stub for `assertFileNotExists` to allow compatibility with both PHPUnit 8 and 9. + * + * @param string $filename + * @param string $message + * @return void + */ + public static function assertFileNotExists(string $filename, string $message = ''): void + { + if (method_exists(Assert::class, 'assertFileDoesNotExist')) { + Assert::assertFileDoesNotExist($filename, $message); + return; + } + + Assert::assertFileNotExists($filename, $message); + } + + /** + * Stub for `assertRegExp` to allow compatibility with both PHPUnit 8 and 9. + * + * @param string $filename + * @param string $message + * @return void + */ + public static function assertRegExp(string $pattern, string $string, string $message = ''): void + { + if (method_exists(Assert::class, 'assertMatchesRegularExpression')) { + Assert::assertMatchesRegularExpression($pattern, $string, $message); + return; + } + + Assert::assertRegExp($pattern, $string, $message); + } } diff --git a/tests/fixtures/plugins/testvendor/goto/Plugin.php b/tests/fixtures/plugins/testvendor/goto/Plugin.php index 3d1b816a6..b98845f61 100644 --- a/tests/fixtures/plugins/testvendor/goto/Plugin.php +++ b/tests/fixtures/plugins/testvendor/goto/Plugin.php @@ -1,4 +1,4 @@ -prepare($request); $this->assertTrue($response->headers->has('Content-Type'), "Response is missing the Content-Type header!"); - $this->assertTrue($response->headers->contains('Content-Type', 'text/plain'), "Content-Type is not \"text/plain\"!"); + $this->assertTrue( + $response->headers->contains('Content-Type', 'application/csv') + || $response->headers->contains('Content-Type', 'text/plain'), + "Content-Type is not as expected!" + ); ob_start(); $response->send();