Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| module_base_test | |
100.00% |
18 / 18 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| setUp | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
| test_run | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| test_step_count | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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 | require_once __DIR__ . '/mocks/test_installer_task_mock.php'; |
| 15 | require_once __DIR__ . '/mocks/test_installer_module.php'; |
| 16 | |
| 17 | class module_base_test extends phpbb_test_case |
| 18 | { |
| 19 | /** |
| 20 | * @var \phpbb\install\module_interface |
| 21 | */ |
| 22 | protected $module; |
| 23 | |
| 24 | /** |
| 25 | * @var phpbb_mock_container_builder |
| 26 | */ |
| 27 | protected $container; |
| 28 | |
| 29 | protected function setUp(): void |
| 30 | { |
| 31 | // DI container mock |
| 32 | $this->container = new phpbb_mock_container_builder(); |
| 33 | $this->container->set('task_one', new test_installer_task_mock()); |
| 34 | $this->container->set('task_two', new test_installer_task_mock()); |
| 35 | |
| 36 | // the collection |
| 37 | $module_collection = new \phpbb\di\ordered_service_collection($this->container); |
| 38 | $module_collection->add('task_one'); |
| 39 | $module_collection->add('task_two'); |
| 40 | $module_collection->add_service_class('task_one', 'test_installer_task_mock'); |
| 41 | $module_collection->add_service_class('task_two', 'test_installer_task_mock'); |
| 42 | |
| 43 | $this->module = new test_installer_module($module_collection, true, false); |
| 44 | |
| 45 | $iohandler = $this->createMock('\phpbb\install\helper\iohandler\iohandler_interface'); |
| 46 | $config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \bantu\IniGetWrapper\IniGetWrapper(), ''); |
| 47 | $this->module->setup($config, $iohandler); |
| 48 | } |
| 49 | |
| 50 | public function test_run() |
| 51 | { |
| 52 | $this->module->run(); |
| 53 | |
| 54 | $task = $this->container->get('task_one'); |
| 55 | $this->assertTrue($task->was_task_runned()); |
| 56 | |
| 57 | $task = $this->container->get('task_two'); |
| 58 | $this->assertTrue($task->was_task_runned()); |
| 59 | } |
| 60 | |
| 61 | public function test_step_count() |
| 62 | { |
| 63 | $this->assertEquals(4, $this->module->get_step_count()); |
| 64 | } |
| 65 | } |