diff options
Diffstat (limited to 'tests/console/cron')
-rw-r--r-- | tests/console/cron/cron_list_test.php | 13 | ||||
-rw-r--r-- | tests/console/cron/run_test.php | 15 |
2 files changed, 21 insertions, 7 deletions
diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index 22423304be..fdc9a05cb2 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -32,7 +32,12 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case protected function setUp() { - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + global $phpbb_root_path, $phpEx; + + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $this->user->method('lang')->will($this->returnArgument(0)); } @@ -45,19 +50,19 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function test_only_ready() { $this->initiate_test(2, 0); - $this->assertContains('TASKS_READY command1 command2', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); + $this->assertContains('TASKS_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_only_not_ready() { $this->initiate_test(0, 2); - $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); + $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_both_ready() { $this->initiate_test(2, 2); - $this->assertSame('TASKS_READY command1 command2 TASKS_NOT_READY command3 command4', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); + $this->assertSame('TASKS_READY command1 command2 TASKS_NOT_READY command3 command4', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); } public function get_cron_manager(array $tasks) diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index f76e967484..b4a0203325 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -16,7 +16,6 @@ use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\cron\run; require_once dirname(__FILE__) . '/tasks/simple.php'; -require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php'; class phpbb_console_command_cron_run_test extends phpbb_database_test_case { @@ -39,10 +38,12 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $db = $this->db = $this->new_dbal(); $config = $this->config = new \phpbb\config\config(array('cron_lock' => '0')); - set_config(null, null, null, $this->config); $this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db); - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $this->user->method('lang')->will($this->returnArgument(0)); $this->task = new phpbb_cron_task_simple(); @@ -76,6 +77,10 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $this->assertSame(false, $this->lock->owns_lock()); } + /** + * @expectedException \phpbb\exception\runtime_exception + * @expectedExceptionMessage CRON_LOCK_ERROR + */ public function test_error_lock() { $this->lock->acquire(); @@ -124,6 +129,10 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $this->assertSame(false, $this->lock->owns_lock()); } + /** + * @expectedException \phpbb\exception\runtime_exception + * @expectedExceptionMessage CRON_NO_SUCH_TASK + */ public function test_arg_invalid() { $command_tester = $this->get_command_tester(); |