mirror of
https://github.com/e107inc/e107.git
synced 2025-07-26 01:11:28 +02:00
Issue #5444 - Support for plugin tests.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests\Unit\_blank;
|
namespace E107\Plugins\_blank\Tests\Unit;
|
||||||
use Codeception\Test\Unit;
|
use Codeception\Test\Unit;
|
||||||
|
|
||||||
/* To use, run these commands from the root directory of e107 in CLI:
|
/* To use, run these commands from the root directory of e107 in CLI:
|
||||||
|
@@ -3,16 +3,16 @@
|
|||||||
"description": "Test harness for e107",
|
"description": "Test harness for e107",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1 || ^8.2 || ^8.3 || ^8.4"
|
"php": "^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"twig/twig": "^3.12",
|
"twig/twig": "^3.0",
|
||||||
"codeception/codeception": "^5.2.1",
|
"codeception/codeception": "^5.0.11 || ^4.2.2",
|
||||||
"codeception/module-asserts": "^3.0",
|
"codeception/module-asserts": "^3.0 || ^1.3",
|
||||||
"codeception/module-db": "^3.1",
|
"codeception/module-db": "^3.1 || ^1.2",
|
||||||
"codeception/module-phpbrowser": "^3.0",
|
"codeception/module-phpbrowser": "^3.0 || ^1.1",
|
||||||
"codeception/module-filesystem": "^3.0",
|
"codeception/module-filesystem": "^3.0 || ^1.1",
|
||||||
"codeception/module-webdriver": "^4.0"
|
"codeception/module-webdriver": "^4.0 || ^1.4"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
@@ -22,8 +22,7 @@
|
|||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Helper\\": "tests/_support/Helper/",
|
"Helper\\": "tests/_support/Helper/",
|
||||||
"Tests\\Unit\\": "tests/unit/",
|
"Tests\\Unit\\": "tests/unit/"
|
||||||
"Tests\\": "../e107_plugins/"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
532
e107_tests/composer.lock
generated
532
e107_tests/composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
|||||||
use Codeception\Util\Autoload;
|
use Codeception\Util\Autoload;
|
||||||
use Codeception\Configuration;
|
use Codeception\Configuration;
|
||||||
|
|
||||||
|
|
||||||
class E107TestSuiteBootstrap
|
class E107TestSuiteBootstrap
|
||||||
{
|
{
|
||||||
const ENABLE_LOGGING = false; // Toggle logging (set to true to enable)
|
const ENABLE_LOGGING = false; // Toggle logging (set to true to enable)
|
||||||
@@ -37,14 +38,12 @@ class E107TestSuiteBootstrap
|
|||||||
$this->log("Root Dir: " . codecept_root_dir());
|
$this->log("Root Dir: " . codecept_root_dir());
|
||||||
|
|
||||||
// Load core unit tests namespace (e107_tests/tests/unit/)
|
// Load core unit tests namespace (e107_tests/tests/unit/)
|
||||||
Autoload::addNamespace('Tests\Unit', codecept_root_dir() . '/tests/unit');
|
Autoload::addNamespace('', codecept_root_dir() . '/tests/unit');
|
||||||
$this->log("Added core unit namespace: Tests\\Unit => " . codecept_root_dir() . '/tests/unit');
|
$this->log("Added core unit namespace: '' => " . codecept_root_dir() . '/tests/unit');
|
||||||
|
|
||||||
// Load parameters
|
|
||||||
define('PARAMS_GENERATOR', realpath(codecept_root_dir() . "/lib/config.php"));
|
define('PARAMS_GENERATOR', realpath(codecept_root_dir() . "/lib/config.php"));
|
||||||
$params = include(PARAMS_GENERATOR);
|
$params = include(PARAMS_GENERATOR);
|
||||||
|
|
||||||
// Define APP_PATH
|
|
||||||
$app_path = $params['app_path'] ?: codecept_root_dir() . "/e107";
|
$app_path = $params['app_path'] ?: codecept_root_dir() . "/e107";
|
||||||
if (substr($app_path, 0, 1) !== '/')
|
if (substr($app_path, 0, 1) !== '/')
|
||||||
{
|
{
|
||||||
@@ -53,10 +52,9 @@ class E107TestSuiteBootstrap
|
|||||||
define('APP_PATH', realpath($app_path));
|
define('APP_PATH', realpath($app_path));
|
||||||
define('PARAMS_SERIALIZED', serialize($params));
|
define('PARAMS_SERIALIZED', serialize($params));
|
||||||
|
|
||||||
// Log App Path after definition
|
|
||||||
$this->log("App Path: " . APP_PATH);
|
$this->log("App Path: " . APP_PATH);
|
||||||
|
|
||||||
// e_PLUGIN status
|
|
||||||
if (defined('e_PLUGIN'))
|
if (defined('e_PLUGIN'))
|
||||||
{
|
{
|
||||||
$this->log("e_PLUGIN already defined as: " . e_PLUGIN);
|
$this->log("e_PLUGIN already defined as: " . e_PLUGIN);
|
||||||
@@ -66,7 +64,6 @@ class E107TestSuiteBootstrap
|
|||||||
$this->log("e_PLUGIN not defined yet");
|
$this->log("e_PLUGIN not defined yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set plugins directory once
|
|
||||||
$this->pluginsDir = realpath(codecept_root_dir() . '/../e107_plugins/');
|
$this->pluginsDir = realpath(codecept_root_dir() . '/../e107_plugins/');
|
||||||
$this->log("Plugins Dir: $this->pluginsDir");
|
$this->log("Plugins Dir: $this->pluginsDir");
|
||||||
|
|
||||||
@@ -74,7 +71,6 @@ class E107TestSuiteBootstrap
|
|||||||
$this->loadUnitTests();
|
$this->loadUnitTests();
|
||||||
$this->loadAcceptanceTests();
|
$this->loadAcceptanceTests();
|
||||||
|
|
||||||
// Include required e107 file
|
|
||||||
include(codecept_root_dir() . "/lib/PriorityCallbacks.php");
|
include(codecept_root_dir() . "/lib/PriorityCallbacks.php");
|
||||||
|
|
||||||
$this->log("e_PLUGIN after initialization: " . (defined('e_PLUGIN') ? e_PLUGIN : 'not defined'));
|
$this->log("e_PLUGIN after initialization: " . (defined('e_PLUGIN') ? e_PLUGIN : 'not defined'));
|
||||||
@@ -87,7 +83,7 @@ class E107TestSuiteBootstrap
|
|||||||
if ($this->pluginsDir && is_dir($this->pluginsDir))
|
if ($this->pluginsDir && is_dir($this->pluginsDir))
|
||||||
{
|
{
|
||||||
$unitDirs = glob($this->pluginsDir . '/*/tests/unit', GLOB_ONLYDIR);
|
$unitDirs = glob($this->pluginsDir . '/*/tests/unit', GLOB_ONLYDIR);
|
||||||
$separator = DIRECTORY_SEPARATOR; // \ on Windows, / on Linux
|
$separator = DIRECTORY_SEPARATOR;
|
||||||
$unitGlobPattern = str_replace('/', $separator, $this->pluginsDir . '/*/tests/unit');
|
$unitGlobPattern = str_replace('/', $separator, $this->pluginsDir . '/*/tests/unit');
|
||||||
$this->log("Unit Glob Pattern: $unitGlobPattern");
|
$this->log("Unit Glob Pattern: $unitGlobPattern");
|
||||||
$this->log("Found Unit Dirs: " . (empty($unitDirs) ? 'None' : ''));
|
$this->log("Found Unit Dirs: " . (empty($unitDirs) ? 'None' : ''));
|
||||||
@@ -100,11 +96,12 @@ class E107TestSuiteBootstrap
|
|||||||
}
|
}
|
||||||
foreach ($unitDirs as $testDir)
|
foreach ($unitDirs as $testDir)
|
||||||
{
|
{
|
||||||
$pluginName = basename(dirname($testDir, 2)); // Two levels up from /unit
|
$pluginName = basename(dirname($testDir, 2));
|
||||||
$relativePath = '../e107_plugins/' . $pluginName . '/tests/unit';
|
$relativePath = '../e107_plugins/' . $pluginName . '/tests/unit';
|
||||||
$pluginUnitDirs[] = $relativePath;
|
$pluginUnitDirs[] = $relativePath;
|
||||||
Autoload::addNamespace("Tests\\Unit\\" . ucfirst($pluginName), $testDir);
|
$namespace = "E107\\Plugins\\" . ucfirst($pluginName) . "\\Tests\\Unit";
|
||||||
$this->log("Added unit namespace: Tests\\Unit\\" . ucfirst($pluginName) . " => $testDir");
|
Autoload::addNamespace($namespace, $testDir);
|
||||||
|
$this->log("Added unit namespace: $namespace => $testDir");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -121,7 +118,7 @@ class E107TestSuiteBootstrap
|
|||||||
if ($this->pluginsDir && is_dir($this->pluginsDir))
|
if ($this->pluginsDir && is_dir($this->pluginsDir))
|
||||||
{
|
{
|
||||||
$acceptanceDirs = glob($this->pluginsDir . '/*/tests/acceptance', GLOB_ONLYDIR);
|
$acceptanceDirs = glob($this->pluginsDir . '/*/tests/acceptance', GLOB_ONLYDIR);
|
||||||
$separator = DIRECTORY_SEPARATOR; // \ on Windows, / on Linux
|
$separator = DIRECTORY_SEPARATOR;
|
||||||
$acceptanceGlobPattern = str_replace('/', $separator, $this->pluginsDir . '/*/tests/acceptance');
|
$acceptanceGlobPattern = str_replace('/', $separator, $this->pluginsDir . '/*/tests/acceptance');
|
||||||
$this->log("Acceptance Glob Pattern: $acceptanceGlobPattern");
|
$this->log("Acceptance Glob Pattern: $acceptanceGlobPattern");
|
||||||
$this->log("Found Acceptance Dirs: " . (empty($acceptanceDirs) ? 'None' : ''));
|
$this->log("Found Acceptance Dirs: " . (empty($acceptanceDirs) ? 'None' : ''));
|
||||||
@@ -137,8 +134,9 @@ class E107TestSuiteBootstrap
|
|||||||
$pluginName = basename(dirname($testDir, 2));
|
$pluginName = basename(dirname($testDir, 2));
|
||||||
$relativePath = '../e107_plugins/' . $pluginName . '/tests/acceptance';
|
$relativePath = '../e107_plugins/' . $pluginName . '/tests/acceptance';
|
||||||
$pluginAcceptanceDirs[] = $relativePath;
|
$pluginAcceptanceDirs[] = $relativePath;
|
||||||
Autoload::addNamespace("Tests\\Acceptance\\" . ucfirst($pluginName), $testDir);
|
$namespace = "E107\\Plugins\\" . ucfirst($pluginName) . "\\Tests\\Acceptance";
|
||||||
$this->log("Added acceptance namespace: Tests\\Acceptance\\" . ucfirst($pluginName) . " => $testDir");
|
Autoload::addNamespace($namespace, $testDir);
|
||||||
|
$this->log("Added acceptance namespace: $namespace => $testDir");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -149,5 +147,4 @@ class E107TestSuiteBootstrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
new E107TestSuiteBootstrap;
|
new E107TestSuiteBootstrap;
|
Reference in New Issue
Block a user