diff options
| author | Dhruv <dhruv.goel92@gmail.com> | 2013-09-01 22:15:33 +0530 |
|---|---|---|
| committer | Dhruv <dhruv.goel92@gmail.com> | 2013-10-05 21:16:05 +0530 |
| commit | 72d939372febdb28088a4ed8584cf28345e398dc (patch) | |
| tree | 678276c819905a2aa8faa709dbaef10c3889d8be /tests/functional/search/base.php | |
| parent | 77ef82682eeb1aea6bccc2ca7b8a14aaad0d02c5 (diff) | |
| download | forums-72d939372febdb28088a4ed8584cf28345e398dc.tar forums-72d939372febdb28088a4ed8584cf28345e398dc.tar.gz forums-72d939372febdb28088a4ed8584cf28345e398dc.tar.bz2 forums-72d939372febdb28088a4ed8584cf28345e398dc.tar.xz forums-72d939372febdb28088a4ed8584cf28345e398dc.zip | |
[ticket/11608] Rename base search test class file
PHPBB3-11608
Diffstat (limited to 'tests/functional/search/base.php')
| -rw-r--r-- | tests/functional/search/base.php | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php new file mode 100644 index 0000000000..c6a5a18c94 --- /dev/null +++ b/tests/functional/search/base.php @@ -0,0 +1,104 @@ +<?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()); + if ($this->search_backend == 'phpbb_search_fulltext_native' || $this->search_backend == 'phpbb_search_fulltext_postgres') + { + $this->markTestIncomplete('Native and Postgres search when fails doesn\'t show the search query'); + } + $split_keywords_string = str_replace(array('+', '-'), ' ', $keywords); + $this->assertEquals($split_keywords_string, $crawler->filter('#keywords')->attr('value')); + } + + public function test_search_backend() + { + if ($this->search_backend == 'phpbb_search_fulltext_sphinx') + { + $this->markTestIncomplete('Sphinx Tests are not supported'); + } + + $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()); + } +} |
