2009-11-22 09:23:12 +01:00
|
|
|
<?php
|
2016-08-23 04:36:06 +02:00
|
|
|
|
2017-08-09 04:53:38 +02:00
|
|
|
namespace SilverStripe\CMS\Tests\Search;
|
2017-08-09 03:25:12 +02:00
|
|
|
|
2018-03-21 05:44:24 +01:00
|
|
|
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search;
|
2016-08-23 04:36:06 +02:00
|
|
|
use SilverStripe\Dev\FunctionalTest;
|
2017-08-09 04:53:38 +02:00
|
|
|
use SilverStripe\Security\Member;
|
2017-08-09 03:25:12 +02:00
|
|
|
|
2017-01-25 21:59:25 +01:00
|
|
|
class CMSMainSearchFormTest extends FunctionalTest
|
|
|
|
{
|
2017-08-09 04:53:38 +02:00
|
|
|
protected static $fixture_file = '../Controllers/CMSMainTest.yml';
|
2017-01-25 21:59:25 +01:00
|
|
|
|
|
|
|
public function testTitleFilter()
|
|
|
|
{
|
2021-08-18 02:35:36 +02:00
|
|
|
$this->logInAs('admin');
|
2017-01-25 21:59:25 +01:00
|
|
|
|
2018-03-21 05:44:24 +01:00
|
|
|
$this->get(
|
2018-09-04 03:13:33 +02:00
|
|
|
'admin/pages/?' .
|
2020-04-19 06:18:01 +02:00
|
|
|
http_build_query([
|
|
|
|
'q' => [
|
2018-09-04 03:13:33 +02:00
|
|
|
'Term' => 'Page 10',
|
2018-03-21 05:44:24 +01:00
|
|
|
'FilterClass' => CMSSiteTreeFilter_Search::class,
|
2020-04-19 06:18:01 +02:00
|
|
|
]
|
|
|
|
])
|
2017-01-25 21:59:25 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$titles = $this->getPageTitles();
|
|
|
|
$this->assertEquals(count($titles), 1);
|
|
|
|
// For some reason the title gets split into two lines
|
|
|
|
|
2021-10-27 23:40:52 +02:00
|
|
|
$this->assertStringContainsString('Page 1', $titles[0]);
|
2017-01-25 21:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getPageTitles()
|
|
|
|
{
|
2020-04-19 06:18:01 +02:00
|
|
|
$titles = [];
|
2018-09-04 03:13:33 +02:00
|
|
|
$links = $this->cssParser()->getBySelector('.col-getTreeTitle span.item');
|
2017-01-25 21:59:25 +01:00
|
|
|
if ($links) {
|
|
|
|
foreach ($links as $link) {
|
|
|
|
$titles[] = preg_replace('/\n/', ' ', $link->asXML());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $titles;
|
|
|
|
}
|
2012-04-12 09:23:20 +02:00
|
|
|
}
|