Add PHP 8.3 fixes for Codeception in tests env
[MAILPOET-6297]
This commit is contained in:
committed by
Rostislav Wolný
parent
483e4db123
commit
5e47337913
@@ -20,10 +20,12 @@
|
||||
},
|
||||
"scripts": {
|
||||
"post-install-cmd": [
|
||||
"php ./tasks/fix-php82-codeception.php"
|
||||
"php ./tasks/fix-php82-codeception.php",
|
||||
"php ./tasks/fix-php83-codeception.php"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"php ./tasks/fix-php82-codeception.php"
|
||||
"php ./tasks/fix-php82-codeception.php",
|
||||
"php ./tasks/fix-php83-codeception.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
68
tests_env/tasks/fix-php83-codeception.php
Normal file
68
tests_env/tasks/fix-php83-codeception.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
// throw exception if anything fails
|
||||
set_error_handler(function ($severity, $message, $file, $line) {
|
||||
throw new ErrorException($message, 0, $severity, $file, $line);
|
||||
});
|
||||
|
||||
// Fixes for PHP8.3 Compatibility when Generator classes use dynamic properties which are deprecated
|
||||
$codeceptionActionsFind = <<<'CODE'
|
||||
protected $name;
|
||||
protected $settings;
|
||||
protected $modules = [];
|
||||
protected $actions;
|
||||
protected $numMethods = 0;
|
||||
CODE;
|
||||
|
||||
$codeceptionActorFind = <<<'CODE'
|
||||
protected $settings;
|
||||
protected $modules;
|
||||
protected $actions;
|
||||
CODE;
|
||||
|
||||
$codeceptionActorReplacement = <<<'CODE'
|
||||
protected $settings;
|
||||
protected $di;
|
||||
protected $moduleContainer;
|
||||
protected $modules;
|
||||
protected $actions;
|
||||
CODE;
|
||||
|
||||
$codeceptionActionsReplacement = <<<'CODE'
|
||||
protected $name;
|
||||
protected $di;
|
||||
protected $moduleContainer;
|
||||
protected $settings;
|
||||
protected $modules = [];
|
||||
protected $actions;
|
||||
protected $numMethods = 0;
|
||||
CODE;
|
||||
|
||||
// Development packages
|
||||
$replacements = [
|
||||
[
|
||||
'file' => __DIR__ . '/../vendor/codeception/codeception/src/Codeception/Lib/Generator/Actions.php',
|
||||
'find' => [
|
||||
$codeceptionActionsFind
|
||||
],
|
||||
'replace' => [
|
||||
$codeceptionActionsReplacement,
|
||||
],
|
||||
],
|
||||
[
|
||||
'file' => __DIR__ . '/../vendor/codeception/codeception/src/Codeception/Lib/Generator/Actor.php',
|
||||
'find' => [
|
||||
$codeceptionActorFind
|
||||
],
|
||||
'replace' => [
|
||||
$codeceptionActorReplacement,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Apply replacements
|
||||
foreach ($replacements as $singleFile) {
|
||||
$data = file_get_contents($singleFile['file']);
|
||||
$data = str_replace($singleFile['find'], $singleFile['replace'], $data);
|
||||
file_put_contents($singleFile['file'], $data);
|
||||
}
|
Reference in New Issue
Block a user