Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
31 / 31 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_installer_config_test | |
100.00% |
31 / 31 |
|
100.00% |
5 / 5 |
6 | |
100.00% |
1 / 1 |
| setUp | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| test_set_get_var | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| test_get_time_remaining | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| test_get_memory_remaining | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| test_progress_tracking | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | use phpbb\install\helper\config; |
| 15 | |
| 16 | class phpbb_installer_config_test extends phpbb_test_case |
| 17 | { |
| 18 | /** |
| 19 | * @var \phpbb\install\helper\config |
| 20 | */ |
| 21 | private $config; |
| 22 | |
| 23 | protected function setUp(): void |
| 24 | { |
| 25 | $phpbb_root_path = __DIR__ . './../../phpBB/'; |
| 26 | $filesystem = $this->createMock('\phpbb\filesystem\filesystem'); |
| 27 | $php_ini = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper') |
| 28 | ->onlyMethods(array('getNumeric', 'getBytes')) |
| 29 | ->getMock(); |
| 30 | $php_ini->method('getNumeric') |
| 31 | ->willReturn(-1); |
| 32 | $php_ini->method('getBytes') |
| 33 | ->willReturn(-1); |
| 34 | |
| 35 | $this->config = new config($filesystem, $php_ini, $phpbb_root_path); |
| 36 | } |
| 37 | |
| 38 | public function test_set_get_var() |
| 39 | { |
| 40 | $this->config->set('foo', 'bar'); |
| 41 | $this->assertEquals('bar', $this->config->get('foo')); |
| 42 | } |
| 43 | |
| 44 | public function test_get_time_remaining() |
| 45 | { |
| 46 | $this->assertGreaterThan(0, $this->config->get_time_remaining()); |
| 47 | } |
| 48 | |
| 49 | public function test_get_memory_remaining() |
| 50 | { |
| 51 | $this->assertGreaterThan(0, $this->config->get_memory_remaining()); |
| 52 | } |
| 53 | |
| 54 | public function test_progress_tracking() |
| 55 | { |
| 56 | $this->config->set_finished_task(0); |
| 57 | $this->config->set_active_module('bar', 5); |
| 58 | $this->config->set_task_progress_count(10); |
| 59 | $this->config->increment_current_task_progress(); |
| 60 | |
| 61 | $progress_data = $this->config->get_progress_data(); |
| 62 | $this->assertEquals(1, $progress_data['current_task_progress']); |
| 63 | |
| 64 | $this->config->increment_current_task_progress(2); |
| 65 | |
| 66 | // We only want to check these values |
| 67 | $result = $this->config->get_progress_data(); |
| 68 | $expected_result = array( |
| 69 | 'last_task_module_name' => 'bar', |
| 70 | 'last_task_module_index' => 5, |
| 71 | 'last_task_index' => 0, |
| 72 | 'max_task_progress' => 10, |
| 73 | 'current_task_progress' => 3, |
| 74 | ); |
| 75 | |
| 76 | foreach ($expected_result as $key => $value) |
| 77 | { |
| 78 | $this->assertEquals($value, $result[$key]); |
| 79 | } |
| 80 | } |
| 81 | } |