silverstripe-reports/tests/search/CMSMainSearchFormTest.php
Ingo Schommer 09ad6dcaa6 ENHANCEMENT Showing full CMS search form (instead of toggling fields individually), removing metadata search fields (limiting to fields applicable in new designs)
API CHANGE Renamed CMSMain->SearchTreeForm() to SearchForm(), CMSMain->doSearchTree() to doSearch() (search can be used for list and gallery views as well)
API CHANGE Removed CMSMain->SiteTreeFilterOptions() and CMSMain::$site_tree_filter_options, moved to CMSMain->SearchForm()
2011-04-28 22:49:34 +12:00

35 lines
915 B
PHP

<?php
class CMSMainSearchFormTest extends FunctionalTest {
static $fixture_file = '../controller/CMSMainTest.yml';
protected $autoFollowRedirection = false;
function testTitleFilter() {
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
$response = $this->get(
'admin/SearchForm/?' .
http_build_query(array(
'Title' => 'Page 10',
'FilterClass' => 'CMSSiteTreeFilter_Search',
'action_doSearch' => true
))
);
$titles = $this->getPageTitles();
$this->assertEquals(count($titles), 1);
// For some reason the title gets split into two lines
$this->assertContains('Page 1', $titles[0]);
}
protected function getPageTitles() {
$titles = array();
$links = $this->cssParser()->getBySelector('li.class-Page a');
if($links) foreach($links as $link) {
$titles[] = preg_replace('/\n/', ' ', $link->asXML());
}
return $titles;
}
}