aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/search
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/search')
-rw-r--r--tests/functional/search/base_test.php95
-rw-r--r--tests/functional/search/mysql_test.php24
-rw-r--r--tests/functional/search/native_test.php24
-rw-r--r--tests/functional/search/postgres_test.php24
-rw-r--r--tests/functional/search/sphinx_test.php28
5 files changed, 195 insertions, 0 deletions
diff --git a/tests/functional/search/base_test.php b/tests/functional/search/base_test.php
new file mode 100644
index 0000000000..538db6de89
--- /dev/null
+++ b/tests/functional/search/base_test.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ *
+ * @package testing
+ * @copyright (c) 2013 phpBB Group
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+ *
+ */
+
+/**
+ * @group functional
+ */
+abstract class phpbb_functional_search_base_test extends phpbb_functional_test_case
+{
+ protected function assert_search_found($keywords)
+ {
+ $crawler = self::request('GET', 'search.php?keywords=' . $keywords);
+ $this->assertEquals(1, $crawler->filter('.postbody')->count());
+ $this->assertEquals(3, $crawler->filter('.posthilit')->count());
+ }
+
+ protected function assert_search_not_found($keywords)
+ {
+ $crawler = self::request('GET', 'search.php?keywords=' . $keywords);
+ $this->assertEquals(0, $crawler->filter('.postbody')->count());
+ $split_keywords_string = str_replace(array('+', '-'), ' ', $keywords);
+ $this->assertEquals($split_keywords_string, $crawler->filter('#keywords')->attr('value'));
+ }
+
+ public function test_search_backend()
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=settings&sid=' . $this->sid);
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+
+ if ($values["config[search_type]"] != $this->search_backend)
+ {
+ $values["config[search_type]"] = $this->search_backend;
+ $form->setValues($values);
+ $crawler = self::submit($form);
+
+ $form = $crawler->selectButton('Yes')->form();
+ $values = $form->getValues();
+ $crawler = self::submit($form);
+
+ // check if search backend is not supported
+ if ($crawler->filter('.errorbox')->count() > 0)
+ {
+ $this->markTestSkipped("Search backend is not supported/running");
+ }
+ $this->create_search_index();
+ }
+
+ $this->logout();
+ $this->assert_search_found('phpbb3+installation');
+ $this->assert_search_not_found('loremipsumdedo');
+
+ $this->login();
+ $this->admin_login();
+ $this->delete_search_index();
+ }
+
+ protected function create_search_index()
+ {
+ $this->add_lang('acp/search');
+ $crawler = self::request(
+ 'POST',
+ 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid,
+ array(
+ 'search_type' => $this->search_backend,
+ 'action' => 'create',
+ 'submit' => true,
+ )
+ );
+ $this->assertContainsLang('SEARCH_INDEX_CREATED', $crawler->text());
+ }
+
+ protected function delete_search_index()
+ {
+ $this->add_lang('acp/search');
+ $crawler = self::request(
+ 'POST',
+ 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid,
+ array(
+ 'search_type' => $this->search_backend,
+ 'action' => 'delete',
+ 'submit' => true,
+ )
+ );
+ $this->assertContainsLang('SEARCH_INDEX_REMOVED', $crawler->text());
+ }
+}
diff --git a/tests/functional/search/mysql_test.php b/tests/functional/search/mysql_test.php
new file mode 100644
index 0000000000..f27269d76a
--- /dev/null
+++ b/tests/functional/search/mysql_test.php
@@ -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__) . '/base_test.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_search_mysql_test extends phpbb_functional_search_base_test
+{
+ protected $search_backend;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->search_backend = 'phpbb_search_fulltext_mysql';
+ }
+}
diff --git a/tests/functional/search/native_test.php b/tests/functional/search/native_test.php
new file mode 100644
index 0000000000..d2f274e051
--- /dev/null
+++ b/tests/functional/search/native_test.php
@@ -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__) . '/base_test.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_search_native_test extends phpbb_functional_search_base_test
+{
+ protected $search_backend;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->search_backend = 'phpbb_search_fulltext_native';
+ }
+}
diff --git a/tests/functional/search/postgres_test.php b/tests/functional/search/postgres_test.php
new file mode 100644
index 0000000000..110360f28e
--- /dev/null
+++ b/tests/functional/search/postgres_test.php
@@ -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__) . '/base_test.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_search_postgres_test extends phpbb_functional_search_base_test
+{
+ protected $search_backend;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->search_backend = 'phpbb_search_fulltext_postgres';
+ }
+}
diff --git a/tests/functional/search/sphinx_test.php b/tests/functional/search/sphinx_test.php
new file mode 100644
index 0000000000..048f4e491b
--- /dev/null
+++ b/tests/functional/search/sphinx_test.php
@@ -0,0 +1,28 @@
+<?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__) . '/base_test.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_search_sphinx_test extends phpbb_functional_search_base_test
+{
+ protected $search_backend;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->search_backend = 'phpbb_search_fulltext_sphinx';
+ if (!isset($config['fulltext_sphinx_id']))
+ {
+ $this->markTestIncomplete('Sphinx search not running for the test board');
+ }
+ }
+}