public function test_progress_tracking() { $this->config->set_finished_task('foo'); $this->config->set_active_module('bar'); $this->config->set_task_progress_count(10); $this->config->increment_current_task_progress(); $progress_data = $this->config->get_progress_data(); $this->assertEquals(1, $progress_data['current_task_progress']); $this->config->increment_current_task_progress(2); $this->assertEquals(array('last_task_module_name' => 'bar', 'last_task_name' => 'foo', 'max_task_progress' => 10, 'current_task_progress' => 3), $this->config->get_progress_data()); }
public function test_progress_tracking() { $this->config->set_finished_task('foo'); $this->config->set_active_module('bar'); $this->config->set_task_progress_count(10); $this->config->increment_current_task_progress(); $progress_data = $this->config->get_progress_data(); $this->assertEquals(1, $progress_data['current_task_progress']); $this->config->increment_current_task_progress(2); // We only want to check these values $result = $this->config->get_progress_data(); $expected_result = array('last_task_module_name' => 'bar', 'last_task_name' => 'foo', 'max_task_progress' => 10, 'current_task_progress' => 3); foreach ($expected_result as $key => $value) { $this->assertEquals($value, $result[$key]); } }
/** * {@inheritdoc} */ public function run() { // Recover install progress $task_name = $this->recover_progress(); $task_found = false; /** * @var string $name ID of the service * @var \phpbb\install\task_interface $task Task object */ foreach ($this->task_collection as $name => $task) { // Run until there are available resources if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { throw new resource_limit_reached_exception(); } // Skip forward until the next task is reached if (!$task_found) { if ($name === $task_name || empty($task_name)) { $task_found = true; if ($name === $task_name) { continue; } } else { continue; } } // Send progress information if ($this->allow_progress_bar) { $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress()); } // Check if we can run the task if (!$task->is_essential() && !$task->check_requirements()) { $this->iohandler->add_log_message(array('SKIP_TASK', $name)); $this->install_config->increment_current_task_progress($this->task_step_count[$name]); continue; } if ($this->allow_progress_bar) { // Only increment progress by one, as if a task has more than one steps // then that should be incremented in the task itself $this->install_config->increment_current_task_progress(); } $task->run(); // Log install progress $this->install_config->set_finished_task($name); // Send progress information if ($this->allow_progress_bar) { $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress()); } $this->iohandler->send_response(); } // Module finished, so clear task progress $this->install_config->set_finished_task(''); }
/** * {@inheritdoc} */ public function run() { // Recover install progress $task_index = $this->recover_progress(); $iterator = $this->task_collection->getIterator(); if ($task_index < $iterator->count()) { $iterator->seek($task_index); } else { $this->install_config->set_finished_task(0); return; } while ($iterator->valid()) { $task = $iterator->current(); $name = $iterator->key(); // Check if we can run the task if (!$task->is_essential() && !$task->check_requirements()) { $this->iohandler->add_log_message(array('SKIP_TASK', $name)); $this->install_config->increment_current_task_progress($this->task_step_count[$name]); } else { // Send progress information if ($this->allow_progress_bar) { $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress()); $this->iohandler->send_response(); } $task->run(); if ($this->allow_progress_bar) { // Only increment progress by one, as if a task has more than one steps // then that should be incremented in the task itself $this->install_config->increment_current_task_progress(); } } $task_index++; $this->install_config->set_finished_task($task_index); $iterator->next(); // Send progress information if ($this->allow_progress_bar) { $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress()); } $this->iohandler->send_response(); // Stop execution if resource limit is reached if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { throw new resource_limit_reached_exception(); } } // Module finished, so clear task progress $this->install_config->set_finished_task(0); }