Replace old structure with new structure

This commit is contained in:
MosLaptop\Not.Reda
2025-08-28 09:28:59 +02:00
parent ea58af4fcc
commit 69dd02eb91
28 changed files with 552 additions and 62 deletions

40
Tests/controllersTest.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
class ControllerTester
{
public function testController($controllerPath, $methodName, $params = [])
{
if (!file_exists($controllerPath)) {
return "Error: Controller file not found at path: $controllerPath";
}
require_once $controllerPath;
// Extract the class name from the file path
$className = basename($controllerPath, '.php');
if (!class_exists($className)) {
return "Error: Class $className not found in the controller file.";
}
$controller = new $className();
if (!method_exists($controller, $methodName)) {
return "Error: Method $methodName not found in class $className.";
}
// Call the method with parameters
return call_user_func_array([$controller, $methodName], $params);
}
}
// Example usage
$tester = new ControllerTester();
$controllerPath = '../App/Controller/ProjectController.php'; // Path to the controller file
$methodName = 'getAllRecords'; // Replace with the method you want to test
$params = []; // Replace with the parameters for the method
$result = $tester->testController($controllerPath, $methodName, $params);
echo '<pre>';
print_r($result);
echo '</pre>';