mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/12597] Refactoring and test improving
Adding tests of return status Refactoring code Adding consistency in verbose mode PHPBB3-12597
This commit is contained in:
@@ -56,56 +56,74 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
|
||||
public function test_normal_use()
|
||||
{
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array('command' => $this->command_name));
|
||||
$exit_status = $command_tester->execute(array('command' => $this->command_name));
|
||||
|
||||
$this->assertSame('', $command_tester->getDisplay());
|
||||
$this->assertSame(true, $this->task->executed);
|
||||
$this->assertSame(0, $exit_status);
|
||||
}
|
||||
|
||||
public function test_verbose_mode()
|
||||
{
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array('command' => $this->command_name, '--verbose' => true));
|
||||
$exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true));
|
||||
|
||||
$this->assertContains('RUNNING_TASK', $command_tester->getDisplay());
|
||||
$this->assertSame(true, $this->task->executed);
|
||||
$this->assertSame(0, $exit_status);
|
||||
}
|
||||
|
||||
public function test_error_lock()
|
||||
{
|
||||
$this->lock->acquire();
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array('command' => $this->command_name));
|
||||
$exit_status = $command_tester->execute(array('command' => $this->command_name));
|
||||
|
||||
$this->assertContains('CRON_LOCK_ERROR', $command_tester->getDisplay());
|
||||
$this->assertSame(false, $this->task->executed);
|
||||
$this->assertSame(1, $exit_status);
|
||||
}
|
||||
|
||||
public function test_no_task()
|
||||
{
|
||||
$tasks = array(
|
||||
);
|
||||
$this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $pathEx);
|
||||
$command_tester = $this->get_command_tester();
|
||||
$exit_status = $command_tester->execute(array('command' => $this->command_name));
|
||||
|
||||
$this->assertContains('CRON_NO_TASK', $command_tester->getDisplay());
|
||||
$this->assertSame(0, $exit_status);
|
||||
}
|
||||
|
||||
public function test_arg_valid()
|
||||
{
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple'));
|
||||
$exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple'));
|
||||
|
||||
$this->assertSame('', $command_tester->getDisplay());
|
||||
$this->assertSame(true, $this->task->executed);
|
||||
$this->assertSame(0, $exit_status);
|
||||
}
|
||||
|
||||
public function test_arg_invalid()
|
||||
{
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array('command' => $this->command_name, 'name' => 'foo'));
|
||||
$exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'foo'));
|
||||
|
||||
$this->assertContains('CRON_NO_TASK', $command_tester->getDisplay());
|
||||
$this->assertContains('CRON_NO_SUCH_TASK', $command_tester->getDisplay());
|
||||
$this->assertSame(false, $this->task->executed);
|
||||
$this->assertSame(2, $exit_status);
|
||||
}
|
||||
|
||||
public function test_arg_valid_verbose()
|
||||
{
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple', '--verbose' => true));
|
||||
$exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple', '--verbose' => true));
|
||||
|
||||
$this->assertSame('', $command_tester->getDisplay());
|
||||
$this->assertContains('RUNNING_TASK', $command_tester->getDisplay());
|
||||
$this->assertSame(true, $this->task->executed);
|
||||
$this->assertSame(0, $exit_status);
|
||||
}
|
||||
|
||||
public function get_command_tester()
|
||||
|
Reference in New Issue
Block a user