Add codeception packages to tests_env
[MAILPOET-6244]
This commit is contained in:
committed by
Jan Lysý
parent
e74e1ef2a2
commit
8c2fdc173c
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ mailpoet-premium
|
||||
tsconfig.tsbuildinfo
|
||||
/wordpress
|
||||
packages/php/*/vendor
|
||||
tests_env/vendor
|
||||
|
29
tests_env/composer.json
Normal file
29
tests_env/composer.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"minimum-stability": "dev",
|
||||
"require-dev": {
|
||||
"codeception/codeception": "4.2.2",
|
||||
"codeception/module-asserts": "^1.3",
|
||||
"codeception/module-cli": "^1.0",
|
||||
"codeception/module-db": "^1.1",
|
||||
"codeception/module-webdriver": "^1.4",
|
||||
"codeception/verify": "^2.1",
|
||||
"hoa/console": "3.17.05.02",
|
||||
"lucatume/wp-browser": "3.2.1",
|
||||
"phpunit/phpunit": "9.6.19",
|
||||
"vlucas/phpdotenv": "v5.6.0"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.4"
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"scripts": {
|
||||
"post-install-cmd": [
|
||||
"php ./tasks/fix-php82-codeception.php"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"php ./tasks/fix-php82-codeception.php"
|
||||
]
|
||||
}
|
||||
}
|
7029
tests_env/composer.lock
generated
Normal file
7029
tests_env/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
59
tests_env/tasks/fix-php82-codeception.php
Normal file
59
tests_env/tasks/fix-php82-codeception.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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.2 Compatibility
|
||||
|
||||
$codeceptionStepReplacement = <<<'CODE'
|
||||
$parentClass = get_parent_class($argument);
|
||||
$reflection = new \ReflectionClass($argument);
|
||||
|
||||
if ($parentClass !== false) {
|
||||
return $this->formatClassName($parentClass);
|
||||
}
|
||||
|
||||
$interfaces = $reflection->getInterfaceNames();
|
||||
foreach ($interfaces as $interface) {
|
||||
if (str_starts_with($interface, 'PHPUnit\\')) {
|
||||
continue;
|
||||
}
|
||||
if (str_starts_with($interface, 'Codeception\\')) {
|
||||
continue;
|
||||
}
|
||||
return $this->formatClassName($interface);
|
||||
}
|
||||
CODE;
|
||||
|
||||
// Development packages
|
||||
$replacements = [
|
||||
[
|
||||
'file' => __DIR__ . '/../vendor/codeception/stub/src/Stub.php',
|
||||
'find' => [
|
||||
' $mock->__mocked = $reflection->getName();',
|
||||
],
|
||||
'replace' => [
|
||||
' //$mock->__mocked = $reflection->getName();',
|
||||
],
|
||||
],
|
||||
[
|
||||
'file' => __DIR__ . '/../vendor/codeception/codeception/src/Codeception/Step.php',
|
||||
'find' => [
|
||||
'} elseif ($argument instanceof MockObject && isset($argument->__mocked)) {',
|
||||
'return $this->formatClassName($argument->__mocked);',
|
||||
],
|
||||
'replace' => [
|
||||
'} elseif ($argument instanceof MockObject) {',
|
||||
$codeceptionStepReplacement,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// 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