Skip to content

Commit 4f192a2

Browse files
committed
test: Added Additional Test Cases
1 parent b5af5f4 commit 4f192a2

File tree

1 file changed

+70
-4
lines changed

1 file changed

+70
-4
lines changed

tests/webfiori/framework/test/cli/CreateAPITestCaseTest.php

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
use webfiori\framework\App;
55
use webfiori\framework\scheduler\webServices\TasksServicesManager;
6-
use webfiori\framework\writers\ServiceHolder;
7-
use webfiori\framework\writers\WebServiceWriter;
8-
use webfiori\http\ParamOption;
9-
use webfiori\http\ParamType;
6+
use webfiori\http\WebServicesManager;
107
/**
118
* @author Ibrahim
129
*/
@@ -203,4 +200,73 @@ public function testCreateAPITestCase05() {
203200
"Info: Provided services manager has 0 registered services.\n",
204201
], $runner->getOutput());
205202
}
203+
/**
204+
* @test
205+
*/
206+
public function testCreateAPITestCase06() {
207+
$runner = App::getRunner();
208+
$runner->setArgsVector([
209+
'webfiori',
210+
'create',
211+
'--c' => 'api-test',
212+
'--service' => 'get-tasks',
213+
]);
214+
215+
216+
$runner->setArgsVector([
217+
'webfiori',
218+
'create',
219+
'--c' => 'api-test',
220+
'--service' => 'say-hi-service',
221+
]);
222+
$runner->setInputs([
223+
'\\tests\\apis\\multiple\\WebService00',
224+
'\\tests\\apis\\multiple\\ServicesManager00',
225+
'n',
226+
'10',
227+
'',
228+
'',
229+
230+
]);
231+
$exitCode = $runner->start();
232+
$this->assertEquals(0, $exitCode);
233+
$path = ROOT_PATH.DS."tests".DS."tests".DS."apis".DS."multiple";
234+
$this->assertEquals([
235+
"Please enter services manager information:\n",
236+
"Error: Provided class is not an instance of ".WebServicesManager::class."\n",
237+
"Please enter services manager information:\n",
238+
"Test case will be created with following parameters:\n",
239+
"PHPUnit Version: 9\n",
240+
'Name: tests\tests\apis\multiple\WebService00Test'."\n",
241+
"Path: ".$path."\n",
242+
"Would you like to use default parameters?(Y/n)\n",
243+
"PHPUnit Version: Enter = '11'\n",
244+
"Enter a name for the new class:\n",
245+
"Enter an optional namespace for the class: Enter = 'tests\\tests\apis\multiple'\n",
246+
"Info: New class was created at \"".$path."\".\n"
247+
], $runner->getOutput());
248+
$clazz = '\\tests\\tests\\apis\\multiple\\WebService00Test';
249+
$this->assertTrue(class_exists($clazz));
250+
$this->removeClass($clazz);
251+
}
252+
/**
253+
* @test
254+
*/
255+
public function testCreateAPITestCase07() {
256+
$runner = App::getRunner();
257+
$runner->setArgsVector([
258+
'webfiori',
259+
'create',
260+
'--c' => 'api-test',
261+
'--manager' => '\\tests\\apis\\emptyService\\Xyz',
262+
]);
263+
$runner->setInputs();
264+
265+
$exitCode = $runner->start();
266+
$this->assertEquals(-1, $exitCode);
267+
268+
$this->assertEquals([
269+
"Error: The argument --manager has invalid value.\n",
270+
], $runner->getOutput());
271+
}
206272
}

0 commit comments

Comments
 (0)