silverstripe-cms/tests/controller/ContentControllerSearchExtensionTest.php
2016-08-10 16:09:23 +12:00

40 lines
1.2 KiB
PHP

<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\CMS\Controllers\ContentController;
class ContentControllerSearchExtensionTest extends SapphireTest {
public function testCustomSearchFormClassesToTest() {
$page = new Page();
$page->URLSegment = 'whatever';
$page->Content = 'oh really?';
$page->write();
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$controller = new ContentController($page);
$form = $controller->SearchForm();
if (get_class($form) == 'SilverStripe\\CMS\\Search\\SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch());
}
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();
Config::inst()->update('File', 'create_table_options', array('SilverStripe\ORM\Connect\MySQLDatabase' => 'ENGINE=InnoDB'));
File::remove_extension('FulltextSearchable');
}
}