[ticket/15540] Fix tests

PHPBB3-15540
This commit is contained in:
rubencm 2021-03-23 01:43:01 +01:00
parent 16220058d3
commit 5c67eabeed
11 changed files with 44 additions and 23 deletions

View file

@ -78,7 +78,8 @@ class acp_search
foreach ($search_types as $search) foreach ($search_types as $search)
{ {
// Only show available search backends // Only show available search backends
if($search->is_available()) { if ($search->is_available())
{
$name = $search->get_name(); $name = $search->get_name();
@ -88,16 +89,20 @@ class acp_search
$identifier = substr($type, strrpos($type, '\\') + 1); $identifier = substr($type, strrpos($type, '\\') + 1);
$search_options .= "<option value=\"$type\"$selected data-toggle-setting=\"#search_{$identifier}_settings\">$name</option>"; $search_options .= "<option value=\"$type\"$selected data-toggle-setting=\"#search_{$identifier}_settings\">$name</option>";
if (method_exists($search, 'acp')) { if (method_exists($search, 'acp'))
{
$vars = $search->acp(); $vars = $search->acp();
if (!$submit) { if (!$submit)
{
$template->assign_block_vars('backend', array( $template->assign_block_vars('backend', array(
'NAME' => $name, 'NAME' => $name,
'SETTINGS' => $vars['tpl'], 'SETTINGS' => $vars['tpl'],
'IDENTIFIER' => $identifier, 'IDENTIFIER' => $identifier,
)); ));
} else if (is_array($vars['config'])) { }
else if (is_array($vars['config']))
{
$settings = array_merge($settings, $vars['config']); $settings = array_merge($settings, $vars['config']);
} }
} }

View file

@ -1404,11 +1404,6 @@ function mcp_fork_topic($topic_ids)
$search_backend_factory = $phpbb_container->get('search.backend_factory'); $search_backend_factory = $phpbb_container->get('search.backend_factory');
$search = $search_backend_factory->get_active(); $search = $search_backend_factory->get_active();
$search_mode = 'post'; $search_mode = 'post';
if ($error)
{
trigger_error($error);
}
} }
else if (!isset($search_type) && !$topic_row['enable_indexing']) else if (!isset($search_type) && !$topic_row['enable_indexing'])
{ {

View file

@ -296,6 +296,11 @@ abstract class base implements search_backend_interface
{ {
$rows = $this->get_posts_between($post_counter + 1, $post_counter + self::BATCH_SIZE); $rows = $this->get_posts_between($post_counter + 1, $post_counter + self::BATCH_SIZE);
if ($this->db->sql_buffer_nested_transactions())
{
$rows = iterator_to_array($rows);
}
foreach ($rows as $row) foreach ($rows as $row)
{ {
// Indexing enabled for this forum // Indexing enabled for this forum

View file

@ -649,7 +649,8 @@ class fulltext_sphinx implements search_backend_interface
*/ */
public function delete_index(int &$post_counter = null): ?array public function delete_index(int &$post_counter = null): ?array
{ {
if ($this->index_created()) { if ($this->index_created())
{
$this->db_tools->sql_table_drop(SPHINX_TABLE); $this->db_tools->sql_table_drop(SPHINX_TABLE);
} }

View file

@ -13,7 +13,6 @@
require_once __DIR__ . '/../../phpBB/includes/functions_admin.php'; require_once __DIR__ . '/../../phpBB/includes/functions_admin.php';
require_once __DIR__ . '/../../phpBB/includes/functions_posting.php'; require_once __DIR__ . '/../../phpBB/includes/functions_posting.php';
require_once __DIR__ . '/../mock/search.php';
class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
{ {

View file

@ -38,7 +38,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$this->login(); $this->login();
$this->admin_login(); $this->admin_login();
$this->create_search_index('phpbb\search\backend\fulltext_native'); $this->create_search_index('phpbb\\search\\backend\\fulltext_native');
$post = $this->create_topic(2, 'Test Topic 1 foosubject', 'This is a test topic posted by the barsearch testing framework.'); $post = $this->create_topic(2, 'Test Topic 1 foosubject', 'This is a test topic posted by the barsearch testing framework.');
@ -49,18 +49,28 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
if ($values["config[search_type]"] != $this->search_backend) if ($values["config[search_type]"] != $this->search_backend)
{ {
$values["config[search_type]"] = $this->search_backend; $values["config[search_type]"] = $this->search_backend;
try
{
$form->setValues($values); $form->setValues($values);
}
catch(\InvalidArgumentException $e)
{
// Search backed is not supported because don't appear in the select
$this->delete_topic($post['topic_id']);
$this->markTestSkipped("Search backend is not supported/running");
}
$crawler = self::submit($form); $crawler = self::submit($form);
$form = $crawler->selectButton('Yes')->form(); $form = $crawler->selectButton('Yes')->form();
$values = $form->getValues(); $values = $form->getValues();
$crawler = self::submit($form); $crawler = self::submit($form);
// check if search backend is not supported // Unknown error selecting search backend
if ($crawler->filter('.errorbox')->count() > 0) if ($crawler->filter('.errorbox')->count() > 0)
{ {
$this->delete_topic($post['topic_id']); $this->fail('Error when trying to select available search backend');
$this->markTestSkipped("Search backend is not supported/running");
} }
$this->create_search_index(); $this->create_search_index();

View file

@ -26,7 +26,7 @@ class phpbb_mock_user
public $lang = []; public $lang = [];
private $options = array(); private $options = array();
public function optionget($item) public function optionget($item, $data = false)
{ {
if (!isset($this->options[$item])) if (!isset($this->options[$item]))
{ {
@ -36,7 +36,7 @@ class phpbb_mock_user
return $this->options[$item]; return $this->options[$item];
} }
public function optionset($item, $value) public function optionset($item, $value, $data = false)
{ {
$this->options[$item] = $value; $this->options[$item] = $value;
} }

View file

@ -24,13 +24,15 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case
protected function setUp(): void protected function setUp(): void
{ {
global $phpbb_root_path, $phpEx, $config, $user, $cache; global $phpbb_root_path, $phpEx, $config, $cache;
parent::setUp(); parent::setUp();
// dbal uses cache // dbal uses cache
$cache = new phpbb_mock_cache(); $cache = new phpbb_mock_cache();
$user = $this->createMock('\phpbb\user');
// set config values // set config values
$config['fulltext_mysql_min_word_len'] = 4; $config['fulltext_mysql_min_word_len'] = 4;
$config['fulltext_mysql_max_word_len'] = 254; $config['fulltext_mysql_max_word_len'] = 254;

View file

@ -24,13 +24,15 @@ class phpbb_search_native_test extends phpbb_search_test_case
protected function setUp(): void protected function setUp(): void
{ {
global $phpbb_root_path, $phpEx, $config, $user, $cache; global $phpbb_root_path, $phpEx, $config, $cache;
parent::setUp(); parent::setUp();
// dbal uses cache // dbal uses cache
$cache = new phpbb_mock_cache(); $cache = new phpbb_mock_cache();
$user = $this->createMock('\phpbb\user');
$this->db = $this->new_dbal(); $this->db = $this->new_dbal();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$class = self::get_search_wrapper('\phpbb\search\backend\fulltext_native'); $class = self::get_search_wrapper('\phpbb\search\backend\fulltext_native');

View file

@ -24,13 +24,15 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case
protected function setUp(): void protected function setUp(): void
{ {
global $phpbb_root_path, $phpEx, $config, $user, $cache; global $phpbb_root_path, $phpEx, $config, $cache;
parent::setUp(); parent::setUp();
// dbal uses cache // dbal uses cache
$cache = new phpbb_mock_cache(); $cache = new phpbb_mock_cache();
$user = $this->createMock('\phpbb\user');
// set config values // set config values
$config['fulltext_postgres_min_word_len'] = 4; $config['fulltext_postgres_min_word_len'] = 4;
$config['fulltext_postgres_max_word_len'] = 254; $config['fulltext_postgres_max_word_len'] = 254;