2010-10-19 06:53:36 +02:00
|
|
|
<?php
|
2016-08-19 00:51:35 +02:00
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
namespace SilverStripe\ORM\Tests\Search;
|
|
|
|
|
2016-08-19 00:51:35 +02:00
|
|
|
use SilverStripe\Assets\File;
|
|
|
|
use SilverStripe\ORM\Connect\MySQLSchemaManager;
|
|
|
|
use SilverStripe\Core\Config\Config;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\ORM\Search\FulltextSearchable;
|
|
|
|
|
2010-10-19 06:53:36 +02:00
|
|
|
class FulltextSearchableTest extends SapphireTest {
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function setUp() {
|
2010-10-19 06:53:36 +02:00
|
|
|
parent::setUp();
|
2013-10-22 06:52:51 +02:00
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
FulltextSearchable::enable(File::class);
|
2010-10-19 06:53:36 +02:00
|
|
|
}
|
2013-10-22 06:52:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function tearDown() {
|
2010-10-19 06:53:36 +02:00
|
|
|
parent::tearDown();
|
2013-10-22 06:52:51 +02:00
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
File::remove_extension(FulltextSearchable::class);
|
|
|
|
Config::inst()->update(File::class, 'create_table_options', array(
|
2016-08-19 00:51:35 +02:00
|
|
|
MySQLSchemaManager::ID => 'ENGINE=InnoDB')
|
|
|
|
);
|
2010-10-19 06:53:36 +02:00
|
|
|
}
|
2013-10-22 06:52:51 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testEnable() {
|
2016-10-14 03:30:05 +02:00
|
|
|
$this->assertTrue(File::has_extension(FulltextSearchable::class));
|
2010-10-19 06:53:36 +02:00
|
|
|
}
|
2013-10-22 06:52:51 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testEnableWithCustomClasses() {
|
2016-10-14 03:30:05 +02:00
|
|
|
FulltextSearchable::enable(array(File::class));
|
|
|
|
$this->assertTrue(File::has_extension(FulltextSearchable::class));
|
2010-10-19 06:53:36 +02:00
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
File::remove_extension(FulltextSearchable::class);
|
|
|
|
$this->assertFalse(File::has_extension(FulltextSearchable::class));
|
2010-10-19 06:53:36 +02:00
|
|
|
}
|
2013-10-22 06:52:51 +02:00
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|