mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 08:25:42 +02:00
[ticket/11608] split search tests into separate files
Tests for each search backend are into their own separate files. These separate classes inherit from a common search test case class. PHPBB3-11608
This commit is contained in:
parent
9c082999bb
commit
36da38f062
24
tests/functional/search_mysql_test.php
Normal file
24
tests/functional/search_mysql_test.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/search_test.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class phpbb_functional_search_mysql_test extends phpbb_functional_search_test
|
||||||
|
{
|
||||||
|
protected $search_backend;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->search_backend = 'phpbb_search_fulltext_mysql';
|
||||||
|
}
|
||||||
|
}
|
24
tests/functional/search_native_test.php
Normal file
24
tests/functional/search_native_test.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/search_test.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class phpbb_functional_search_native_test extends phpbb_functional_search_test
|
||||||
|
{
|
||||||
|
protected $search_backend;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->search_backend = 'phpbb_search_fulltext_native';
|
||||||
|
}
|
||||||
|
}
|
24
tests/functional/search_postgres_test.php
Normal file
24
tests/functional/search_postgres_test.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/search_test.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class phpbb_functional_search_postgres_test extends phpbb_functional_search_test
|
||||||
|
{
|
||||||
|
protected $search_backend;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->search_backend = 'phpbb_search_fulltext_postgres';
|
||||||
|
}
|
||||||
|
}
|
25
tests/functional/search_sphinx_test.php
Normal file
25
tests/functional/search_sphinx_test.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/search_test.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class phpbb_functional_search_sphinx_test extends phpbb_functional_search_test
|
||||||
|
{
|
||||||
|
protected $search_backend;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->search_backend = 'phpbb_search_fulltext_sphinx';
|
||||||
|
$this->markTestIncomplete('Sphinx search not running for the test board');
|
||||||
|
}
|
||||||
|
}
|
@ -10,46 +10,23 @@
|
|||||||
/**
|
/**
|
||||||
* @group functional
|
* @group functional
|
||||||
*/
|
*/
|
||||||
class phpbb_functional_search_test extends phpbb_functional_test_case
|
abstract class phpbb_functional_search_test extends phpbb_functional_test_case
|
||||||
{
|
{
|
||||||
|
|
||||||
public function test_native()
|
protected function search_found()
|
||||||
{
|
|
||||||
$this->search_backend_test('phpbb_search_fulltext_native');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_mysql_fulltext()
|
|
||||||
{
|
|
||||||
$this->search_backend_test('phpbb_search_fulltext_mysql');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_postgres_fulltext()
|
|
||||||
{
|
|
||||||
$this->search_backend_test('phpbb_search_fulltext_postgres');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_sphinx()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Sphinx search not running for the test board');
|
|
||||||
$this->search_backend_test('phpbb_search_fulltext_sphinx');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function search_found()
|
|
||||||
{
|
{
|
||||||
$crawler = self::request('GET', 'search.php?keywords=phpbb3+installation');
|
$crawler = self::request('GET', 'search.php?keywords=phpbb3+installation');
|
||||||
$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
|
$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
|
||||||
$this->assertEquals(3, $crawler->filter('.posthilit')->count());
|
$this->assertEquals(3, $crawler->filter('.posthilit')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search_not_found()
|
protected function search_not_found()
|
||||||
{
|
{
|
||||||
$crawler = self::request('GET', 'search.php?keywords=loremipsumdedo');
|
$crawler = self::request('GET', 'search.php?keywords=loremipsumdedo');
|
||||||
$this->assertLessThan(1, $crawler->filter('.postbody')->count());
|
$this->assertLessThan(1, $crawler->filter('.postbody')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function search_backend_test($search_backend)
|
public function test_search_backend()
|
||||||
{
|
{
|
||||||
$this->login();
|
$this->login();
|
||||||
$this->admin_login();
|
$this->admin_login();
|
||||||
@ -58,9 +35,9 @@ class phpbb_functional_search_test extends phpbb_functional_test_case
|
|||||||
$form = $crawler->selectButton('Submit')->form();
|
$form = $crawler->selectButton('Submit')->form();
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
|
|
||||||
if ($values["config[search_type]"] != $search_backend)
|
if ($values["config[search_type]"] != $this->search_backend)
|
||||||
{
|
{
|
||||||
$values["config[search_type]"] = $search_backend;
|
$values["config[search_type]"] = $this->search_backend;
|
||||||
$form->setValues($values);
|
$form->setValues($values);
|
||||||
$crawler = self::submit($form);
|
$crawler = self::submit($form);
|
||||||
|
|
||||||
@ -72,11 +49,10 @@ class phpbb_functional_search_test extends phpbb_functional_test_case
|
|||||||
{
|
{
|
||||||
$crawler->filter('.errorbox')->text();
|
$crawler->filter('.errorbox')->text();
|
||||||
self::markTestSkipped("Search backend is not supported/running");
|
self::markTestSkipped("Search backend is not supported/running");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (InvalidArgumentException $e) {}
|
catch (InvalidArgumentException $e) {}
|
||||||
|
|
||||||
$this->create_search_index($search_backend);
|
$this->create_search_index();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logout();
|
$this->logout();
|
||||||
@ -85,17 +61,17 @@ class phpbb_functional_search_test extends phpbb_functional_test_case
|
|||||||
|
|
||||||
$this->login();
|
$this->login();
|
||||||
$this->admin_login();
|
$this->admin_login();
|
||||||
$this->delete_search_index($search_backend);
|
$this->delete_search_index();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function create_search_index($search_backend)
|
protected function create_search_index()
|
||||||
{
|
{
|
||||||
$this->add_lang('acp/search');
|
$this->add_lang('acp/search');
|
||||||
$crawler = self::request(
|
$crawler = self::request(
|
||||||
'POST',
|
'POST',
|
||||||
'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid,
|
'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid,
|
||||||
array(
|
array(
|
||||||
'search_type' => $search_backend,
|
'search_type' => $this->search_backend,
|
||||||
'action' => 'create',
|
'action' => 'create',
|
||||||
'submit' => true,
|
'submit' => true,
|
||||||
)
|
)
|
||||||
@ -103,14 +79,14 @@ class phpbb_functional_search_test extends phpbb_functional_test_case
|
|||||||
$this->assertContains($this->lang('SEARCH_INDEX_CREATED'), $crawler->text());
|
$this->assertContains($this->lang('SEARCH_INDEX_CREATED'), $crawler->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function delete_search_index($search_backend)
|
protected function delete_search_index()
|
||||||
{
|
{
|
||||||
$this->add_lang('acp/search');
|
$this->add_lang('acp/search');
|
||||||
$crawler = self::request(
|
$crawler = self::request(
|
||||||
'POST',
|
'POST',
|
||||||
'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid,
|
'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid,
|
||||||
array(
|
array(
|
||||||
'search_type' => $search_backend,
|
'search_type' => $this->search_backend,
|
||||||
'action' => 'delete',
|
'action' => 'delete',
|
||||||
'submit' => true,
|
'submit' => true,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user