2009-11-22 09:23:12 +01:00
|
|
|
<?php
|
2011-04-22 13:32:10 +02:00
|
|
|
class CMSMainSearchFormTest extends FunctionalTest {
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2013-03-18 11:47:15 +01:00
|
|
|
protected static $fixture_file = '../controller/CMSMainTest.yml';
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function testTitleFilter() {
|
2009-11-22 09:23:12 +01:00
|
|
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
|
|
|
|
|
|
|
$response = $this->get(
|
2012-04-18 23:33:37 +02:00
|
|
|
'admin/pages/SearchForm/?' .
|
2009-11-22 09:23:12 +01:00
|
|
|
http_build_query(array(
|
2012-04-18 23:40:27 +02:00
|
|
|
'q' => array(
|
|
|
|
'Title' => 'Page 10',
|
|
|
|
'FilterClass' => 'CMSSiteTreeFilter_Search',
|
|
|
|
),
|
2011-04-22 13:32:10 +02:00
|
|
|
'action_doSearch' => true
|
2009-11-22 09:23:12 +01:00
|
|
|
))
|
|
|
|
);
|
2012-04-18 23:40:27 +02:00
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
$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;
|
|
|
|
}
|
2012-04-12 09:23:20 +02:00
|
|
|
}
|