aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-10-07 10:15:06 -0700
committerNathan Guse <nathaniel.guse@gmail.com>2013-10-07 10:15:06 -0700
commit1e2ceb456f24f53560bdb15094759e40bff49ea7 (patch)
treeec1e2047313cd966923c8aa0d34868d7fae67201
parentb0282eeb8a667f098229abab9c37efc2b370c05a (diff)
parent8c73d2834149bdea21c9feb9a5ab8c4525cd6bff (diff)
downloadforums-1e2ceb456f24f53560bdb15094759e40bff49ea7.tar
forums-1e2ceb456f24f53560bdb15094759e40bff49ea7.tar.gz
forums-1e2ceb456f24f53560bdb15094759e40bff49ea7.tar.bz2
forums-1e2ceb456f24f53560bdb15094759e40bff49ea7.tar.xz
forums-1e2ceb456f24f53560bdb15094759e40bff49ea7.zip
Merge pull request #1481 from dhruvgoel92/ticket/11608
[ticket/11608] add functional tests for search
-rw-r--r--tests/functional/search/base.php95
-rw-r--r--tests/functional/search/mysql_test.php23
-rw-r--r--tests/functional/search/native_test.php23
-rw-r--r--tests/functional/search/postgres_test.php23
-rw-r--r--tests/functional/search/sphinx_test.php23
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php5
6 files changed, 192 insertions, 0 deletions
diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php
new file mode 100644
index 0000000000..28327da914
--- /dev/null
+++ b/tests/functional/search/base.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 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..7af8051417
--- /dev/null
+++ b/tests/functional/search/mysql_test.php
@@ -0,0 +1,23 @@
+<?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.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_search_mysql_test extends phpbb_functional_search_base
+{
+ protected $search_backend = '\phpbb\search\fulltext_mysql';
+
+ protected function assert_search_not_found($keywords)
+ {
+ $this->markTestIncomplete('MySQL search when fails doesn\'t show the search query');
+ }
+}
diff --git a/tests/functional/search/native_test.php b/tests/functional/search/native_test.php
new file mode 100644
index 0000000000..ce568df616
--- /dev/null
+++ b/tests/functional/search/native_test.php
@@ -0,0 +1,23 @@
+<?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.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_search_native_test extends phpbb_functional_search_base
+{
+ protected $search_backend = '\phpbb\search\fulltext_native';
+
+ protected function assert_search_not_found($keywords)
+ {
+ $this->markTestIncomplete('Native search when fails doesn\'t show the search query');
+ }
+}
diff --git a/tests/functional/search/postgres_test.php b/tests/functional/search/postgres_test.php
new file mode 100644
index 0000000000..487b8aeebb
--- /dev/null
+++ b/tests/functional/search/postgres_test.php
@@ -0,0 +1,23 @@
+<?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.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_search_postgres_test extends phpbb_functional_search_base
+{
+ protected $search_backend = '\phpbb\search\fulltext_postgres';
+
+ protected function assert_search_not_found($keywords)
+ {
+ $this->markTestIncomplete('Postgres search when fails doesn\'t show the search query');
+ }
+}
diff --git a/tests/functional/search/sphinx_test.php b/tests/functional/search/sphinx_test.php
new file mode 100644
index 0000000000..ef2522f9ed
--- /dev/null
+++ b/tests/functional/search/sphinx_test.php
@@ -0,0 +1,23 @@
+<?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.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_search_sphinx_test extends phpbb_functional_search_base
+{
+ protected $search_backend = '\phpbb\search\fulltext_sphinx';
+
+ public function test_search_backend()
+ {
+ $this->markTestIncomplete('Sphinx Tests are not supported');
+ }
+}
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
index 351a3a9594..2f225fe7af 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -158,6 +158,11 @@ class phpbb_test_case_helpers
{
$config['redis_port'] = $phpbb_redis_port;
}
+
+ if (isset($fulltext_sphinx_id))
+ {
+ $config['fulltext_sphinx_id'] = $fulltext_sphinx_id;
+ }
}
if (isset($_SERVER['PHPBB_TEST_DBMS']))