mirror of
https://github.com/e107inc/e107.git
synced 2025-08-07 07:06:30 +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_plugins/**/*.php'
|
||||||
- '%app_path%/e107_themes/**/*.php'
|
- '%app_path%/e107_themes/**/*.php'
|
||||||
- '%app_path%/e107_web/**/*.php'
|
- '%app_path%/e107_web/**/*.php'
|
||||||
|
- '%app_path%/e107_plugins/linkwords/tests'
|
||||||
exclude:
|
exclude:
|
||||||
- './**'
|
- './**'
|
||||||
- '%app_path%/e107_handlers/vendor/**/*.php'
|
- '%app_path%/e107_handlers/vendor/**/*.php'
|
||||||
@@ -28,9 +29,11 @@ extensions:
|
|||||||
- Codeception\Extension\RunFailed
|
- Codeception\Extension\RunFailed
|
||||||
modules:
|
modules:
|
||||||
enabled:
|
enabled:
|
||||||
|
- Asserts
|
||||||
- \Helper\DelayedDb:
|
- \Helper\DelayedDb:
|
||||||
dsn: 'mysql:host=%db.host%;port=%db.port%;dbname=%db.dbname%'
|
dsn: 'mysql:host=%db.host%;port=%db.port%;dbname=%db.dbname%'
|
||||||
user: '%db.user%'
|
user: '%db.user%'
|
||||||
password: '%db.password%'
|
password: '%db.password%'
|
||||||
populate: '%db.populate%'
|
populate: '%db.populate%'
|
||||||
dump: '%db.dump_path%'
|
dump: '%db.dump_path%'
|
||||||
|
|
||||||
|
@@ -2,11 +2,28 @@
|
|||||||
"name": "e107inc/e107-test",
|
"name": "e107inc/e107-test",
|
||||||
"description": "Test harness for e107",
|
"description": "Test harness for e107",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.1 || ^8.2 || ^8.3 || ^8.4"
|
||||||
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"twig/twig": ">=1.28",
|
"twig/twig": "^3.12",
|
||||||
"codeception/codeception": "^4.2",
|
"codeception/codeception": "^5.2.1",
|
||||||
"codeception/module-asserts": "^1.1",
|
"codeception/module-asserts": "^3.0",
|
||||||
"codeception/module-db": "^1.0",
|
"codeception/module-db": "^3.1",
|
||||||
"codeception/module-phpbrowser": "^1.0"
|
"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
|
<?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);
|
$params = include(PARAMS_GENERATOR);
|
||||||
|
|
||||||
$app_path = $params['app_path'] ?: codecept_root_dir()."/e107";
|
$app_path = $params['app_path'] ?: codecept_root_dir() . "/e107";
|
||||||
|
if(substr($app_path, 0, 1) !== '/')
|
||||||
// Relative path
|
{
|
||||||
if (substr($app_path, 0, 1) !== '/')
|
|
||||||
$app_path = codecept_root_dir() . "/{$app_path}";
|
$app_path = codecept_root_dir() . "/{$app_path}";
|
||||||
|
}
|
||||||
define('APP_PATH', realpath($app_path));
|
define('APP_PATH', realpath($app_path));
|
||||||
define('PARAMS_SERIALIZED', serialize($params));
|
define('PARAMS_SERIALIZED', serialize($params));
|
||||||
|
// define('e_PLUGIN', APP_PATH . '/e107_plugins/');
|
||||||
|
|
||||||
// Provide a way to register callbacks that execute before Codeception's
|
$pluginsDir = realpath(codecept_root_dir() . '/../e107_plugins/');
|
||||||
include(codecept_root_dir()."/lib/PriorityCallbacks.php");
|
$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
|
<?php
|
||||||
namespace Helper;
|
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
|
class DelayedDb extends \Codeception\Module\Db
|
||||||
{
|
{
|
||||||
protected $requiredFields = [];
|
protected array $requiredFields = ['dsn', 'user', 'password']; // Enforce required config
|
||||||
|
|
||||||
public function _initialize()
|
public function _initialize(): void
|
||||||
{
|
{
|
||||||
// Noop
|
// Call parent directly instead of deferring
|
||||||
}
|
parent::_initialize();
|
||||||
|
codecept_debug("DelayedDb initialized with DSN: " . $this->config['dsn']);
|
||||||
|
}
|
||||||
|
|
||||||
public function _delayedInitialize()
|
// Keep this for manual triggering if needed
|
||||||
{
|
public function _delayedInitialize()
|
||||||
return parent::_initialize();
|
{
|
||||||
}
|
return parent::_initialize();
|
||||||
|
}
|
||||||
|
|
||||||
public function _getDbHostname()
|
public function _getDbHostname()
|
||||||
{
|
{
|
||||||
$matches = [];
|
$matches = [];
|
||||||
$matched = preg_match('~host=([^;]+)~s', $this->config['dsn'], $matches);
|
$matched = preg_match('~host=([^;]+)~s', $this->config['dsn'], $matches);
|
||||||
if (!$matched)
|
return $matched ? $matches[1] : false;
|
||||||
{
|
}
|
||||||
return 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()
|
public function _getDbUsername()
|
||||||
{
|
{
|
||||||
$matches = [];
|
return $this->config['user'];
|
||||||
$matched = preg_match('~dbname=([^;]+)~s', $this->config['dsn'], $matches);
|
}
|
||||||
if (!$matched)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $matches[1];
|
public function _getDbPassword()
|
||||||
}
|
{
|
||||||
|
return $this->config['password'];
|
||||||
public function _getDbUsername()
|
}
|
||||||
{
|
}
|
||||||
return $this->config['user'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function _getDbPassword()
|
|
||||||
{
|
|
||||||
return $this->config['password'];
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user