Skip to content

Commit

Permalink
test: Added Additional Test Cases for Scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Jul 1, 2024
1 parent 2f872fe commit 0baf386
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/webfiori/framework/test/cli/SchedulerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,50 @@ public function test13() {
"Check finished.",
], TasksManager::getLogArray());
}
/**
* @test
*/
public function test14() {
$runner = App::getRunner();
$runner->setInputs([
'5'
]);
$runner->setArgsVector([
'webfiori',
'scheduler',
'--force',
'p' => '123456'
]);
$this->assertEquals(0, $runner->start());
$this->assertEquals([
"Select one of the scheduled tasks to force:\n",
"0: Fail 1\n",
"1: Fail 2\n",
"2: Fail 3\n",
"3: Success Every Minute\n",
"4: Success 1\n",
"5: Cancel <--\n",
], $runner->getOutput());
}
/**
* @test
*/
public function test15() {
$runner = App::getRunner();
$runner->setInputs([
'Hell',
'5'
]);
$runner->setArgsVector([
'webfiori',
'scheduler',
'--force',
'--task-name="Rand"',
'p' => '123456'
]);
$this->assertEquals(-1, $runner->start());
$this->assertEquals([
"Error: No task was found which has the name 'Rand'\n",
], $runner->getOutput());
}
}
4 changes: 4 additions & 0 deletions webfiori/framework/cli/commands/SchedulerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public function listTasks() {
}
private function checkTaskArgs($taskName) {
$task = TasksManager::getTask($taskName);

if ($task === null) {
return;
}
$args = $task->getExecArgsNames();

if (count($args) != 0 && $this->confirm('Would you like to customize execution arguments?', false)) {
Expand Down

0 comments on commit 0baf386

Please sign in to comment.