silverstripe-framework/tests/php/ORM/Search/FulltextSearchableTest.php

46 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2016-10-14 03:30:05 +02:00
namespace SilverStripe\ORM\Tests\Search;
use SilverStripe\Assets\File;
use SilverStripe\ORM\Connect\MySQLSchemaManager;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\ORM\Search\FulltextSearchable;
class FulltextSearchableTest extends SapphireTest {
public function setUp() {
parent::setUp();
2016-10-14 03:30:05 +02:00
FulltextSearchable::enable(File::class);
}
/**
* 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 tearDown() {
parent::tearDown();
2016-10-14 03:30:05 +02:00
File::remove_extension(FulltextSearchable::class);
Config::inst()->update(File::class, 'create_table_options', array(
MySQLSchemaManager::ID => 'ENGINE=InnoDB')
);
}
public function testEnable() {
2016-10-14 03:30:05 +02:00
$this->assertTrue(File::has_extension(FulltextSearchable::class));
}
public function testEnableWithCustomClasses() {
2016-10-14 03:30:05 +02:00
FulltextSearchable::enable(array(File::class));
$this->assertTrue(File::has_extension(FulltextSearchable::class));
2016-10-14 03:30:05 +02:00
File::remove_extension(FulltextSearchable::class);
$this->assertFalse(File::has_extension(FulltextSearchable::class));
}
}