2009-11-22 08:23:12 +00:00
|
|
|
<?php
|
2016-08-23 14:36:06 +12:00
|
|
|
|
2017-08-09 14:53:38 +12:00
|
|
|
namespace SilverStripe\CMS\Tests\Search;
|
2017-08-09 13:25:12 +12:00
|
|
|
|
2018-03-21 17:44:24 +13:00
|
|
|
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search;
|
2016-08-23 14:36:06 +12:00
|
|
|
use SilverStripe\Dev\FunctionalTest;
|
2017-08-09 14:53:38 +12:00
|
|
|
use SilverStripe\Security\Member;
|
2017-08-09 13:25:12 +12:00
|
|
|
|
2017-01-26 09:59:25 +13:00
|
|
|
class CMSMainSearchFormTest extends FunctionalTest
|
|
|
|
{
|
2017-08-09 14:53:38 +12:00
|
|
|
protected static $fixture_file = '../Controllers/CMSMainTest.yml';
|
2017-01-26 09:59:25 +13:00
|
|
|
|
|
|
|
public function testTitleFilter()
|
|
|
|
{
|
2017-08-09 14:53:38 +12:00
|
|
|
$this->session()->set('loggedInAs', $this->idFromFixture(Member::class, 'admin'));
|
2017-01-26 09:59:25 +13:00
|
|
|
|
2018-03-21 17:44:24 +13:00
|
|
|
$this->get(
|
2018-09-04 13:13:33 +12:00
|
|
|
'admin/pages/?' .
|
2020-04-19 16:18:01 +12:00
|
|
|
http_build_query([
|
|
|
|
'q' => [
|
2018-09-04 13:13:33 +12:00
|
|
|
'Term' => 'Page 10',
|
2018-03-21 17:44:24 +13:00
|
|
|
'FilterClass' => CMSSiteTreeFilter_Search::class,
|
2020-04-19 16:18:01 +12:00
|
|
|
]
|
|
|
|
])
|
2017-01-26 09:59:25 +13: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()
|
|
|
|
{
|
2020-04-19 16:18:01 +12:00
|
|
|
$titles = [];
|
2018-09-04 13:13:33 +12:00
|
|
|
$links = $this->cssParser()->getBySelector('.col-getTreeTitle span.item');
|
2017-01-26 09:59:25 +13:00
|
|
|
if ($links) {
|
|
|
|
foreach ($links as $link) {
|
|
|
|
$titles[] = preg_replace('/\n/', ' ', $link->asXML());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $titles;
|
|
|
|
}
|
2012-04-12 19:23:20 +12:00
|
|
|
}
|