created mocks for testing

This commit is contained in:
Guillermo Dev
2018-10-13 18:00:51 +02:00
parent e53debb98d
commit 1211af09cc
26 changed files with 412 additions and 118 deletions

View File

@@ -21,17 +21,19 @@ abstract class WebService
/**
* Treat the current request and output the result. This is the only
* method that should be called on the webservice directly !
* @param bool $sendSession needed for testing
*/
public function run()
public function run($sendSession = true)
{
Logger::start(array('version' => $this->version));
$renderer = new Renderer();
$rendererClass = Configuration::get('renderer.class', __NAMESPACE__ . '\Renderer');
$renderer = new $rendererClass;
$data = array();
try {
$result = $this->call();
$result = $this->call($sendSession);
$data["result"][$this->func] = $result;
// Logger::log(print_r($result, true));
@@ -61,13 +63,16 @@ abstract class WebService
* Determines which method to call based on GET or POST parameters and
* call it before returning the result.
*
* @param bool $sendSession used for testing
* @return array
* @throws UsageException
*/
private function call()
private function call($sendSession = true)
{
session_save_path(Configuration::get('session.save_path'));
session_start();
if ($sendSession) {
session_save_path(Configuration::get('session.save_path'));
session_start();
}
$params = empty($_GET) ? $_POST : $_GET;
if (empty($params)) {