silverstripe-cms/tests/controller/ContentControllerSearchExtensionTest.php

38 lines
1.1 KiB
PHP
Raw Normal View History

<?php
use SilverStripe\ORM\Versioning\Versioned;
class ContentControllerSearchExtensionTest extends SapphireTest {
public function testCustomSearchFormClassesToTest() {
$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);
$controller = new ContentController($page);
$form = $controller->SearchForm();
2016-03-08 21:50:55 +01:00
if (get_class($form) == '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');
}
}