2009-11-22 09:23:12 +01:00
|
|
|
<?php
|
2016-08-23 04:36:06 +02:00
|
|
|
|
|
|
|
use SilverStripe\Dev\FunctionalTest;
|
2017-01-25 21:59:25 +01:00
|
|
|
|
|
|
|
class CMSMainSearchFormTest extends FunctionalTest
|
|
|
|
{
|
|
|
|
|
|
|
|
protected static $fixture_file = '../controller/CMSMainTest.yml';
|
|
|
|
|
|
|
|
public function testTitleFilter()
|
|
|
|
{
|
2017-06-19 03:00:47 +02:00
|
|
|
$this->session()->set('loggedInAs', $this->idFromFixture('SilverStripe\\Security\\Member', 'admin'));
|
2017-01-25 21:59:25 +01:00
|
|
|
|
|
|
|
$response = $this->get(
|
|
|
|
'admin/pages/SearchForm/?' .
|
|
|
|
http_build_query(array(
|
|
|
|
'q' => array(
|
|
|
|
'Title' => 'Page 10',
|
|
|
|
'FilterClass' => 'SilverStripe\\CMS\\Controllers\\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;
|
|
|
|
}
|
2012-04-12 09:23:20 +02:00
|
|
|
}
|