diff --git a/tests/webfiori/framework/test/writers/CLICommandClassWriterTest.php b/tests/webfiori/framework/test/writers/CLICommandClassWriterTest.php index bc299216..91b1eb0c 100644 --- a/tests/webfiori/framework/test/writers/CLICommandClassWriterTest.php +++ b/tests/webfiori/framework/test/writers/CLICommandClassWriterTest.php @@ -2,6 +2,7 @@ namespace webfiori\framework\test\writers; use PHPUnit\Framework\TestCase; +use webfiori\cli\CLICommand; use webfiori\framework\writers\CLICommandClassWriter; class CLICommandClassWriterTest extends TestCase { @@ -41,11 +42,29 @@ public function test01() { $this->assertEquals('Lets-Do-It', $writer->getCommandName()); $this->assertEquals('', $writer->getDescription()); $this->assertEquals([], $writer->getArgs()); + $writer->setArgs([ + new \webfiori\cli\Argument('--do', 'A do arg', true) + ]); + $this->assertEquals('', $writer->getDescription()); + $writer->setCommandDescription('Random desc'); + $this->assertEquals('Random desc', $writer->getDescription()); $this->assertEquals([ 'webfiori\cli\CLICommand' ], $writer->getUseStatements()); $writer->writeClass(); - $this->assertTrue(class_exists($writer->getNamespace().'\\'.$writer->getName())); + $clazz = $writer->getNamespace().'\\'.$writer->getName(); + $this->assertTrue(class_exists($clazz)); $writer->removeClass(); + $clazzObj = new $clazz(); + $this->assertTrue($clazzObj instanceof CLICommand); + $this->assertEquals('Lets-Do-It', $clazzObj->getName()); + $this->assertEquals('Random desc', $clazzObj->getDescription()); + $this->assertEquals([ + '--do' + ], $clazzObj->getArgsNames()); + $arg = $clazzObj->getArg('--do'); + $this->assertTrue($arg instanceof \webfiori\cli\Argument); + $this->assertEquals('A do arg', $arg->getDescription()); + $this->assertTrue($arg->isOptional()); } } diff --git a/webfiori/framework/writers/CLICommandClassWriter.php b/webfiori/framework/writers/CLICommandClassWriter.php index 8b536fe3..511e9880 100644 --- a/webfiori/framework/writers/CLICommandClassWriter.php +++ b/webfiori/framework/writers/CLICommandClassWriter.php @@ -157,8 +157,8 @@ public function writeClassComment() { $topArr[] = ' * In addition, the command have the following args:'; $topArr[] = ' *