diff --git a/code/search/SearchIntrospection.php b/code/search/SearchIntrospection.php index e7694b0..8f061d0 100644 --- a/code/search/SearchIntrospection.php +++ b/code/search/SearchIntrospection.php @@ -1,7 +1,9 @@ $class) { - if (!DataObject::getSchema()->classHasTable($class)) { - unset($classes[$i]); - } - } - } + if ($dataOnly) { + foreach ($classes as $i => $class) { + if (!DataObject::getSchema()->classHasTable($class)) { + unset($classes[$i]); + } + } + } self::$hierarchy[$key] = $classes; } diff --git a/code/search/captures/SearchManipulateCapture_MySQLDatabase.php b/code/search/captures/SearchManipulateCapture_MySQLDatabase.php index f1b9296..5cc666e 100644 --- a/code/search/captures/SearchManipulateCapture_MySQLDatabase.php +++ b/code/search/captures/SearchManipulateCapture_MySQLDatabase.php @@ -5,11 +5,13 @@ namespace SilverStripe\FullTextSearch\Captures; use SilverStripe\ORM\Connect\MySQLDatabase; use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater; -class SearchManipulateCapture_MySQLDatabase extends MySQLDatabase { +class SearchManipulateCapture_MySQLDatabase extends MySQLDatabase +{ public $isManipulationCapture = true; - public function manipulate($manipulation) { + public function manipulate($manipulation) + { $res = parent::manipulate($manipulation); SearchUpdater::handle_manipulation($manipulation); return $res; diff --git a/code/search/captures/SearchManipulateCapture_PostgreSQLDatabase.php b/code/search/captures/SearchManipulateCapture_PostgreSQLDatabase.php index 12906b3..562b1cd 100644 --- a/code/search/captures/SearchManipulateCapture_PostgreSQLDatabase.php +++ b/code/search/captures/SearchManipulateCapture_PostgreSQLDatabase.php @@ -9,11 +9,13 @@ if (!class_exists('PostgreSQLDatabase')) { return; } -class SearchManipulateCapture_PostgreSQLDatabase extends PostgreSQLDatabase { +class SearchManipulateCapture_PostgreSQLDatabase extends PostgreSQLDatabase +{ public $isManipulationCapture = true; - public function manipulate($manipulation) { + public function manipulate($manipulation) + { $res = parent::manipulate($manipulation); SearchUpdater::handle_manipulation($manipulation); return $res; diff --git a/code/search/captures/SearchManipulateCapture_SQLite3Database.php b/code/search/captures/SearchManipulateCapture_SQLite3Database.php index 989b526..a3e4be0 100644 --- a/code/search/captures/SearchManipulateCapture_SQLite3Database.php +++ b/code/search/captures/SearchManipulateCapture_SQLite3Database.php @@ -9,11 +9,13 @@ if (!class_exists('SQLite3Database')) { return; } -class SearchManipulateCapture_SQLite3Database extends SQLite3Database { +class SearchManipulateCapture_SQLite3Database extends SQLite3Database +{ public $isManipulationCapture = true; - public function manipulate($manipulation) { + public function manipulate($manipulation) + { $res = parent::manipulate($manipulation); SearchUpdater::handle_manipulation($manipulation); return $res; diff --git a/code/search/processors/SearchUpdateBatchedProcessor.php b/code/search/processors/SearchUpdateBatchedProcessor.php index 78166da..7eca39f 100644 --- a/code/search/processors/SearchUpdateBatchedProcessor.php +++ b/code/search/processors/SearchUpdateBatchedProcessor.php @@ -26,7 +26,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor /** * List of indexes successfully comitted in the current batch - * + * * @var array */ protected $completedIndexes; @@ -43,7 +43,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor /** * Up to this number of additional ids can be added to any batch in order to reduce the number * of batches - * + * * @config * @var int */ @@ -59,7 +59,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor /** * Set the current batch index - * + * * @param int $batch Index of the batch */ protected function setBatch($batch) @@ -76,7 +76,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor /** * Process the current queue - * + * * @return boolean */ public function process() @@ -101,7 +101,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor /** * Segments batches acording to the specified rules - * + * * @param array $source Source input * @return array Batches */ diff --git a/code/search/processors/SearchUpdateCommitJobProcessor.php b/code/search/processors/SearchUpdateCommitJobProcessor.php index 122245f..09a96e7 100644 --- a/code/search/processors/SearchUpdateCommitJobProcessor.php +++ b/code/search/processors/SearchUpdateCommitJobProcessor.php @@ -266,7 +266,7 @@ class SearchUpdateCommitJobProcessor implements QueuedJob $this->indexes = $jobData->indexes; } - public function addMessage($message, $severity='INFO') + public function addMessage($message, $severity = 'INFO') { $severity = strtoupper($severity); $this->messages[] = '[' . date('Y-m-d H:i:s') . "][$severity] $message"; diff --git a/code/search/processors/SearchUpdateProcessor.php b/code/search/processors/SearchUpdateProcessor.php index b437f7b..6c27f1d 100644 --- a/code/search/processors/SearchUpdateProcessor.php +++ b/code/search/processors/SearchUpdateProcessor.php @@ -10,7 +10,7 @@ abstract class SearchUpdateProcessor { /** * List of dirty records to process in format - * + * * array( * '$BaseClass' => array( * '$State Key' => array( @@ -62,7 +62,7 @@ abstract class SearchUpdateProcessor /** * Generates the list of indexes to process for the dirty items - * + * * @return array */ protected function prepareIndexes() @@ -112,7 +112,7 @@ abstract class SearchUpdateProcessor /** * Commits the specified index to the Solr service - * + * * @param SolrIndex $index Index object * @return bool Flag indicating success */ @@ -123,7 +123,7 @@ abstract class SearchUpdateProcessor /** * Gets the record data source to process - * + * * @return array */ protected function getSource() @@ -133,7 +133,7 @@ abstract class SearchUpdateProcessor /** * Process all indexes, returning true if successful - * + * * @return bool Flag indicating success */ public function process() diff --git a/code/search/processors/SearchUpdateQueuedJobProcessor.php b/code/search/processors/SearchUpdateQueuedJobProcessor.php index 27eedd4..19a2a06 100644 --- a/code/search/processors/SearchUpdateQueuedJobProcessor.php +++ b/code/search/processors/SearchUpdateQueuedJobProcessor.php @@ -90,7 +90,7 @@ class SearchUpdateQueuedJobProcessor extends SearchUpdateBatchedProcessor implem $this->currentBatch = $jobData->currentBatch; } - public function addMessage($message, $severity='INFO') + public function addMessage($message, $severity = 'INFO') { $severity = strtoupper($severity); $this->messages[] = '[' . date('Y-m-d H:i:s') . "][$severity] $message"; diff --git a/code/search/queries/SearchQuery.php b/code/search/queries/SearchQuery.php index 8fe5f88..8986128 100644 --- a/code/search/queries/SearchQuery.php +++ b/code/search/queries/SearchQuery.php @@ -56,7 +56,7 @@ class SearchQuery extends ViewableData * Similar to {@link search()}, but uses stemming and other similarity algorithms * to find the searched terms. For example, a term "fishing" would also likely find results * containing "fish" or "fisher". Depends on search implementation. - * + * * @param String $text See {@link search()} * @param array $fields See {@link search()} * @param array $boost See {@link search()} @@ -74,7 +74,7 @@ class SearchQuery extends ViewableData /** * Similar to {@link search()}, but typically used to further narrow down * based on other facets which don't influence the field relevancy. - * + * * @param String $field Composite name of the field * @param Mixed $values Scalar value, array of values, or an instance of SearchQuery_Range */ @@ -87,7 +87,7 @@ class SearchQuery extends ViewableData /** * Excludes results which match these criteria, inverse of {@link filter()}. - * + * * @param String $field * @param mixed $values */ @@ -124,5 +124,3 @@ class SearchQuery extends ViewableData return "Search Query\n"; } } - - diff --git a/code/search/queries/SearchQuery_Range.php b/code/search/queries/SearchQuery_Range.php index 33b35e5..6d3b8c3 100644 --- a/code/search/queries/SearchQuery_Range.php +++ b/code/search/queries/SearchQuery_Range.php @@ -31,4 +31,4 @@ class SearchQuery_Range { return $this->start !== null || $this->end !== null; } -} \ No newline at end of file +} diff --git a/code/search/updaters/SearchUpdater.php b/code/search/updaters/SearchUpdater.php index 4a36d1f..2098db3 100644 --- a/code/search/updaters/SearchUpdater.php +++ b/code/search/updaters/SearchUpdater.php @@ -127,8 +127,7 @@ class SearchUpdater 'command' => $command, 'fields' => array() ); - } - // Otherwise update the class label if it's more specific than the currently recorded one + } // Otherwise update the class label if it's more specific than the currently recorded one elseif (is_subclass_of($class, $writes[$key]['class'])) { $writes[$key]['class'] = $class; } diff --git a/code/search/variants/SearchVariant.php b/code/search/variants/SearchVariant.php index 153ec17..b294096 100644 --- a/code/search/variants/SearchVariant.php +++ b/code/search/variants/SearchVariant.php @@ -152,7 +152,7 @@ abstract class SearchVariant * * SearchVariant::call(...) ==== SearchVariant::with()->call(...); */ - public static function call($method, &$a1=null, &$a2=null, &$a3=null, &$a4=null, &$a5=null, &$a6=null, &$a7=null) + public static function call($method, &$a1 = null, &$a2 = null, &$a3 = null, &$a4 = null, &$a5 = null, &$a6 = null, &$a7 = null) { return self::with()->call($method, $a1, $a2, $a3, $a4, $a5, $a6, $a7); } @@ -219,9 +219,10 @@ abstract class SearchVariant * @param string $name Field name * @param array $field Field spec */ - protected function addFilterField($index, $name, $field) { + protected function addFilterField($index, $name, $field) + { // If field already exists, make sure to merge origin / base fields - if(isset($index->filterFields[$name])) { + if (isset($index->filterFields[$name])) { $field['base'] = $this->mergeClasses( $index->filterFields[$name]['base'], $field['base'] @@ -244,21 +245,21 @@ abstract class SearchVariant * @param array|string $right Right class(es) * @return array|string List of classes, or single class */ - protected function mergeClasses($left, $right) { + protected function mergeClasses($left, $right) + { // Merge together and remove dupes - if(!is_array($left)) { + if (!is_array($left)) { $left = array($left); } - if(!is_array($right)) { + if (!is_array($right)) { $right = array($right); } $merged = array_values(array_unique(array_merge($left, $right))); // If there is only one item, return it as a single string - if(count($merged) === 1) { + if (count($merged) === 1) { return reset($merged); } return $merged; } } - diff --git a/code/search/variants/SearchVariantSubsites.php b/code/search/variants/SearchVariantSubsites.php index 0239dbf..5c96ed4 100644 --- a/code/search/variants/SearchVariantSubsites.php +++ b/code/search/variants/SearchVariantSubsites.php @@ -109,12 +109,10 @@ class SearchVariantSubsites extends SearchVariant if (isset($write['fields']['SiteTree:SubsiteID'])) { $subsitesForWrite = array($write['fields']['SiteTree:SubsiteID']); - } - // files in subsite 0 should be in all subsites as they are global + } // files in subsite 0 should be in all subsites as they are global elseif (isset($write['fields']['File:SubsiteID']) && intval($write['fields']['File:SubsiteID']) !== 0) { $subsitesForWrite = array($write['fields']['File:SubsiteID']); - } - else { + } else { $subsitesForWrite = $subsites; } diff --git a/code/search/variants/SearchVariant_Caller.php b/code/search/variants/SearchVariant_Caller.php index b037129..1f0f5d7 100644 --- a/code/search/variants/SearchVariant_Caller.php +++ b/code/search/variants/SearchVariant_Caller.php @@ -14,7 +14,7 @@ class SearchVariant_Caller $this->variants = $variants; } - public function call($method, &$a1=null, &$a2=null, &$a3=null, &$a4=null, &$a5=null, &$a6=null, &$a7=null) + public function call($method, &$a1 = null, &$a2 = null, &$a3 = null, &$a4 = null, &$a5 = null, &$a6 = null, &$a7 = null) { $values = array(); @@ -29,4 +29,4 @@ class SearchVariant_Caller return $values; } -} \ No newline at end of file +} diff --git a/code/solr/Solr.php b/code/solr/Solr.php index 72a1305..f413bb7 100644 --- a/code/solr/Solr.php +++ b/code/solr/Solr.php @@ -121,7 +121,10 @@ class Solr if (!self::$service_singleton) { self::$service_singleton = Object::create( - $options['service'], $options['host'], $options['port'], $options['path'] + $options['service'], + $options['host'], + $options['port'], + $options['path'] ); } diff --git a/code/solr/SolrIndex.php b/code/solr/SolrIndex.php index 68ca165..c23cb06 100644 --- a/code/solr/SolrIndex.php +++ b/code/solr/SolrIndex.php @@ -1,6 +1,7 @@ classIs($class, $nextBase)) { + protected function classIs($class, $base) + { + if (is_array($base)) { + foreach ($base as $nextBase) { + if ($this->classIs($class, $nextBase)) { return true; } } @@ -510,7 +512,7 @@ abstract class SolrIndex extends SearchIndex protected function _addField($doc, $object, $field) { $class = get_class($object); - if(!$this->classIs($class, $field['origin'])) { + if (!$this->classIs($class, $field['origin'])) { return; } diff --git a/code/solr/reindex/handlers/SolrReindexBase.php b/code/solr/reindex/handlers/SolrReindexBase.php index 747fb36..6db01c1 100644 --- a/code/solr/reindex/handlers/SolrReindexBase.php +++ b/code/solr/reindex/handlers/SolrReindexBase.php @@ -34,7 +34,11 @@ abstract class SolrReindexBase implements SolrReindexHandler * @param string $classes */ protected function processIndex( - LoggerInterface $logger, SolrIndex $indexInstance, $batchSize, $taskName, $classes = null + LoggerInterface $logger, + SolrIndex $indexInstance, + $batchSize, + $taskName, + $classes = null ) { // Filter classes for this index $indexClasses = $this->getClassesForIndex($indexInstance, $classes); @@ -87,8 +91,13 @@ abstract class SolrReindexBase implements SolrReindexHandler * @param string $taskName */ protected function processVariant( - LoggerInterface $logger, SolrIndex $indexInstance, $state, - $class, $includeSubclasses, $batchSize, $taskName + LoggerInterface $logger, + SolrIndex $indexInstance, + $state, + $class, + $includeSubclasses, + $batchSize, + $taskName ) { // Set state SearchVariant::activate_state($state); @@ -127,7 +136,13 @@ abstract class SolrReindexBase implements SolrReindexHandler * @param string $taskName Name of task script to run */ abstract protected function processGroup( - LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName + LoggerInterface $logger, + SolrIndex $indexInstance, + $state, + $class, + $groups, + $group, + $taskName ); /** @@ -144,7 +159,12 @@ abstract class SolrReindexBase implements SolrReindexHandler * @param int $group */ public function runGroup( - LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group + LoggerInterface $logger, + SolrIndex $indexInstance, + $state, + $class, + $groups, + $group ) { // Set time limit and state Environment::increaseTimeLimitTo(); diff --git a/code/solr/reindex/handlers/SolrReindexImmediateHandler.php b/code/solr/reindex/handlers/SolrReindexImmediateHandler.php index 9f29c98..06e1980 100644 --- a/code/solr/reindex/handlers/SolrReindexImmediateHandler.php +++ b/code/solr/reindex/handlers/SolrReindexImmediateHandler.php @@ -21,7 +21,11 @@ class SolrReindexImmediateHandler extends SolrReindexBase } protected function processIndex( - LoggerInterface $logger, SolrIndex $indexInstance, $batchSize, $taskName, $classes = null + LoggerInterface $logger, + SolrIndex $indexInstance, + $batchSize, + $taskName, + $classes = null ) { parent::processIndex($logger, $indexInstance, $batchSize, $taskName, $classes); @@ -46,7 +50,13 @@ class SolrReindexImmediateHandler extends SolrReindexBase * @param string $taskName Name of task script to run */ protected function processGroup( - LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName + LoggerInterface $logger, + SolrIndex $indexInstance, + $state, + $class, + $groups, + $group, + $taskName ) { // Build state $statevar = json_encode($state); diff --git a/code/solr/reindex/handlers/SolrReindexQueuedHandler.php b/code/solr/reindex/handlers/SolrReindexQueuedHandler.php index bda7024..d7b9d43 100644 --- a/code/solr/reindex/handlers/SolrReindexQueuedHandler.php +++ b/code/solr/reindex/handlers/SolrReindexQueuedHandler.php @@ -85,12 +85,22 @@ class SolrReindexQueuedHandler extends SolrReindexBase } protected function processGroup( - LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName + LoggerInterface $logger, + SolrIndex $indexInstance, + $state, + $class, + $groups, + $group, + $taskName ) { // Trigger another job for this group $job = Injector::inst()->create( SolrReindexGroupQueuedJob::class, - get_class($indexInstance), $state, $class, $groups, $group + get_class($indexInstance), + $state, + $class, + $groups, + $group ); $this ->getQueuedJobService() @@ -101,7 +111,12 @@ class SolrReindexQueuedHandler extends SolrReindexBase } public function runGroup( - LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group + LoggerInterface $logger, + SolrIndex $indexInstance, + $state, + $class, + $groups, + $group ) { parent::runGroup($logger, $indexInstance, $state, $class, $groups, $group); diff --git a/code/solr/services/Solr3Service_Core.php b/code/solr/services/Solr3Service_Core.php index 15638dc..c2875e0 100644 --- a/code/solr/services/Solr3Service_Core.php +++ b/code/solr/services/Solr3Service_Core.php @@ -2,7 +2,6 @@ namespace SilverStripe\FullTextSearch\Solr\Services; - class Solr3Service_Core extends SolrService_Core { } diff --git a/code/solr/services/Solr4Service_Core.php b/code/solr/services/Solr4Service_Core.php index 056c658..729369e 100644 --- a/code/solr/services/Solr4Service_Core.php +++ b/code/solr/services/Solr4Service_Core.php @@ -25,8 +25,12 @@ class Solr4Service_Core extends SolrService_Core * @inheritdoc * @see Solr4Service_Core::addDocuments */ - public function addDocument(\Apache_Solr_Document $document, $allowDups = false, - $overwritePending = true, $overwriteCommitted = true, $commitWithin = 0 + public function addDocument( + \Apache_Solr_Document $document, + $allowDups = false, + $overwritePending = true, + $overwriteCommitted = true, + $commitWithin = 0 ) { return $this->addDocuments(array($document), $allowDups, $overwritePending, $overwriteCommitted, $commitWithin); } @@ -35,8 +39,12 @@ class Solr4Service_Core extends SolrService_Core * Solr 4.0 compat http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22add.22 * Remove allowDups, overwritePending and overwriteComitted */ - public function addDocuments($documents, $allowDups = false, $overwritePending = true, - $overwriteCommitted = true, $commitWithin = 0 + public function addDocuments( + $documents, + $allowDups = false, + $overwritePending = true, + $overwriteCommitted = true, + $commitWithin = 0 ) { $overwriteVal = $allowDups ? 'false' : 'true'; $commitWithin = (int) $commitWithin; diff --git a/code/solr/stores/SolrConfigStore.php b/code/solr/stores/SolrConfigStore.php index 7e2e025..a153f2e 100644 --- a/code/solr/stores/SolrConfigStore.php +++ b/code/solr/stores/SolrConfigStore.php @@ -1,5 +1,6 @@ remote.'/'.$index; } -} \ No newline at end of file +} diff --git a/code/solr/tasks/Solr_BuildTask.php b/code/solr/tasks/Solr_BuildTask.php index 9e4e3c9..578f1e0 100644 --- a/code/solr/tasks/Solr_BuildTask.php +++ b/code/solr/tasks/Solr_BuildTask.php @@ -1,9 +1,11 @@ isInstantiable()) { diff --git a/code/utils/MultipleArrayIterator.php b/code/utils/MultipleArrayIterator.php index d7d1185..7b4a530 100644 --- a/code/utils/MultipleArrayIterator.php +++ b/code/utils/MultipleArrayIterator.php @@ -1,6 +1,8 @@ 'Varchar' diff --git a/tests/SearchUpdaterTest.php b/tests/SearchUpdaterTest.php index c56764f..a89077f 100644 --- a/tests/SearchUpdaterTest.php +++ b/tests/SearchUpdaterTest.php @@ -1,16 +1,18 @@ getAdded(array('ID')); // Some databases don't output $added in a consistent order; that's okay - usort($added, function ($a, $b) {return $a['ID']-$b['ID']; }); + usort($added, function ($a, $b) { + return $a['ID']-$b['ID']; + }); $this->assertEquals($added, array( array('ID' => $container1->ID), @@ -93,7 +97,9 @@ class SearchUpdaterTest extends SapphireTest $added = self::$index->getAdded(array('ID')); // Some databases don't output $added in a consistent order; that's okay - usort($added, function ($a, $b) {return $a['ID']-$b['ID']; }); + usort($added, function ($a, $b) { + return $a['ID']-$b['ID']; + }); $this->assertEquals($added, array( array('ID' => $container1->ID), diff --git a/tests/SearchVariantSiteTreeSubsitesPolyhomeTest.php b/tests/SearchVariantSiteTreeSubsitesPolyhomeTest.php index 892619f..49cd4ce 100644 --- a/tests/SearchVariantSiteTreeSubsitesPolyhomeTest.php +++ b/tests/SearchVariantSiteTreeSubsitesPolyhomeTest.php @@ -1,13 +1,13 @@ assertEquals(2, $query->require['_subsite'][0]); - } - } diff --git a/tests/SearchVariantVersionedTest.php b/tests/SearchVariantVersionedTest.php index 37c28c9..133d01b 100644 --- a/tests/SearchVariantVersionedTest.php +++ b/tests/SearchVariantVersionedTest.php @@ -1,8 +1,10 @@ hasOneComponent($object->getClassName(), 'Subsite')) { + if (class_exists('Subsite') && DataObject::getSchema()->hasOneComponent($object->getClassName(), 'Subsite')) { $variants[] = '"SearchVariantSubsites":"' . $subsiteID. '"'; } // Check versioned - if($stage) { + if ($stage) { $variants[] = '"SearchVariantVersioned":"' . $stage . '"'; } - return $id.'-'.$class.'-{'.implode(',',$variants).'}'; + return $id.'-'.$class.'-{'.implode(',', $variants).'}'; } public function testPublishing() @@ -127,10 +130,10 @@ class SolrIndexSubsitesTest extends SapphireTest { )); \Phockito::verify($serviceMock)->addDocument($doc1); \Phockito::verify($serviceMock)->addDocument($doc2); - } - public function testCorrectSubsiteIDOnPageWrite() { + public function testCorrectSubsiteIDOnPageWrite() + { $mockWrites = array( '3367:SiteTree:a:1:{s:22:"SearchVariantVersioned";s:4:"Live";}' => array( 'base' => 'SiteTree', @@ -169,7 +172,7 @@ class SolrIndexSubsitesTest extends SapphireTest { $variant = new SearchVariantSubsites(); $tmpMockWrites = $mockWrites; $variant->extractManipulationWriteState($tmpMockWrites); - foreach($tmpMockWrites as $mockWrite) { + foreach ($tmpMockWrites as $mockWrite) { $this->assertCount(1, $mockWrite['statefulids']); $statefulIDs = array_shift($mockWrite['statefulids']); $this->assertEquals(0, $statefulIDs['state']['SearchVariantSubsites']); @@ -180,14 +183,15 @@ class SolrIndexSubsitesTest extends SapphireTest { $tmpMockWrites['3367:SiteTree:a:1:{s:22:"SearchVariantVersioned";s:4:"Live";}']['fields']['SiteTree:SubsiteID'] = $subsite->ID; $variant->extractManipulationWriteState($tmpMockWrites); - foreach($tmpMockWrites as $mockWrite) { + foreach ($tmpMockWrites as $mockWrite) { $this->assertCount(1, $mockWrite['statefulids']); $statefulIDs = array_shift($mockWrite['statefulids']); $this->assertEquals($subsite->ID, $statefulIDs['state']['SearchVariantSubsites']); } } - public function testCorrectSubsiteIDOnFileWrite() { + public function testCorrectSubsiteIDOnFileWrite() + { $subsiteIDs = array('0') + $this->allFixtureIDs('Subsite'); $mockWrites = array( '35910:File:a:0:{}' => array( @@ -217,7 +221,7 @@ class SolrIndexSubsitesTest extends SapphireTest { $variant = new SearchVariantSubsites(); $tmpMockWrites = $mockWrites; $variant->extractManipulationWriteState($tmpMockWrites); - foreach($tmpMockWrites as $mockWrite) { + foreach ($tmpMockWrites as $mockWrite) { $this->assertCount(count($subsiteIDs), $mockWrite['statefulids']); foreach ($mockWrite['statefulids'] as $statefulIDs) { $this->assertTrue( @@ -232,11 +236,10 @@ class SolrIndexSubsitesTest extends SapphireTest { $tmpMockWrites['35910:File:a:0:{}']['fields']['File:SubsiteID'] = $subsite->ID; $variant->extractManipulationWriteState($tmpMockWrites); - foreach($tmpMockWrites as $mockWrite) { + foreach ($tmpMockWrites as $mockWrite) { $this->assertCount(1, $mockWrite['statefulids']); $statefulIDs = array_shift($mockWrite['statefulids']); $this->assertEquals($subsite->ID, $statefulIDs['state']['SearchVariantSubsites']); } } - } diff --git a/tests/SolrIndexTest.php b/tests/SolrIndexTest.php index 24cb994..50c276d 100644 --- a/tests/SolrIndexTest.php +++ b/tests/SolrIndexTest.php @@ -1,5 +1,8 @@ expects($this->exactly(2)) ->method('search') - ->withConsecutive([ + ->withConsecutive( + [ $this->equalTo('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)'), $this->anything(), $this->anything(), diff --git a/tests/SolrIndexVersionedTest.php b/tests/SolrIndexVersionedTest.php index 35ba3b2..50c004c 100644 --- a/tests/SolrIndexVersionedTest.php +++ b/tests/SolrIndexVersionedTest.php @@ -1,5 +1,7 @@ hasOneComponent($object->getClassName(), 'Subsite')) { + if (class_exists('Subsite') && DataObject::getSchema()->hasOneComponent($object->getClassName(), 'Subsite')) { $subsites = '"SearchVariantSubsites":"0",'; } return $id.'-'.$class.'-{'.$subsites. json_encode(SearchVariantVersioned::class) . ':"'.$stage.'"}'; diff --git a/tests/SolrIndexVersionedTest/SolrIndexVersionedTest_Object.php b/tests/SolrIndexVersionedTest/SolrIndexVersionedTest_Object.php index dfa0268..5390c0e 100644 --- a/tests/SolrIndexVersionedTest/SolrIndexVersionedTest_Object.php +++ b/tests/SolrIndexVersionedTest/SolrIndexVersionedTest_Object.php @@ -9,7 +9,8 @@ use SilverStripe\Versioned\Versioned; /** * Non-sitetree versioned dataobject */ -class SolrIndexVersionedTest_Object extends DataObject implements TestOnly { +class SolrIndexVersionedTest_Object extends DataObject implements TestOnly +{ private static $table_name = 'SolrIndexVersionedTest_Object'; diff --git a/tests/SolrReindexQueuedTest.php b/tests/SolrReindexQueuedTest.php index 42ce09c..243ddd7 100644 --- a/tests/SolrReindexQueuedTest.php +++ b/tests/SolrReindexQueuedTest.php @@ -1,5 +1,7 @@ filtersOnID()) { diff --git a/tests/SolrReindexTest/SolrReindexTest_TestHandler.php b/tests/SolrReindexTest/SolrReindexTest_TestHandler.php index fd86b88..7cf22b7 100644 --- a/tests/SolrReindexTest/SolrReindexTest_TestHandler.php +++ b/tests/SolrReindexTest/SolrReindexTest_TestHandler.php @@ -12,7 +12,13 @@ use SilverStripe\FullTextSearch\Solr\SolrIndex; class SolrReindexTest_TestHandler extends SolrReindexBase { public function processGroup( - LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName + LoggerInterface $logger, + SolrIndex $indexInstance, + $state, + $class, + $groups, + $group, + $taskName ) { $indexName = $indexInstance->getIndexName(); $stateName = json_encode($state);