mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
NEW Add config for shutdown flush, remove references to Object and update tests
This commit is contained in:
parent
0de6f52b1f
commit
b448bfcd20
@ -6,8 +6,8 @@ use Exception;
|
|||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use SilverStripe\View\ViewableData;
|
use SilverStripe\View\ViewableData;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\Core\Object;
|
|
||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\FullTextSearch\Search\SearchIntrospection;
|
use SilverStripe\FullTextSearch\Search\SearchIntrospection;
|
||||||
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
||||||
use SilverStripe\FullTextSearch\Utils\MultipleArrayIterator;
|
use SilverStripe\FullTextSearch\Utils\MultipleArrayIterator;
|
||||||
@ -160,11 +160,15 @@ abstract class SearchIndex extends ViewableData
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = $manyMany[2];
|
$class = $manyMany['childClass'];
|
||||||
$options['multi_valued'] = true;
|
$options['multi_valued'] = true;
|
||||||
$options['lookup_chain'][] = array(
|
$options['lookup_chain'][] = array(
|
||||||
'call' => 'method', 'method' => $lookup,
|
'call' => 'method',
|
||||||
'through' => 'many_many', 'class' => $dataclass, 'otherclass' => $class, 'details' => $manyMany
|
'method' => $lookup,
|
||||||
|
'through' => 'many_many',
|
||||||
|
'class' => $dataclass,
|
||||||
|
'otherclass' => $class,
|
||||||
|
'details' => $manyMany,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +361,7 @@ abstract class SearchIndex extends ViewableData
|
|||||||
if (preg_match('/^(\w+)\(/', $type, $match)) {
|
if (preg_match('/^(\w+)\(/', $type, $match)) {
|
||||||
$type = $match[1];
|
$type = $match[1];
|
||||||
}
|
}
|
||||||
list($type, $args) = Object::parse_class_spec($type);
|
list($type, $args) = ClassInfo::parse_class_spec($type);
|
||||||
|
|
||||||
// Get class from shortName
|
// Get class from shortName
|
||||||
$object = Injector::inst()->get($type, false, ['Name' => 'test']);
|
$object = Injector::inst()->get($type, false, ['Name' => 'test']);
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace SilverStripe\FullTextSearch\Search\Updaters;
|
namespace SilverStripe\FullTextSearch\Search\Updaters;
|
||||||
|
|
||||||
|
use SilverStripe\Core\Config\Configurable;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Core\Object;
|
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
@ -28,6 +28,16 @@ use ReflectionClass;
|
|||||||
|
|
||||||
class SearchUpdater
|
class SearchUpdater
|
||||||
{
|
{
|
||||||
|
use Configurable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to register the shutdown function to flush. Can be disabled for example in unit testing.
|
||||||
|
*
|
||||||
|
* @config
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static $flush_on_shutdown = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace the database object with a subclass that captures all manipulations and passes them to us
|
* Replace the database object with a subclass that captures all manipulations and passes them to us
|
||||||
*/
|
*/
|
||||||
@ -174,11 +184,7 @@ class SearchUpdater
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we do have some work to do register the shutdown function to actually do the work
|
// If we do have some work to do register the shutdown function to actually do the work
|
||||||
|
if (self::$processor && !self::$registered && self::config()->get('flush_on_shutdown')) {
|
||||||
// Don't do it if we're testing - there's no database connection outside the test methods, so we'd
|
|
||||||
// just get errors
|
|
||||||
|
|
||||||
if (self::$processor && !self::$registered && !SapphireTest::is_running_test()) {
|
|
||||||
register_shutdown_function(array(SearchUpdater::class, "flush_dirty_indexes"));
|
register_shutdown_function(array(SearchUpdater::class, "flush_dirty_indexes"));
|
||||||
self::$registered = true;
|
self::$registered = true;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace SilverStripe\FullTextSearch\Solr\Reindex\Handlers;
|
namespace SilverStripe\FullTextSearch\Solr\Reindex\Handlers;
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use SilverStripe\Core\Environment;
|
||||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||||
use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
||||||
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
||||||
@ -146,7 +147,7 @@ abstract class SolrReindexBase implements SolrReindexHandler
|
|||||||
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group
|
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group
|
||||||
) {
|
) {
|
||||||
// Set time limit and state
|
// Set time limit and state
|
||||||
increase_time_limit_to();
|
Environment::increaseTimeLimitTo();
|
||||||
SearchVariant::activate_state($state);
|
SearchVariant::activate_state($state);
|
||||||
$logger->info("Adding $class");
|
$logger->info("Adding $class");
|
||||||
|
|
||||||
|
@ -18,8 +18,10 @@ class SearchUpdaterTest extends SapphireTest
|
|||||||
|
|
||||||
private static $index = null;
|
private static $index = null;
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
Config::modify()->set(SearchUpdater::class, 'flush_on_shutdown', false);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
if (self::$index === null) {
|
if (self::$index === null) {
|
||||||
|
@ -7,7 +7,9 @@ namespace SilverStripe\FullTextSearch\Tests\SearchUpdaterTest;
|
|||||||
*/
|
*/
|
||||||
class SearchUpdaterTest_ExtendedContainer extends SearchUpdaterTest_OtherContainer
|
class SearchUpdaterTest_ExtendedContainer extends SearchUpdaterTest_OtherContainer
|
||||||
{
|
{
|
||||||
private static $db = array(
|
private static $table_name = 'SearchUpdaterTest_ExtendedContainer';
|
||||||
|
|
||||||
|
private static $db = [
|
||||||
'SomeField' => 'Varchar',
|
'SomeField' => 'Varchar',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ use SilverStripe\ORM\DataObject;
|
|||||||
*/
|
*/
|
||||||
class SearchUpdaterTest_OtherContainer extends DataObject
|
class SearchUpdaterTest_OtherContainer extends DataObject
|
||||||
{
|
{
|
||||||
|
private static $table_name = 'SearchUpdaterTest_OtherContainer';
|
||||||
|
|
||||||
private static $has_many = [
|
private static $has_many = [
|
||||||
'HasManyObjects' => SearchUpdaterTest_HasMany::class,
|
'HasManyObjects' => SearchUpdaterTest_HasMany::class,
|
||||||
];
|
];
|
||||||
|
@ -24,8 +24,10 @@ class SearchVariantVersionedTest extends SapphireTest
|
|||||||
SearchVariantVersionedTest_Item::class
|
SearchVariantVersionedTest_Item::class
|
||||||
);
|
);
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
Config::modify()->set(SearchUpdater::class, 'flush_on_shutdown', false);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
if (self::$index === null) {
|
if (self::$index === null) {
|
||||||
@ -34,7 +36,7 @@ class SearchVariantVersionedTest extends SapphireTest
|
|||||||
|
|
||||||
SearchUpdater::bind_manipulation_capture();
|
SearchUpdater::bind_manipulation_capture();
|
||||||
|
|
||||||
Config::modify()->set('Injector', SearchUpdateProcessor::class, array(
|
Config::modify()->set(Injector::class, SearchUpdateProcessor::class, array(
|
||||||
'class' => SearchUpdateImmediateProcessor::class
|
'class' => SearchUpdateImmediateProcessor::class
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ if (class_exists('\Phockito')) {
|
|||||||
* Subsite specific solr testing
|
* Subsite specific solr testing
|
||||||
*/
|
*/
|
||||||
class SolrIndexSubsitesTest extends SapphireTest {
|
class SolrIndexSubsitesTest extends SapphireTest {
|
||||||
|
// @todo
|
||||||
public static $fixture_file = 'SolrIndexSubsitesTest/SolrIndexSubsitesTest.yml';
|
// protected static $fixture_file = 'SolrIndexSubsitesTest/SolrIndexSubsitesTest.yml';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SolrIndexSubsitesTest_Index
|
* @var SolrIndexSubsitesTest_Index
|
||||||
@ -21,16 +21,16 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
|||||||
|
|
||||||
protected $server = null;
|
protected $server = null;
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
// Prevent parent::setUp() crashing on db build
|
// Prevent parent::setUp() crashing on db build
|
||||||
if (!class_exists('Subsite')) {
|
if (!class_exists('Subsite')) {
|
||||||
$this->skipTest = true;
|
$this->skipTest = true;
|
||||||
$this->markTestSkipped("These tests need the Subsite module installed to run");
|
$this->markTestSkipped("These tests need the Subsite module installed to run");
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->server = $_SERVER;
|
$this->server = $_SERVER;
|
||||||
|
|
||||||
if (!class_exists('\Phockito')) {
|
if (!class_exists('\Phockito')) {
|
||||||
@ -39,13 +39,6 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check versioned available
|
|
||||||
if (!class_exists('Subsite')) {
|
|
||||||
$this->skipTest = true;
|
|
||||||
$this->markTestSkipped('The subsite module is not installed');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::$index === null) {
|
if (self::$index === null) {
|
||||||
self::$index = singleton('SolrIndexSubsitesTest_Index');
|
self::$index = singleton('SolrIndexSubsitesTest_Index');
|
||||||
}
|
}
|
||||||
@ -60,9 +53,9 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
|||||||
SearchUpdater::clear_dirty_indexes();
|
SearchUpdater::clear_dirty_indexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
if($this->server) {
|
if ($this->server) {
|
||||||
$_SERVER = $this->server;
|
$_SERVER = $this->server;
|
||||||
$this->server = null;
|
$this->server = null;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Core\Injector\Injector;
|
||||||
|
use SilverStripe\Core\Kernel;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_AmbiguousRelationIndex;
|
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_AmbiguousRelationIndex;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_AmbiguousRelationInheritedIndex;
|
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_AmbiguousRelationInheritedIndex;
|
||||||
@ -13,10 +15,8 @@ use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasMan
|
|||||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_ManyMany;
|
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_ManyMany;
|
||||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_OtherContainer;
|
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_OtherContainer;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Control\Director;
|
|
||||||
use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
|
use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
|
||||||
|
|
||||||
|
|
||||||
class SolrIndexTest extends SapphireTest
|
class SolrIndexTest extends SapphireTest
|
||||||
{
|
{
|
||||||
public function testFieldDataHasOne()
|
public function testFieldDataHasOne()
|
||||||
@ -58,15 +58,15 @@ class SolrIndexTest extends SapphireTest
|
|||||||
$index = new SolrIndexTest_AmbiguousRelationIndex();
|
$index = new SolrIndexTest_AmbiguousRelationIndex();
|
||||||
$data = $index->fieldData('HasManyObjects.Field1');
|
$data = $index->fieldData('HasManyObjects.Field1');
|
||||||
|
|
||||||
$this->assertArrayHasKey('SearchUpdaterTest_Container_HasManyObjects_Field1', $data);
|
$this->assertArrayHasKey(SearchUpdaterTest_Container::class . '_HasManyObjects_Field1', $data);
|
||||||
$this->assertArrayHasKey('SearchUpdaterTest_OtherContainer_HasManyObjects_Field1', $data);
|
$this->assertArrayHasKey(SearchUpdaterTest_OtherContainer::class . '_HasManyObjects_Field1', $data);
|
||||||
|
|
||||||
$dataContainer = $data['SearchUpdaterTest_Container_HasManyObjects_Field1'];
|
$dataContainer = $data[SearchUpdaterTest_Container::class . '_HasManyObjects_Field1'];
|
||||||
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
|
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
|
||||||
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
|
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
|
||||||
$this->assertEquals(SearchUpdaterTest_HasMany::class, $dataContainer['class']);
|
$this->assertEquals(SearchUpdaterTest_HasMany::class, $dataContainer['class']);
|
||||||
|
|
||||||
$dataOtherContainer = $data['SearchUpdaterTest_OtherContainer_HasManyObjects_Field1'];
|
$dataOtherContainer = $data[SearchUpdaterTest_OtherContainer::class . '_HasManyObjects_Field1'];
|
||||||
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
|
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
|
||||||
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
|
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
|
||||||
$this->assertEquals(SearchUpdaterTest_HasMany::class, $dataOtherContainer['class']);
|
$this->assertEquals(SearchUpdaterTest_HasMany::class, $dataOtherContainer['class']);
|
||||||
@ -77,15 +77,15 @@ class SolrIndexTest extends SapphireTest
|
|||||||
$index = new SolrIndexTest_AmbiguousRelationIndex();
|
$index = new SolrIndexTest_AmbiguousRelationIndex();
|
||||||
$data = $index->fieldData('ManyManyObjects.Field1');
|
$data = $index->fieldData('ManyManyObjects.Field1');
|
||||||
|
|
||||||
$this->assertArrayHasKey('SearchUpdaterTest_Container_ManyManyObjects_Field1', $data);
|
$this->assertArrayHasKey(SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1', $data);
|
||||||
$this->assertArrayHasKey('SearchUpdaterTest_OtherContainer_ManyManyObjects_Field1', $data);
|
$this->assertArrayHasKey(SearchUpdaterTest_OtherContainer::class . '_ManyManyObjects_Field1', $data);
|
||||||
|
|
||||||
$dataContainer = $data['SearchUpdaterTest_Container_ManyManyObjects_Field1'];
|
$dataContainer = $data[SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1'];
|
||||||
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
|
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
|
||||||
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
|
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
|
||||||
$this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataContainer['class']);
|
$this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataContainer['class']);
|
||||||
|
|
||||||
$dataOtherContainer = $data['SearchUpdaterTest_OtherContainer_ManyManyObjects_Field1'];
|
$dataOtherContainer = $data[SearchUpdaterTest_OtherContainer::class . '_ManyManyObjects_Field1'];
|
||||||
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
|
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
|
||||||
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
|
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
|
||||||
$this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataOtherContainer['class']);
|
$this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataOtherContainer['class']);
|
||||||
@ -96,16 +96,16 @@ class SolrIndexTest extends SapphireTest
|
|||||||
$index = new SolrIndexTest_AmbiguousRelationInheritedIndex();
|
$index = new SolrIndexTest_AmbiguousRelationInheritedIndex();
|
||||||
$data = $index->fieldData('ManyManyObjects.Field1');
|
$data = $index->fieldData('ManyManyObjects.Field1');
|
||||||
|
|
||||||
$this->assertArrayHasKey('SearchUpdaterTest_Container_ManyManyObjects_Field1', $data);
|
$this->assertArrayHasKey(SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1', $data);
|
||||||
$this->assertArrayHasKey('SearchUpdaterTest_OtherContainer_ManyManyObjects_Field1', $data);
|
$this->assertArrayHasKey(SearchUpdaterTest_OtherContainer::class . '_ManyManyObjects_Field1', $data);
|
||||||
$this->assertArrayNotHasKey('SearchUpdaterTest_ExtendedContainer_ManyManyObjects_Field1', $data);
|
$this->assertArrayNotHasKey(SearchUpdaterTest_ExtendedContainer::class . '_ManyManyObjects_Field1', $data);
|
||||||
|
|
||||||
$dataContainer = $data['SearchUpdaterTest_Container_ManyManyObjects_Field1'];
|
$dataContainer = $data[SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1'];
|
||||||
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
|
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
|
||||||
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
|
$this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
|
||||||
$this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataContainer['class']);
|
$this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataContainer['class']);
|
||||||
|
|
||||||
$dataOtherContainer = $data['SearchUpdaterTest_OtherContainer_ManyManyObjects_Field1'];
|
$dataOtherContainer = $data[SearchUpdaterTest_OtherContainer::class . '_ManyManyObjects_Field1'];
|
||||||
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
|
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
|
||||||
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
|
$this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
|
||||||
$this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataOtherContainer['class']);
|
$this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataOtherContainer['class']);
|
||||||
@ -248,8 +248,7 @@ class SolrIndexTest extends SapphireTest
|
|||||||
|
|
||||||
public function testAddFieldExtraOptions()
|
public function testAddFieldExtraOptions()
|
||||||
{
|
{
|
||||||
Config::nest();
|
Injector::inst()->get(Kernel::class)->setEnvironment('live');
|
||||||
Director::set_environment_type('live');
|
|
||||||
|
|
||||||
$index = new SolrIndexTest_FakeIndex();
|
$index = new SolrIndexTest_FakeIndex();
|
||||||
|
|
||||||
@ -261,8 +260,6 @@ class SolrIndexTest extends SapphireTest
|
|||||||
$defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
|
$defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
|
||||||
$defField1 = $defs->xpath('field[@name="' . SearchUpdaterTest_Container::class . '_Field1"]');
|
$defField1 = $defs->xpath('field[@name="' . SearchUpdaterTest_Container::class . '_Field1"]');
|
||||||
$this->assertEquals((string)$defField1[0]['stored'], 'true');
|
$this->assertEquals((string)$defField1[0]['stored'], 'true');
|
||||||
|
|
||||||
Config::unnest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddAnalyzer()
|
public function testAddAnalyzer()
|
||||||
|
@ -27,8 +27,10 @@ class SolrIndexVersionedTest extends SapphireTest
|
|||||||
SolrIndexVersionedTest_Object::class
|
SolrIndexVersionedTest_Object::class
|
||||||
);
|
);
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
Config::modify()->set(SearchUpdater::class, 'flush_on_shutdown', false);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
if (self::$index === null) {
|
if (self::$index === null) {
|
||||||
@ -37,7 +39,7 @@ class SolrIndexVersionedTest extends SapphireTest
|
|||||||
|
|
||||||
SearchUpdater::bind_manipulation_capture();
|
SearchUpdater::bind_manipulation_capture();
|
||||||
|
|
||||||
Config::modify()->set('Injector', SearchUpdateProcessor::class, array(
|
Config::modify()->set(Injector::class, SearchUpdateProcessor::class, array(
|
||||||
'class' => SearchUpdateImmediateProcessor::class
|
'class' => SearchUpdateImmediateProcessor::class
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||||
|
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
|
||||||
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Variant;
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Variant;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Index;
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Index;
|
||||||
@ -38,14 +39,17 @@ class SolrReindexTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
protected $service = null;
|
protected $service = null;
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
Config::modify()->set(SearchUpdater::class, 'flush_on_shutdown', false);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// Set test handler for reindex
|
// Set test handler for reindex
|
||||||
Config::modify()->set('Injector', SolrReindexHandler::class, array(
|
Config::modify()->set(Injector::class, SolrReindexHandler::class, array(
|
||||||
'class' => SolrReindexTest_TestHandler::class
|
'class' => SolrReindexTest_TestHandler::class
|
||||||
));
|
));
|
||||||
|
|
||||||
Injector::inst()->registerService(new SolrReindexTest_TestHandler(), SolrReindexHandler::class);
|
Injector::inst()->registerService(new SolrReindexTest_TestHandler(), SolrReindexHandler::class);
|
||||||
|
|
||||||
// Set test variant
|
// Set test variant
|
||||||
@ -55,6 +59,7 @@ class SolrReindexTest extends SapphireTest
|
|||||||
$this->service = $this->getServiceMock();
|
$this->service = $this->getServiceMock();
|
||||||
$this->index = singleton(SolrReindexTest_Index::class);
|
$this->index = singleton(SolrReindexTest_Index::class);
|
||||||
$this->index->setService($this->service);
|
$this->index->setService($this->service);
|
||||||
|
|
||||||
FullTextSearch::force_index_list($this->index);
|
FullTextSearch::force_index_list($this->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user