Skip to content

Commit 90ca2f4

Browse files
authored
Merge pull request #235 from WebFiori/dev
Testing of Create Web Service Test Case
2 parents c456f48 + d75c9d0 commit 90ca2f4

File tree

17 files changed

+576
-93
lines changed

17 files changed

+576
-93
lines changed

bootstrap.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use webfiori\framework\App;
77
use webfiori\framework\autoload\ClassLoader;
8+
use webfiori\framework\config\JsonDriver;
89

910
$DS = DIRECTORY_SEPARATOR;
1011

@@ -88,6 +89,11 @@
8889
//run code after tests completion.
8990
register_shutdown_function(function()
9091
{
92+
JsonDriver::setConfigFileName('app-config.json');
93+
App::getConfig()->remove();
94+
JsonDriver::setConfigFileName('run-sql-test.json');
95+
App::getConfig()->remove();
96+
JsonDriver::setConfigFileName('super-confx.json');
9197
App::getConfig()->remove();
9298
});
9399
fprintf(STDOUT, "Registering shutdown function completed.\n");

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"webfiori/jsonx":"v3.3.0",
2424
"webfiori/ui":"v2.6.3",
2525
"webfiori/collections":"v1.1.4",
26-
"webfiori/database":"v0.8.10",
26+
"webfiori/database":"v0.8.11",
2727
"webfiori/cli":"v1.3.0",
2828
"webfiori/mailer":"v1.2.0",
2929
"webfiori/err":"v1.1.0"

phpunit.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<file>./webfiori/framework/cli/commands/UpdateTableCommand.php</file>
4646
<file>./webfiori/framework/cli/commands/VersionCommand.php</file>
4747
<file>./webfiori/framework/cli/commands/WHelpCommand.php</file>
48+
<file>./webfiori/framework/cli/CLITestCase.php</file>
49+
<file>./webfiori/framework/cli/CLIUtils.php</file>
4850

4951
<file>./webfiori/framework/cli/helpers/ClassInfoReader.php</file>
5052
<file>./webfiori/framework/cli/helpers/CreateBackgroundTask.php</file>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
namespace tests\apis\emptyService;
3+
4+
use webfiori\http\WebServicesManager;
5+
/**
6+
*
7+
* @author Ibrahim
8+
*/
9+
class EmptyServicesManager extends WebServicesManager {
10+
public function __construct(string $version = '1.0.0') {
11+
parent::__construct($version);
12+
}
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace tests\apis\multiple;
3+
4+
use webfiori\http\WebServicesManager;
5+
/**
6+
*
7+
* @author Ibrahim
8+
*/
9+
class ServicesManager00 extends WebServicesManager {
10+
public function __construct(string $version = '1.0.0') {
11+
parent::__construct($version);
12+
$this->addService(new WebService00());
13+
$this->addService(new WebService01());
14+
}
15+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
namespace tests\apis\multiple;
3+
4+
use webfiori\http\AbstractWebService;
5+
use webfiori\http\ParamType;
6+
use webfiori\http\ParamOption;
7+
use webfiori\http\RequestMethod;
8+
9+
10+
/**
11+
* A class that contains the implementation of the web service 'say-hi-service'.
12+
* This service has the following parameters:
13+
* <ul>
14+
* <li><b>first-name</b>: Data type: string.</li>
15+
* <li><b>last-name</b>: Data type: string.</li>
16+
* <li><b>age</b>: Data type: integer.</li>
17+
* </ul>
18+
*/
19+
class WebService00 extends AbstractWebService {
20+
/**
21+
* Creates new instance of the class.
22+
*/
23+
public function __construct() {
24+
parent::__construct('say-hi-service');
25+
$this->setDescription('');
26+
$this->setRequestMethods([
27+
RequestMethod::GET,
28+
RequestMethod::POST,
29+
RequestMethod::PATCH,
30+
RequestMethod::HEAD
31+
]);
32+
$this->addParameters([
33+
'first-name' => [
34+
ParamOption::TYPE => ParamType::STRING,
35+
],
36+
'last-name' => [
37+
ParamOption::TYPE => ParamType::STRING,
38+
],
39+
'age' => [
40+
ParamOption::TYPE => ParamType::INT,
41+
ParamOption::OPTIONAL => true,
42+
],
43+
]);
44+
}
45+
/**
46+
* Checks if the client is authorized to call a service or not.
47+
*
48+
* @return boolean If the client is authorized, the method will return true.
49+
*/
50+
public function isAuthorized() {
51+
// TODO: Check if the client is authorized to call the service 'say-hi-service'.
52+
// You can ignore this method or remove it.
53+
//$authHeader = $this->getAuthHeader();
54+
//$authType = $authHeader['type'];
55+
//$token = $authHeader['credentials'];
56+
}
57+
/**
58+
* Process the request.
59+
*/
60+
public function processRequest() {
61+
// TODO: process the request for the service 'say-hi-service'.
62+
$this->getManager()->serviceNotImplemented();
63+
}
64+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
namespace tests\apis\multiple;
3+
4+
use webfiori\http\AbstractWebService;
5+
use webfiori\http\RequestMethod;
6+
7+
8+
/**
9+
* A class that contains the implementation of the web service 'say-hi-service-2'.
10+
*/
11+
class WebService01 extends AbstractWebService {
12+
/**
13+
* Creates new instance of the class.
14+
*/
15+
public function __construct() {
16+
parent::__construct('say-hi-service-2');
17+
$this->setDescription('');
18+
$this->setRequestMethods([
19+
RequestMethod::HEAD,
20+
]);
21+
22+
}
23+
/**
24+
* Checks if the client is authorized to call a service or not.
25+
*
26+
* @return boolean If the client is authorized, the method will return true.
27+
*/
28+
public function isAuthorized() {
29+
// TODO: Check if the client is authorized to call the service 'say-hi-service'.
30+
// You can ignore this method or remove it.
31+
//$authHeader = $this->getAuthHeader();
32+
//$authType = $authHeader['type'];
33+
//$token = $authHeader['credentials'];
34+
}
35+
/**
36+
* Process the request.
37+
*/
38+
public function processRequest() {
39+
// TODO: process the request for the service 'say-hi-service'.
40+
$this->getManager()->serviceNotImplemented();
41+
}
42+
}

0 commit comments

Comments
 (0)