2011-03-22 10:00:53 +01:00
|
|
|
<?php
|
2016-06-16 06:57:19 +02:00
|
|
|
|
|
|
|
use SilverStripe\ORM\Versioning\Versioned;
|
2016-07-22 01:32:32 +02:00
|
|
|
use SilverStripe\CMS\Controllers\ContentController;
|
|
|
|
|
2016-06-16 06:57:19 +02:00
|
|
|
|
2011-03-22 10:00:53 +01:00
|
|
|
class ContentControllerSearchExtensionTest extends SapphireTest {
|
2013-10-22 04:21:46 +02:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function testCustomSearchFormClassesToTest() {
|
2011-03-22 10:00:53 +01:00
|
|
|
$page = new Page();
|
|
|
|
$page->URLSegment = 'whatever';
|
|
|
|
$page->Content = 'oh really?';
|
|
|
|
$page->write();
|
2016-04-01 05:17:37 +02:00
|
|
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
2011-03-22 10:00:53 +01:00
|
|
|
$controller = new ContentController($page);
|
2016-01-06 00:42:07 +01:00
|
|
|
$form = $controller->SearchForm();
|
2016-03-08 21:50:55 +01:00
|
|
|
|
2016-07-22 01:32:32 +02:00
|
|
|
if (get_class($form) == 'SilverStripe\\CMS\\Search\\SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch());
|
2011-03-22 10:00:53 +01:00
|
|
|
}
|
2013-10-22 04:21:46 +02:00
|
|
|
|
|
|
|
public function setUpOnce() {
|
|
|
|
parent::setUpOnce();
|
|
|
|
|
|
|
|
FulltextSearchable::enable('File');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FulltextSearchable::enable() leaves behind remains that don't get cleaned up
|
|
|
|
* properly at the end of the test. This becomes apparent when a later test tries to
|
|
|
|
* ALTER TABLE File and add fulltext indexes with the InnoDB table type.
|
|
|
|
*/
|
|
|
|
public function tearDownOnce() {
|
|
|
|
parent::tearDownOnce();
|
|
|
|
|
2016-06-16 06:57:19 +02:00
|
|
|
Config::inst()->update('File', 'create_table_options', array('SilverStripe\ORM\Connect\MySQLDatabase' => 'ENGINE=InnoDB'));
|
2013-10-22 04:21:46 +02:00
|
|
|
File::remove_extension('FulltextSearchable');
|
|
|
|
}
|
|
|
|
|
2012-04-12 09:23:20 +02:00
|
|
|
}
|