Replace old structure with new structure
This commit is contained in:
20
Tests/connectionTest.php
Normal file
20
Tests/connectionTest.php
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
<?php
|
||||
use App\Config\Database;
|
||||
|
||||
require_once __DIR__ . '/../App/Config/Database.php'; // Adjusted to use a relative path
|
||||
|
||||
try {
|
||||
// Create an instance of the Database class
|
||||
$db = new class extends Database {};
|
||||
|
||||
// Establish a connection using the linkDB method
|
||||
$pdo = $db->linkDB();
|
||||
|
||||
// If the connection is successful
|
||||
echo "Connected successfully using PDO";
|
||||
} catch (Exception $e) {
|
||||
// Handle connection error
|
||||
error_log($e->getMessage()); // Log the error message
|
||||
echo "An error occurred while connecting to the database. Please try again later.";
|
||||
}
|
||||
40
Tests/controllersTest.php
Normal file
40
Tests/controllersTest.php
Normal 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>';
|
||||
128
Tests/test.php
Normal file
128
Tests/test.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
define('API', 'restAPI.php'); // NICHT VERAENDERN!!!
|
||||
$url = "http://localhost/VPR_Backend/" . API;
|
||||
// $filepath = "c:\\xampp\\htdocs\\2022_BEE_PBAT3H19AB\\taskit\\";
|
||||
|
||||
/**
|
||||
* Options for get all projetcs
|
||||
*/
|
||||
$defaults = array(
|
||||
CURLOPT_URL => $url . '/project',
|
||||
// CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
|
||||
// CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
|
||||
CURLOPT_CUSTOMREQUEST => "GET"
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* Options for get all tasks
|
||||
*/
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/task',
|
||||
// CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
|
||||
// CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
|
||||
// CURLOPT_CUSTOMREQUEST => "GET"
|
||||
// );
|
||||
|
||||
/**
|
||||
* Options for get tasks filtered
|
||||
*/
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/task/getFilteredTasks?dueDate=1%20DAY',
|
||||
// CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
|
||||
// CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
|
||||
// CURLOPT_CUSTOMREQUEST => "GET"
|
||||
// );
|
||||
|
||||
/**
|
||||
* Options for insert new task
|
||||
*/
|
||||
// $params = json_encode(array(
|
||||
// "projectId" => '72f7cc6e-3717-11eb-add7-2c4d544f8fe0'
|
||||
// , 'title' => 'Neuer Task 5'
|
||||
// , 'expense' => '0,25'
|
||||
// , 'dueDate' => '15.03.2022'
|
||||
// , 'priorityId' => 1));
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/task',
|
||||
// CURLOPT_CUSTOMREQUEST => "POST",
|
||||
// // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
|
||||
// // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
|
||||
// CURLOPT_POSTFIELDS => $params
|
||||
// );
|
||||
|
||||
/**
|
||||
* Options for Update Task OHNE Login
|
||||
*/
|
||||
// $params = json_encode(array("done" => '0'));
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/task/1b2d4564-3718-11eb-add7-2c4d544f8fe0',
|
||||
// CURLOPT_CUSTOMREQUEST => "PUT",
|
||||
// CURLOPT_POSTFIELDS => $params
|
||||
// );
|
||||
|
||||
|
||||
/**
|
||||
* Options for Delete Task OHNE Login
|
||||
*/
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/task/01b169aa-3718-11eb-add7-2c4d544f8fe0',
|
||||
// CURLOPT_CUSTOMREQUEST => "DELETE"
|
||||
// );
|
||||
|
||||
/**
|
||||
* Options for Delete Task MIT Login
|
||||
*/
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/task/cbdb169f-e0da-11e7-a056-2c4d544f8fe0',
|
||||
// CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
|
||||
// CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
|
||||
// CURLOPT_CUSTOMREQUEST => "DELETE"
|
||||
// );
|
||||
|
||||
/**
|
||||
* Options for loginUser
|
||||
*/
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/user/loginUser?username=fiona&pw=12345',
|
||||
// CURLOPT_CUSTOMREQUEST => "GET",
|
||||
// CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
|
||||
// CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
|
||||
// CURLOPT_COOKIEJAR => $filepath . 'cookie.txt' // set same file as cookie jar
|
||||
// );
|
||||
|
||||
/**
|
||||
* Options for isLogin
|
||||
*/
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/user/isLogin',
|
||||
// CURLOPT_CUSTOMREQUEST => "GET",
|
||||
// CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
|
||||
// CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
|
||||
// CURLOPT_COOKIEJAR => $filepath . 'cookie.txt' // set same file as cookie jar
|
||||
// );
|
||||
|
||||
/**
|
||||
* Options for logout
|
||||
*/
|
||||
// $defaults = array(
|
||||
// CURLOPT_URL => $url . '/user/logout',
|
||||
// CURLOPT_CUSTOMREQUEST => "GET",
|
||||
// CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
|
||||
// CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
|
||||
// CURLOPT_COOKIEJAR => $filepath . 'cookie.txt' // set same file as cookie jar
|
||||
// );
|
||||
|
||||
// session_write_close();
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, ($defaults));
|
||||
curl_exec($ch);
|
||||
if(curl_error($ch)) {
|
||||
print(curl_error($ch));
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
// session_start();
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user