silverstripe-framework/tests/search/FulltextSearchableTest.php
Ingo Schommer feefb11dae MINOR Added FulltextSearchable::get_searchable_classes() in order to introspect currently searchable classes, added FulltextSearchableTest, added documentation
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@111789 467b73ca-7a2a-4603-9d3b-597d59a354a9
2011-02-02 14:19:54 +13:00

44 lines
1.6 KiB
PHP

<?php
/**
* @package sapphire
* @subpackage tests
*/
class FulltextSearchableTest extends SapphireTest {
function setUp() {
parent::setUp();
$this->orig['File_searchable'] = Object::has_extension('File', 'FulltextSearchable');
$this->orig['SiteTree_searchable'] = Object::has_extension('SiteTree', 'FulltextSearchable');
// TODO This shouldn't need all arguments included
Object::remove_extension('File', 'FulltextSearchable(\'Filename,Title,Content\')');
Object::remove_extension('SiteTree', 'FulltextSearchable(\'Title,MenuTitle,Content,MetaTitle,MetaDescription,MetaKeywords\')');
}
function tearDown() {
// TODO This shouldn't need all arguments included
if($this->orig['File_searchable']) Object::add_extension('File', 'FulltextSearchable(\'Filename,Title,Content\')');
if($this->orig['SiteTree_searchable']) Object::add_extension('SiteTree', 'FulltextSearchable(\'Title,MenuTitle,Content,MetaTitle,MetaDescription,MetaKeywords\')');
parent::tearDown();
}
function testEnable() {
FulltextSearchable::enable();
$this->assertTrue(Object::has_extension('SiteTree', 'FulltextSearchable'));
$this->assertTrue(Object::has_extension('File', 'FulltextSearchable'));
}
function testEnableWithCustomClasses() {
FulltextSearchable::enable(array('SiteTree'));
$this->assertTrue(Object::has_extension('SiteTree', 'FulltextSearchable'));
// TODO This shouldn't need all arguments included
Object::remove_extension('File', 'FulltextSearchable(\'Filename,Title,Content\')');
$this->assertFalse(Object::has_extension('File', 'FulltextSearchable'));
}
}