Skip to content

Commit 0d839cb

Browse files
committed
[ticket/12597] Modification of return statuses and of test files
PHPBB3-12597
1 parent 5fca308 commit 0d839cb

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

phpBB/phpbb/console/command/cron/run_all.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected function configure()
6060
* @param InputInterface input The input stream, unused here
6161
* @param OutputInterface output The output stream, used for printig verbose-mode
6262
* and error information.
63-
* @return null
63+
* @return boolean 0 if all is ok, 1 if a lock error occured
6464
*/
6565
protected function execute(InputInterface $input, OutputInterface $output)
6666
{

tests/console/cron/run_all_test.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class phpbb_console_command_cron_run_all_test extends phpbb_database_test_case
2121
protected $user;
2222
protected $cron_manager;
2323
protected $command_name;
24+
protected $task;
2425

2526
public function getDataSet()
2627
{
@@ -40,8 +41,9 @@ public function setUp()
4041
$this->user = $this->getMock('\phpbb\user');
4142
$this->user->method('lang')->will($this->returnArgument(0));
4243

44+
$this->task = new phpbb_cron_task_simple();
4345
$tasks = array(
44-
new phpbb_cron_task_simple(),
46+
$this->task,
4547
);
4648
$this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $pathEx);
4749

@@ -58,7 +60,7 @@ public function test_normal_use()
5860
$command_tester->execute(array('command' => $this->command_name));
5961

6062
$this->assertSame('', $command_tester->getDisplay());
61-
$this->assertSame(1, $cron_num_exec);
63+
$this->assertSame(true, $this->task->executed);
6264
}
6365

6466
public function test_verbose_mode()
@@ -69,7 +71,7 @@ public function test_verbose_mode()
6971
$command_tester->execute(array('command' => $this->command_name, '--verbose' => true));
7072

7173
$this->assertContains('RUNNING_TASK', $command_tester->getDisplay());
72-
$this->assertSame(1, $cron_num_exec);
74+
$this->assertSame(true, $this->task->executed);
7375
}
7476

7577
public function test_error_lock()
@@ -81,7 +83,7 @@ public function test_error_lock()
8183
$command_tester->execute(array('command' => $this->command_name));
8284

8385
$this->assertContains('CRON_LOCK_ERROR', $command_tester->getDisplay());
84-
$this->assertSame(0, $cron_num_exec);
86+
$this->assertSame(false, $this->task->executed);
8587
}
8688

8789
public function get_command_tester()

tests/console/cron/tasks/simple.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33
class phpbb_cron_task_simple extends \phpbb\cron\task\base
44
{
5+
public $executed;
6+
7+
public function __construct()
8+
{
9+
$executed = false;
10+
parent::__construct();
11+
}
12+
513
public function get_name()
614
{
715
return get_class($this);
816
}
917

1018
public function run()
1119
{
12-
global $cron_num_exec;
13-
$cron_num_exec++;
20+
$this->executed = true;
1421
}
1522
}

0 commit comments

Comments
 (0)