Skip to content

Commit

Permalink
Update InitAppCommandTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Aug 21, 2023
1 parent 061d01d commit f85813a
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions tests/webfiori/tests/cli/InitAppCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function test00() {
'app.php',
'init'
]);
$r->start();
$this->assertEquals(-1, $r->start());
$this->assertEquals([
"Error: The following required argument(s) are missing: '--dir'\n"
], $r->getOutput());
Expand All @@ -41,12 +41,7 @@ public function test01() {
'init',
'--dir' => "test\0a"
]);
$r->start();
$this->assertEquals([
"Creating \"test\0a/app.php\"...\n",
"Error: Unable to initialize due to an exception:\n",
"2 - file_exists() expects parameter 1 to be a valid path, string given At class File line 502\n"
], $r->getOutput());
$this->assertEquals(-1, $r->start());
}
/**
* @test
Expand All @@ -61,10 +56,11 @@ public function test02() {
'app.php',
'init',
'--dir' => 'test'
])->start();
]);
$this->assertEquals(0, $r->start());
$this->assertEquals([
"Creating \"test/app.php\"...\n",
"Creating \"test/test.sh\"...\n",
"Creating \"test/test\"...\n",
"Success: App created successfully.\n"
], $r->getOutput());
}
Expand All @@ -82,13 +78,45 @@ public function test03() {
'init',
'--dir' => 'test'
]);
$r->start();
$this->assertEquals(0, $r->start());
$this->assertEquals([
"Creating \"test/app.php\"...\n",
"Warning: File app.php already exist!\n",
"Creating \"test/test.sh\"...\n",
"Warning: File test.sh already exist!\n",
"Creating \"test/test\"...\n",
"Warning: File test already exist!\n",
"Success: App created successfully.\n"
], $r->getOutput());
unlink(ROOT_DIR.DS.'test'.DS.'app.php');
unlink(ROOT_DIR.DS.'test'.DS.'test');
rmdir(ROOT_DIR.DS.'test');
}
/**
* @test
*/
public function test04() {
$r = new Runner();
$r->register(new InitAppCommand());
$r->setDefaultCommand('init');
$r->setInputs([]);
$r->setArgsVector([
'app.php',
'init',
'--dir' => 'test2',
'--entry' => 'bang'
]);
$this->assertEquals(0, $r->start());
$this->assertEquals([
"Creating \"test2/app.php\"...\n",
"Creating \"test2/bang\"...\n",
"Success: App created successfully.\n"
], $r->getOutput());
unlink(ROOT_DIR.DS.'test2'.DS.'app.php');
unlink(ROOT_DIR.DS.'test2'.DS.'bang');
rmdir(ROOT_DIR.DS.'test2');
}
}





0 comments on commit f85813a

Please sign in to comment.