1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-09 02:06:32 +02:00

[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

@@ -13,7 +13,6 @@
require_once __DIR__ . '/../../phpBB/includes/functions_admin.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
{

View File

@@ -38,7 +38,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$this->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.');
@@ -49,18 +49,28 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
if ($values["config[search_type]"] != $this->search_backend)
{
$values["config[search_type]"] = $this->search_backend;
$form->setValues($values);
try
{
$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);
$form = $crawler->selectButton('Yes')->form();
$values = $form->getValues();
$crawler = self::submit($form);
// check if search backend is not supported
// Unknown error selecting search backend
if ($crawler->filter('.errorbox')->count() > 0)
{
$this->delete_topic($post['topic_id']);
$this->markTestSkipped("Search backend is not supported/running");
$this->fail('Error when trying to select available search backend');
}
$this->create_search_index();

View File

@@ -26,7 +26,7 @@ class phpbb_mock_user
public $lang = [];
private $options = array();
public function optionget($item)
public function optionget($item, $data = false)
{
if (!isset($this->options[$item]))
{
@@ -36,7 +36,7 @@ class phpbb_mock_user
return $this->options[$item];
}
public function optionset($item, $value)
public function optionset($item, $value, $data = false)
{
$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
{
global $phpbb_root_path, $phpEx, $config, $user, $cache;
global $phpbb_root_path, $phpEx, $config, $cache;
parent::setUp();
// dbal uses cache
$cache = new phpbb_mock_cache();
$user = $this->createMock('\phpbb\user');
// set config values
$config['fulltext_mysql_min_word_len'] = 4;
$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
{
global $phpbb_root_path, $phpEx, $config, $user, $cache;
global $phpbb_root_path, $phpEx, $config, $cache;
parent::setUp();
// dbal uses cache
$cache = new phpbb_mock_cache();
$user = $this->createMock('\phpbb\user');
$this->db = $this->new_dbal();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$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
{
global $phpbb_root_path, $phpEx, $config, $user, $cache;
global $phpbb_root_path, $phpEx, $config, $cache;
parent::setUp();
// dbal uses cache
$cache = new phpbb_mock_cache();
$user = $this->createMock('\phpbb\user');
// set config values
$config['fulltext_postgres_min_word_len'] = 4;
$config['fulltext_postgres_max_word_len'] = 254;