Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
42.86% covered (danger)
42.86%
9 / 21
36.84% covered (danger)
36.84%
7 / 19
CRAP
0.00% covered (danger)
0.00%
0 / 1
search_backend_mock
42.86% covered (danger)
42.86%
9 / 21
36.84% covered (danger)
36.84%
7 / 19
86.36
0.00% covered (danger)
0.00%
0 / 1
 get_name
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 is_available
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 init
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_search_query
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_common_words
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_word_length
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 split_keywords
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 keyword_search
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 author_search
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 supports_phrase_search
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 index
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 index_remove
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 tidy
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 create_index
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 delete_index
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 index_created
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 index_stats
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_acp_options
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_type
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
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
14use phpbb\search\backend\search_backend_interface;
15
16class search_backend_mock implements search_backend_interface
17{
18    public $index_created = false;
19
20    public function get_name(): string
21    {
22        return 'Mock search backend';
23    }
24
25    public function is_available(): bool
26    {
27        return true;
28    }
29
30    public function init()
31    {
32        return false;
33    }
34
35    public function get_search_query(): string
36    {
37        return '';
38    }
39
40    public function get_common_words(): array
41    {
42        return [];
43    }
44
45    public function get_word_length()
46    {
47        return false;
48    }
49
50    public function split_keywords(string &$keywords, string $terms): bool
51    {
52        return false;
53    }
54
55    public function keyword_search(string $type, string $fields, string $terms, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
56    {
57        return 0;
58    }
59
60    public function author_search(string $type, bool $firstpost_only, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
61    {
62        return 0;
63    }
64
65    public function supports_phrase_search(): bool
66    {
67        return false;
68    }
69
70    public function index(string $mode, int $post_id, string &$message, string &$subject, int $poster_id, int $forum_id)
71    {
72        // Nothing
73    }
74
75    public function index_remove(array $post_ids, array $author_ids, array $forum_ids): void
76    {
77        // Nothing
78    }
79
80    public function tidy(): void
81    {
82        // Nothing
83    }
84
85    public function create_index(int &$post_counter = 0): array|null
86    {
87        $this->index_created = true;
88        return null;
89    }
90
91    public function delete_index(int &$post_counter = 0): array|null
92    {
93        $this->index_created = true;
94        return null;
95    }
96
97    public function index_created(): bool
98    {
99        return $this->index_created;
100    }
101
102    public function index_stats()
103    {
104        return [];
105    }
106
107    public function get_acp_options(): array
108    {
109        return [];
110    }
111
112    public function get_type(): string
113    {
114        return static::class;
115    }
116}
117