aboutsummaryrefslogtreecommitdiffstats
path: root/tests/console/cron/run_test.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/console/cron/run_test.php')
-rw-r--r--tests/console/cron/run_test.php94
1 files changed, 89 insertions, 5 deletions
diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php
index b4a0203325..2744bf132c 100644
--- a/tests/console/cron/run_test.php
+++ b/tests/console/cron/run_test.php
@@ -32,7 +32,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- public function setUp()
+ public function setUp(): void
{
global $db, $config, $phpbb_root_path, $phpEx;
@@ -40,7 +40,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$config = $this->config = new \phpbb\config\config(array('cron_lock' => '0'));
$this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db);
- $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
@@ -50,7 +50,35 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$tasks = array(
$this->task,
);
- $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $phbEx);
+
+ $mock_config = new \phpbb\config\config(array(
+ 'force_server_vars' => false,
+ 'enable_mod_rewrite' => '',
+ ));
+
+ $mock_router = $this->getMockBuilder('\phpbb\routing\router')
+ ->setMethods(array('setContext', 'generate'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock_router->method('setContext')
+ ->willReturn(true);
+ $mock_router->method('generate')
+ ->willReturn('foobar');
+
+ $request = new \phpbb\request\request();
+ $request->enable_super_globals();
+
+ $routing_helper = new \phpbb\routing\helper(
+ $mock_config,
+ $mock_router,
+ new \phpbb\symfony_request($request),
+ $request,
+ new \phpbb\filesystem\filesystem(),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $this->cron_manager = new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
$this->assertSame('0', $config['cron_lock']);
}
@@ -96,7 +124,35 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
{
$tasks = array(
);
- $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $phpEx);
+
+ $mock_config = new \phpbb\config\config(array(
+ 'force_server_vars' => false,
+ 'enable_mod_rewrite' => '',
+ ));
+
+ $mock_router = $this->getMockBuilder('\phpbb\routing\router')
+ ->setMethods(array('setContext', 'generate'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock_router->method('setContext')
+ ->willReturn(true);
+ $mock_router->method('generate')
+ ->willReturn('foobar');
+
+ $request = new \phpbb\request\request();
+ $request->enable_super_globals();
+
+ $routing_helper = new \phpbb\routing\helper(
+ $mock_config,
+ $mock_router,
+ new \phpbb\symfony_request($request),
+ $request,
+ new \phpbb\filesystem\filesystem(),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $this->cron_manager = new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name));
@@ -109,7 +165,35 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
{
$tasks = array(
);
- $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $phpEx);
+
+ $mock_config = new \phpbb\config\config(array(
+ 'force_server_vars' => false,
+ 'enable_mod_rewrite' => '',
+ ));
+
+ $mock_router = $this->getMockBuilder('\phpbb\routing\router')
+ ->setMethods(array('setContext', 'generate'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock_router->method('setContext')
+ ->willReturn(true);
+ $mock_router->method('generate')
+ ->willReturn('foobar');
+
+ $request = new \phpbb\request\request();
+ $request->enable_super_globals();
+
+ $routing_helper = new \phpbb\routing\helper(
+ $mock_config,
+ $mock_router,
+ new \phpbb\symfony_request($request),
+ $request,
+ new \phpbb\filesystem\filesystem(),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $this->cron_manager = new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true));