2009-11-22 09:23:12 +01:00
|
|
|
<?php
|
2011-04-22 13:32:10 +02:00
|
|
|
class CMSMainSearchFormTest extends FunctionalTest {
|
2016-03-08 21:50:55 +01:00
|
|
|
|
2013-03-18 11:47:15 +01:00
|
|
|
protected static $fixture_file = '../controller/CMSMainTest.yml';
|
2016-03-08 21:50:55 +01:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function testTitleFilter() {
|
2016-06-23 01:51:20 +02:00
|
|
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('SilverStripe\\Security\\Member', 'admin'));
|
2009-11-22 09:23:12 +01:00
|
|
|
|
|
|
|
$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',
|
2016-07-22 01:32:32 +02:00
|
|
|
'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_Search',
|
2012-04-18 23:40:27 +02:00
|
|
|
),
|
2011-04-22 13:32:10 +02:00
|
|
|
'action_doSearch' => true
|
2009-11-22 09:23:12 +01:00
|
|
|
))
|
|
|
|
);
|
2016-03-08 21:50:55 +01: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
|
2016-03-08 21:50:55 +01:00
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
$this->assertContains('Page 1', $titles[0]);
|
|
|
|
}
|
2016-03-08 21:50:55 +01:00
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
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
|
|
|
}
|