Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
26 / 26 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_console_searchindex_base | |
100.00% |
26 / 26 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| setUp | |
100.00% |
26 / 26 |
|
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 | use phpbb\config\config; |
| 15 | use phpbb\di\service_collection; |
| 16 | use phpbb\language\language; |
| 17 | use phpbb\log\log; |
| 18 | use phpbb\posting\post_helper; |
| 19 | use phpbb\search\search_backend_factory; |
| 20 | use phpbb\search\state_helper; |
| 21 | use phpbb\user; |
| 22 | |
| 23 | require_once __DIR__ . '/../../mock/search_backend_mock.php'; |
| 24 | require_once __DIR__ . '/../../mock/search_backend_mock_not_available.php'; |
| 25 | |
| 26 | class phpbb_console_searchindex_base extends phpbb_test_case |
| 27 | { |
| 28 | /** @var config */ |
| 29 | protected $config; |
| 30 | |
| 31 | /** @var language */ |
| 32 | protected $language; |
| 33 | |
| 34 | /** @var log */ |
| 35 | protected $log; |
| 36 | |
| 37 | /** @var post_helper */ |
| 38 | protected $post_helper; |
| 39 | |
| 40 | /** @var user */ |
| 41 | protected $user; |
| 42 | |
| 43 | /** @var search_backend_factory */ |
| 44 | protected $search_backend_factory; |
| 45 | |
| 46 | /** @var state_helper */ |
| 47 | protected $state_helper; |
| 48 | |
| 49 | /** @var service_collection */ |
| 50 | protected $search_backend_collection; |
| 51 | |
| 52 | protected function setUp(): void |
| 53 | { |
| 54 | global $phpbb_root_path, $phpEx; |
| 55 | |
| 56 | $this->config = new \phpbb\config\config([ |
| 57 | 'search_indexing_state' => [], |
| 58 | 'search_type' => 'search_backend_mock' |
| 59 | ]); |
| 60 | |
| 61 | $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); |
| 62 | $this->language = new \phpbb\language\language($lang_loader); |
| 63 | |
| 64 | $this->log = $this->createMock('\phpbb\log\log'); |
| 65 | |
| 66 | $this->post_helper = $this->createMock('\phpbb\posting\post_helper'); |
| 67 | $this->post_helper |
| 68 | ->method('get_max_post_id') |
| 69 | ->willReturn(1000); |
| 70 | |
| 71 | $this->user = $this->createMock('\phpbb\user'); |
| 72 | |
| 73 | $phpbb_container = new phpbb_mock_container_builder(); |
| 74 | $this->search_backend_collection = new \phpbb\di\service_collection($phpbb_container); |
| 75 | |
| 76 | $search_backend_mock = new search_backend_mock(); |
| 77 | $this->search_backend_collection->add('search_backend_mock'); |
| 78 | $this->search_backend_collection->add_service_class('search_backend_mock', 'search_backend_mock'); |
| 79 | $phpbb_container->set('search_backend_mock', $search_backend_mock); |
| 80 | |
| 81 | $search_backend_mock_not_available = new search_backend_mock_not_available(); |
| 82 | $this->search_backend_collection->add('search_backend_mock_not_available'); |
| 83 | $this->search_backend_collection->add_service_class('search_backend_mock_not_available', 'search_backend_mock_not_available'); |
| 84 | $phpbb_container->set('search_backend_mock_not_available', $search_backend_mock_not_available); |
| 85 | |
| 86 | $this->search_backend_factory = new search_backend_factory($this->config, $this->search_backend_collection); |
| 87 | |
| 88 | $this->state_helper = new state_helper($this->config, $this->search_backend_factory); |
| 89 | |
| 90 | parent::setUp(); |
| 91 | } |
| 92 | } |
| 93 |