mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-12 15:04:04 +00:00
- Added codeception test for PCRM
- Fixes and improvements for PCRMLib
This commit is contained in:
@@ -20,8 +20,7 @@ class PCRMLib
|
|||||||
"PCRMLib", // disabled self loading
|
"PCRMLib", // disabled self loading
|
||||||
"LogLib", // hardly usefull and virtually dangerous
|
"LogLib", // hardly usefull and virtually dangerous
|
||||||
"MigrationLib", // virtually dangerous, DB manipulation
|
"MigrationLib", // virtually dangerous, DB manipulation
|
||||||
"FilesystemLib", // virtually dangerous, direct access to file system
|
"FilesystemLib" // virtually dangerous, direct access to file system
|
||||||
"REST_Controller" // recursion issues (?)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -323,8 +322,9 @@ class PCRMLib
|
|||||||
{
|
{
|
||||||
// Get informations about the function
|
// Get informations about the function
|
||||||
$reflectionMethod = new ReflectionMethod($resourceName, $function);
|
$reflectionMethod = new ReflectionMethod($resourceName, $function);
|
||||||
// If the number of given parameters is equal to the number of parameters required by the function
|
// If the number of given parameters is greater or equal to the number of
|
||||||
if ($reflectionMethod->getNumberOfRequiredParameters() == count($parameters))
|
// parameters required by the function
|
||||||
|
if (count($parameters) >= $reflectionMethod->getNumberOfRequiredParameters())
|
||||||
{
|
{
|
||||||
// If the function is static
|
// If the function is static
|
||||||
if ($reflectionMethod->isStatic() === true)
|
if ($reflectionMethod->isStatic() === true)
|
||||||
@@ -345,6 +345,8 @@ class PCRMLib
|
|||||||
// @ was applied to prevent really ugly and unmanageable errors
|
// @ was applied to prevent really ugly and unmanageable errors
|
||||||
$resultCall = @call_user_func_array($classMethod, $parameters);
|
$resultCall = @call_user_func_array($classMethod, $parameters);
|
||||||
// If errors occurred while running it
|
// If errors occurred while running it
|
||||||
|
// NOTE: if the called function via call_user_func_array returns a boolean set as false,
|
||||||
|
// it will be recognized like a running error. A little bit tricky ;)
|
||||||
if ($resultCall === false)
|
if ($resultCall === false)
|
||||||
{
|
{
|
||||||
$result = $this->_error("Error running " . $resourceName . "->" . $function . "()");
|
$result = $this->_error("Error running " . $resourceName . "->" . $function . "()");
|
||||||
@@ -362,7 +364,10 @@ class PCRMLib
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result = $this->_error("Wrong parameters number!");
|
$result = $this->_error(
|
||||||
|
"Number of required parameters: " . $reflectionMethod->getNumberOfRequiredParameters() .
|
||||||
|
". Given: " . count($parameters)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$I = new ApiTester($scenario);
|
||||||
|
$I->wantTo("Test API call v1/system/PCRM/Call");
|
||||||
|
$I->amHttpAuthenticated("admin", "1q2w3");
|
||||||
|
$I->haveHttpHeader("FHC-API-KEY", "[email protected]");
|
||||||
|
|
||||||
|
$I->sendGET("v1/system/PCRM/Call", array(
|
||||||
|
"resource" => "codex/Bundesland_model", "function" => "load", "bundesland_code" => "1")
|
||||||
|
);
|
||||||
|
$I->seeResponseCodeIs(200);
|
||||||
|
$I->seeResponseIsJson();
|
||||||
|
$I->seeResponseContainsJson(["error" => 0]);
|
||||||
|
|
||||||
|
$I->sendGET("v1/system/PCRM/Call", array(
|
||||||
|
"resource" => "PermissionLib", "function" => "hasPermission",
|
||||||
|
"sn" => "bis.tbl_archiv", "pt" => "s")
|
||||||
|
);
|
||||||
|
$I->seeResponseCodeIs(200);
|
||||||
|
$I->seeResponseIsJson();
|
||||||
|
$I->seeResponseContainsJson(["error" => 0]);
|
||||||
Reference in New Issue
Block a user