mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
PHP 8.4 support and dynamic loading of plugin tests (WIP)
This commit is contained in:
@@ -17,6 +17,7 @@ coverage:
|
||||
- '%app_path%/e107_plugins/**/*.php'
|
||||
- '%app_path%/e107_themes/**/*.php'
|
||||
- '%app_path%/e107_web/**/*.php'
|
||||
- '%app_path%/e107_plugins/linkwords/tests'
|
||||
exclude:
|
||||
- './**'
|
||||
- '%app_path%/e107_handlers/vendor/**/*.php'
|
||||
@@ -28,9 +29,11 @@ extensions:
|
||||
- Codeception\Extension\RunFailed
|
||||
modules:
|
||||
enabled:
|
||||
- Asserts
|
||||
- \Helper\DelayedDb:
|
||||
dsn: 'mysql:host=%db.host%;port=%db.port%;dbname=%db.dbname%'
|
||||
user: '%db.user%'
|
||||
password: '%db.password%'
|
||||
populate: '%db.populate%'
|
||||
dump: '%db.dump_path%'
|
||||
|
||||
|
@@ -2,11 +2,28 @@
|
||||
"name": "e107inc/e107-test",
|
||||
"description": "Test harness for e107",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"require": {
|
||||
"php": "^8.1 || ^8.2 || ^8.3 || ^8.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"twig/twig": ">=1.28",
|
||||
"codeception/codeception": "^4.2",
|
||||
"codeception/module-asserts": "^1.1",
|
||||
"codeception/module-db": "^1.0",
|
||||
"codeception/module-phpbrowser": "^1.0"
|
||||
}
|
||||
"twig/twig": "^3.12",
|
||||
"codeception/codeception": "^5.2.1",
|
||||
"codeception/module-asserts": "^3.0",
|
||||
"codeception/module-db": "^3.1",
|
||||
"codeception/module-phpbrowser": "^3.0",
|
||||
"codeception/module-filesystem": "^3.0",
|
||||
"codeception/module-webdriver": "^4.0"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Helper\\": "tests/_support/Helper/",
|
||||
"Tests\\Unit\\": "tests/unit/",
|
||||
"Tests\\": "../e107_plugins/"
|
||||
}
|
||||
}
|
||||
}
|
2038
e107_tests/composer.lock
generated
2038
e107_tests/composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,57 @@
|
||||
<?php
|
||||
Codeception\Util\Autoload::addNamespace('', codecept_root_dir().'/tests/unit');
|
||||
|
||||
define('PARAMS_GENERATOR', realpath(codecept_root_dir()."/lib/config.php"));
|
||||
use Codeception\Util\Autoload;
|
||||
use Codeception\Configuration;
|
||||
|
||||
Autoload::addNamespace('', codecept_root_dir() . '/tests/unit');
|
||||
|
||||
define('PARAMS_GENERATOR', realpath(codecept_root_dir() . "/lib/config.php"));
|
||||
$params = include(PARAMS_GENERATOR);
|
||||
|
||||
$app_path = $params['app_path'] ?: codecept_root_dir()."/e107";
|
||||
|
||||
// Relative path
|
||||
if (substr($app_path, 0, 1) !== '/')
|
||||
$app_path = $params['app_path'] ?: codecept_root_dir() . "/e107";
|
||||
if(substr($app_path, 0, 1) !== '/')
|
||||
{
|
||||
$app_path = codecept_root_dir() . "/{$app_path}";
|
||||
|
||||
}
|
||||
define('APP_PATH', realpath($app_path));
|
||||
define('PARAMS_SERIALIZED', serialize($params));
|
||||
// define('e_PLUGIN', APP_PATH . '/e107_plugins/');
|
||||
|
||||
// Provide a way to register callbacks that execute before Codeception's
|
||||
include(codecept_root_dir()."/lib/PriorityCallbacks.php");
|
||||
$pluginsDir = realpath(codecept_root_dir() . '/../e107_plugins/');
|
||||
$pluginTestDirs = [];
|
||||
|
||||
$logFile = codecept_output_dir() . '/bootstrap.log';
|
||||
file_put_contents($logFile, '');
|
||||
file_put_contents($logFile, "Time: " . date(DATE_ATOM) . "\n", FILE_APPEND);
|
||||
file_put_contents($logFile, "Root Dir: " . codecept_root_dir() . "\n", FILE_APPEND);
|
||||
file_put_contents($logFile, "Plugins Dir: $pluginsDir\n", FILE_APPEND);
|
||||
|
||||
if($pluginsDir && is_dir($pluginsDir))
|
||||
{
|
||||
$dirs = glob($pluginsDir . '/*/tests', GLOB_ONLYDIR);
|
||||
file_put_contents($logFile, "Glob Pattern: $pluginsDir/*/tests\n", FILE_APPEND);
|
||||
file_put_contents($logFile, "Found Dirs: " . (empty($dirs) ? 'None' : implode(', ', $dirs)) . "\n", FILE_APPEND);
|
||||
foreach($dirs as $testDir)
|
||||
{
|
||||
$pluginName = basename(dirname($testDir));
|
||||
$relativePath = '../e107_plugins/' . $pluginName . '/tests';
|
||||
$pluginTestDirs[] = $relativePath; // Just paths, no array
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file_put_contents($logFile, "Plugins Dir not found or not a directory\n", FILE_APPEND);
|
||||
}
|
||||
file_put_contents($logFile, "Included: " . json_encode($pluginTestDirs, JSON_PRETTY_PRINT) . "\n", FILE_APPEND);
|
||||
|
||||
if(!empty($pluginTestDirs))
|
||||
{
|
||||
Configuration::append(['include' => $pluginTestDirs]);
|
||||
codecept_debug("Dynamic includes added: " . json_encode($pluginTestDirs));
|
||||
}
|
||||
else
|
||||
{
|
||||
codecept_debug("No plugin test directories found");
|
||||
}
|
||||
|
||||
include(codecept_root_dir() . "/lib/PriorityCallbacks.php");
|
@@ -57,8 +57,8 @@ abstract class Base extends \Codeception\Module
|
||||
}
|
||||
}
|
||||
|
||||
public function _before(\Codeception\TestInterface $test = null)
|
||||
public function _before(?\Codeception\TestInterface $test = null)
|
||||
{
|
||||
$this->_callbackDeployerStarted();
|
||||
$this->_callbackDeployerStarted();
|
||||
}
|
||||
}
|
||||
|
@@ -1,54 +1,44 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class DelayedDb extends \Codeception\Module\Db
|
||||
{
|
||||
protected $requiredFields = [];
|
||||
protected array $requiredFields = ['dsn', 'user', 'password']; // Enforce required config
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
// Noop
|
||||
}
|
||||
public function _initialize(): void
|
||||
{
|
||||
// Call parent directly instead of deferring
|
||||
parent::_initialize();
|
||||
codecept_debug("DelayedDb initialized with DSN: " . $this->config['dsn']);
|
||||
}
|
||||
|
||||
public function _delayedInitialize()
|
||||
{
|
||||
return parent::_initialize();
|
||||
}
|
||||
// Keep this for manual triggering if needed
|
||||
public function _delayedInitialize()
|
||||
{
|
||||
return parent::_initialize();
|
||||
}
|
||||
|
||||
public function _getDbHostname()
|
||||
{
|
||||
$matches = [];
|
||||
$matched = preg_match('~host=([^;]+)~s', $this->config['dsn'], $matches);
|
||||
if (!$matched)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public function _getDbHostname()
|
||||
{
|
||||
$matches = [];
|
||||
$matched = preg_match('~host=([^;]+)~s', $this->config['dsn'], $matches);
|
||||
return $matched ? $matches[1] : false;
|
||||
}
|
||||
|
||||
return $matches[1];
|
||||
}
|
||||
public function _getDbName()
|
||||
{
|
||||
$matches = [];
|
||||
$matched = preg_match('~dbname=([^;]+)~s', $this->config['dsn'], $matches);
|
||||
return $matched ? $matches[1] : false;
|
||||
}
|
||||
|
||||
public function _getDbName()
|
||||
{
|
||||
$matches = [];
|
||||
$matched = preg_match('~dbname=([^;]+)~s', $this->config['dsn'], $matches);
|
||||
if (!$matched)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public function _getDbUsername()
|
||||
{
|
||||
return $this->config['user'];
|
||||
}
|
||||
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
public function _getDbUsername()
|
||||
{
|
||||
return $this->config['user'];
|
||||
}
|
||||
|
||||
public function _getDbPassword()
|
||||
{
|
||||
return $this->config['password'];
|
||||
}
|
||||
}
|
||||
public function _getDbPassword()
|
||||
{
|
||||
return $this->config['password'];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user