Skip to content

Commit d3c384f

Browse files
committed
fix: API Creation
1 parent b24ca94 commit d3c384f

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public function testCreateAPITestCase00() {
2020
'--service' => 'c'
2121
]);
2222

23-
if ($output[0] !== "Error: The argument --manager has invalid value.\n") {
23+
if ($output[0] !== "Error: The argument --manager has invalid value: Not a class: A\n") {
2424
$this->fail("Expected error message not found. Full output: " . implode('', $output));
2525
}
2626

27-
$this->assertEquals("Error: The argument --manager has invalid value.\n", $output[0]);
27+
$this->assertEquals("Error: The argument --manager has invalid value: Not a class: A\n", $output[0]);
2828
$this->assertEquals(-1, $this->getExitCode());
2929
}
3030
/**
@@ -210,7 +210,7 @@ public function testCreateAPITestCase06() {
210210
*/
211211
public function testCreateAPITestCase07() {
212212
$this->assertEquals([
213-
"Error: The argument --manager has invalid value.\n",
213+
"Error: The argument --manager has invalid value: Not a class: \\tests\\apis\\emptyService\\Xyz\n",
214214
], $this->executeMultiCommand([
215215
CreateCommand::class,
216216
'--c' => 'api-test',

webfiori/framework/cli/helpers/CreateAPITestCase.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,31 @@ private function readManagerInfo() : bool {
7676
$instance = null;
7777

7878
if ($m !== null) {
79-
if (class_exists($m, false)) {
80-
try {
81-
$instance = new $m();
82-
} catch (\Throwable $ex) {
83-
$this->error("The argument --manager has invalid value.");
84-
return false;
85-
}
79+
try {
80+
if (class_exists($m)) {
81+
82+
$instance = new $m();
83+
8684

8785
if ($instance instanceof WebServicesManager) {
8886
$this->writer->setServicesManager($instance);
8987

9088
return true;
9189
} else {
92-
$this->error("The argument --manager has invalid value.");
90+
$this->error("The argument --manager has invalid value: Not an instance of ".WebServicesManager::class);
9391

9492
return false;
9593
}
94+
9695
} else {
97-
$this->error("The argument --manager has invalid value.");
96+
$this->error("The argument --manager has invalid value: Not a class: ".$m);
9897

9998
return false;
10099
}
100+
} catch (\Throwable $ex) {
101+
$this->error("The argument --manager has invalid value: ".$ex->getMessage());
102+
return false;
103+
}
101104
}
102105

103106
if ($instance === null) {

0 commit comments

Comments
 (0)