FIX Run phpcbf automated linting to fix PSR-2 code styles, add PSR-4 autoloader

This commit is contained in:
Robbie Averill 2017-11-15 09:48:52 +13:00
parent 1080d6444a
commit e590132967
44 changed files with 208 additions and 112 deletions

View File

@ -1,7 +1,9 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Search; namespace SilverStripe\FullTextSearch\Search;
use SilverStripe\Core\ClassInfo; use SilverStripe\Core\ClassInfo;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
/** /**
* Some additional introspection tools that are used often by the fulltext search code * Some additional introspection tools that are used often by the fulltext search code
*/ */

View File

@ -5,11 +5,13 @@ namespace SilverStripe\FullTextSearch\Captures;
use SilverStripe\ORM\Connect\MySQLDatabase; use SilverStripe\ORM\Connect\MySQLDatabase;
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater; use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
class SearchManipulateCapture_MySQLDatabase extends MySQLDatabase { class SearchManipulateCapture_MySQLDatabase extends MySQLDatabase
{
public $isManipulationCapture = true; public $isManipulationCapture = true;
public function manipulate($manipulation) { public function manipulate($manipulation)
{
$res = parent::manipulate($manipulation); $res = parent::manipulate($manipulation);
SearchUpdater::handle_manipulation($manipulation); SearchUpdater::handle_manipulation($manipulation);
return $res; return $res;

View File

@ -9,11 +9,13 @@ if (!class_exists('PostgreSQLDatabase')) {
return; return;
} }
class SearchManipulateCapture_PostgreSQLDatabase extends PostgreSQLDatabase { class SearchManipulateCapture_PostgreSQLDatabase extends PostgreSQLDatabase
{
public $isManipulationCapture = true; public $isManipulationCapture = true;
public function manipulate($manipulation) { public function manipulate($manipulation)
{
$res = parent::manipulate($manipulation); $res = parent::manipulate($manipulation);
SearchUpdater::handle_manipulation($manipulation); SearchUpdater::handle_manipulation($manipulation);
return $res; return $res;

View File

@ -9,11 +9,13 @@ if (!class_exists('SQLite3Database')) {
return; return;
} }
class SearchManipulateCapture_SQLite3Database extends SQLite3Database { class SearchManipulateCapture_SQLite3Database extends SQLite3Database
{
public $isManipulationCapture = true; public $isManipulationCapture = true;
public function manipulate($manipulation) { public function manipulate($manipulation)
{
$res = parent::manipulate($manipulation); $res = parent::manipulate($manipulation);
SearchUpdater::handle_manipulation($manipulation); SearchUpdater::handle_manipulation($manipulation);
return $res; return $res;

View File

@ -124,5 +124,3 @@ class SearchQuery extends ViewableData
return "Search Query\n"; return "Search Query\n";
} }
} }

View File

@ -127,8 +127,7 @@ class SearchUpdater
'command' => $command, 'command' => $command,
'fields' => array() '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'])) { elseif (is_subclass_of($class, $writes[$key]['class'])) {
$writes[$key]['class'] = $class; $writes[$key]['class'] = $class;
} }

View File

@ -219,7 +219,8 @@ abstract class SearchVariant
* @param string $name Field name * @param string $name Field name
* @param array $field Field spec * @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 field already exists, make sure to merge origin / base fields
if (isset($index->filterFields[$name])) { if (isset($index->filterFields[$name])) {
$field['base'] = $this->mergeClasses( $field['base'] = $this->mergeClasses(
@ -244,7 +245,8 @@ abstract class SearchVariant
* @param array|string $right Right class(es) * @param array|string $right Right class(es)
* @return array|string List of classes, or single class * @return array|string List of classes, or single class
*/ */
protected function mergeClasses($left, $right) { protected function mergeClasses($left, $right)
{
// Merge together and remove dupes // Merge together and remove dupes
if (!is_array($left)) { if (!is_array($left)) {
$left = array($left); $left = array($left);
@ -261,4 +263,3 @@ abstract class SearchVariant
return $merged; return $merged;
} }
} }

View File

@ -109,12 +109,10 @@ class SearchVariantSubsites extends SearchVariant
if (isset($write['fields']['SiteTree:SubsiteID'])) { if (isset($write['fields']['SiteTree:SubsiteID'])) {
$subsitesForWrite = array($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) { elseif (isset($write['fields']['File:SubsiteID']) && intval($write['fields']['File:SubsiteID']) !== 0) {
$subsitesForWrite = array($write['fields']['File:SubsiteID']); $subsitesForWrite = array($write['fields']['File:SubsiteID']);
} } else {
else {
$subsitesForWrite = $subsites; $subsitesForWrite = $subsites;
} }

View File

@ -121,7 +121,10 @@ class Solr
if (!self::$service_singleton) { if (!self::$service_singleton) {
self::$service_singleton = Object::create( self::$service_singleton = Object::create(
$options['service'], $options['host'], $options['port'], $options['path'] $options['service'],
$options['host'],
$options['port'],
$options['path']
); );
} }

View File

@ -1,6 +1,7 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Solr; namespace SilverStripe\FullTextSearch\Solr;
Solr::include_client_api(); Solr::include_client_api();
use SilverStripe\Control\Director; use SilverStripe\Control\Director;
@ -493,7 +494,8 @@ abstract class SolrIndex extends SearchIndex
* @param array|string $base Class or list of base classes * @param array|string $base Class or list of base classes
* @return bool * @return bool
*/ */
protected function classIs($class, $base) { protected function classIs($class, $base)
{
if (is_array($base)) { if (is_array($base)) {
foreach ($base as $nextBase) { foreach ($base as $nextBase) {
if ($this->classIs($class, $nextBase)) { if ($this->classIs($class, $nextBase)) {

View File

@ -34,7 +34,11 @@ abstract class SolrReindexBase implements SolrReindexHandler
* @param string $classes * @param string $classes
*/ */
protected function processIndex( protected function processIndex(
LoggerInterface $logger, SolrIndex $indexInstance, $batchSize, $taskName, $classes = null LoggerInterface $logger,
SolrIndex $indexInstance,
$batchSize,
$taskName,
$classes = null
) { ) {
// Filter classes for this index // Filter classes for this index
$indexClasses = $this->getClassesForIndex($indexInstance, $classes); $indexClasses = $this->getClassesForIndex($indexInstance, $classes);
@ -87,8 +91,13 @@ abstract class SolrReindexBase implements SolrReindexHandler
* @param string $taskName * @param string $taskName
*/ */
protected function processVariant( protected function processVariant(
LoggerInterface $logger, SolrIndex $indexInstance, $state, LoggerInterface $logger,
$class, $includeSubclasses, $batchSize, $taskName SolrIndex $indexInstance,
$state,
$class,
$includeSubclasses,
$batchSize,
$taskName
) { ) {
// Set state // Set state
SearchVariant::activate_state($state); SearchVariant::activate_state($state);
@ -127,7 +136,13 @@ abstract class SolrReindexBase implements SolrReindexHandler
* @param string $taskName Name of task script to run * @param string $taskName Name of task script to run
*/ */
abstract protected function processGroup( 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 * @param int $group
*/ */
public function runGroup( public function runGroup(
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
Environment::increaseTimeLimitTo(); Environment::increaseTimeLimitTo();

View File

@ -21,7 +21,11 @@ class SolrReindexImmediateHandler extends SolrReindexBase
} }
protected function processIndex( 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); parent::processIndex($logger, $indexInstance, $batchSize, $taskName, $classes);
@ -46,7 +50,13 @@ class SolrReindexImmediateHandler extends SolrReindexBase
* @param string $taskName Name of task script to run * @param string $taskName Name of task script to run
*/ */
protected function processGroup( protected function processGroup(
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName LoggerInterface $logger,
SolrIndex $indexInstance,
$state,
$class,
$groups,
$group,
$taskName
) { ) {
// Build state // Build state
$statevar = json_encode($state); $statevar = json_encode($state);

View File

@ -85,12 +85,22 @@ class SolrReindexQueuedHandler extends SolrReindexBase
} }
protected function processGroup( 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 // Trigger another job for this group
$job = Injector::inst()->create( $job = Injector::inst()->create(
SolrReindexGroupQueuedJob::class, SolrReindexGroupQueuedJob::class,
get_class($indexInstance), $state, $class, $groups, $group get_class($indexInstance),
$state,
$class,
$groups,
$group
); );
$this $this
->getQueuedJobService() ->getQueuedJobService()
@ -101,7 +111,12 @@ class SolrReindexQueuedHandler extends SolrReindexBase
} }
public function runGroup( 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); parent::runGroup($logger, $indexInstance, $state, $class, $groups, $group);

View File

@ -2,7 +2,6 @@
namespace SilverStripe\FullTextSearch\Solr\Services; namespace SilverStripe\FullTextSearch\Solr\Services;
class Solr3Service_Core extends SolrService_Core class Solr3Service_Core extends SolrService_Core
{ {
} }

View File

@ -25,8 +25,12 @@ class Solr4Service_Core extends SolrService_Core
* @inheritdoc * @inheritdoc
* @see Solr4Service_Core::addDocuments * @see Solr4Service_Core::addDocuments
*/ */
public function addDocument(\Apache_Solr_Document $document, $allowDups = false, public function addDocument(
$overwritePending = true, $overwriteCommitted = true, $commitWithin = 0 \Apache_Solr_Document $document,
$allowDups = false,
$overwritePending = true,
$overwriteCommitted = true,
$commitWithin = 0
) { ) {
return $this->addDocuments(array($document), $allowDups, $overwritePending, $overwriteCommitted, $commitWithin); 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 * Solr 4.0 compat http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22add.22
* Remove allowDups, overwritePending and overwriteComitted * Remove allowDups, overwritePending and overwriteComitted
*/ */
public function addDocuments($documents, $allowDups = false, $overwritePending = true, public function addDocuments(
$overwriteCommitted = true, $commitWithin = 0 $documents,
$allowDups = false,
$overwritePending = true,
$overwriteCommitted = true,
$commitWithin = 0
) { ) {
$overwriteVal = $allowDups ? 'false' : 'true'; $overwriteVal = $allowDups ? 'false' : 'true';
$commitWithin = (int) $commitWithin; $commitWithin = (int) $commitWithin;

View File

@ -1,5 +1,6 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Solr\Stores; namespace SilverStripe\FullTextSearch\Solr\Stores;
/** /**
* Class SolrConfigStore * Class SolrConfigStore
* *
@ -30,7 +31,3 @@ interface SolrConfigStore
*/ */
public function instanceDir($index); public function instanceDir($index);
} }

View File

@ -2,7 +2,6 @@
namespace SilverStripe\FullTextSearch\Solr\Stores; namespace SilverStripe\FullTextSearch\Solr\Stores;
/** /**
* Class SolrConfigStore_File * Class SolrConfigStore_File
* *

View File

@ -1,9 +1,11 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Solr\Tasks; namespace SilverStripe\FullTextSearch\Solr\Tasks;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask; use SilverStripe\Dev\BuildTask;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory; use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory;
/** /**
* Abstract class for build tasks * Abstract class for build tasks
*/ */

View File

@ -1,5 +1,6 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Solr\Tasks; namespace SilverStripe\FullTextSearch\Solr\Tasks;
use Exception; use Exception;
use SilverStripe\Core\ClassInfo; use SilverStripe\Core\ClassInfo;
use SilverStripe\FullTextSearch\Solr\Solr; use SilverStripe\FullTextSearch\Solr\Solr;

View File

@ -1,5 +1,6 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Solr\Tasks; namespace SilverStripe\FullTextSearch\Solr\Tasks;
use ReflectionClass; use ReflectionClass;
use SilverStripe\Core\ClassInfo; use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;

View File

@ -1,6 +1,8 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Utils; namespace SilverStripe\FullTextSearch\Utils;
use Iterator; use Iterator;
class MultipleArrayIterator implements Iterator class MultipleArrayIterator implements Iterator
{ {
protected $arrays; protected $arrays;

View File

@ -1,5 +1,6 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Utils; namespace SilverStripe\FullTextSearch\Utils;
class WebDAV class WebDAV
{ {
public static function curl_init($url, $method) public static function curl_init($url, $method)

View File

@ -29,6 +29,12 @@
"phpunit/phpunit": "^5.7", "phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.0" "squizlabs/php_codesniffer": "^3.0"
}, },
"autoload": {
"psr-4": {
"SilverStripe\\FullTextSearch\\": "code/",
"SilverStripe\\FullTextSearch\\Tests\\": "tests/"
}
},
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.x-dev" "dev-master": "3.x-dev"
@ -38,5 +44,5 @@
"silverstripe/fulltextsearch-localsolr": "Adds a ready-to-use local Solr server for initial development" "silverstripe/fulltextsearch-localsolr": "Adds a ready-to-use local Solr server for initial development"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": "true" "prefer-stable": true
} }

View File

@ -1,16 +1,18 @@
<?php <?php
use SilverStripe\Dev\SapphireTest; namespace SilverStripe\FullTextSearch\Tests;
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\FullTextSearch\Search\FullTextSearch; use SilverStripe\FullTextSearch\Search\FullTextSearch;
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateProcessor;
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor;
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Container; use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Container;
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasOne; use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasOne;
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasMany; use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasMany;
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Index; use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Index;
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateProcessor;
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor;
class SearchUpdaterTest extends SapphireTest class SearchUpdaterTest extends SapphireTest
{ {
@ -74,7 +76,9 @@ class SearchUpdaterTest extends SapphireTest
$added = self::$index->getAdded(array('ID')); $added = self::$index->getAdded(array('ID'));
// Some databases don't output $added in a consistent order; that's okay // 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( $this->assertEquals($added, array(
array('ID' => $container1->ID), array('ID' => $container1->ID),
@ -93,7 +97,9 @@ class SearchUpdaterTest extends SapphireTest
$added = self::$index->getAdded(array('ID')); $added = self::$index->getAdded(array('ID'));
// Some databases don't output $added in a consistent order; that's okay // 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( $this->assertEquals($added, array(
array('ID' => $container1->ID), array('ID' => $container1->ID),

View File

@ -1,13 +1,13 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Tests;
use SilverStripe\CMS\Model\SiteTree; use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex_Recording;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex_Recording;
use SilverStripe\FullTextSearch\Tests\SearchVariantSiteTreeSubsitesPolyhomeTest\SearchVariantSiteTreeSubsitesPolyhomeTest_Index; use SilverStripe\FullTextSearch\Tests\SearchVariantSiteTreeSubsitesPolyhomeTest\SearchVariantSiteTreeSubsitesPolyhomeTest_Index;
use SilverStripe\FullTextSearch\Tests\SearchVariantSiteTreeSubsitesPolyhomeTest\SearchVariantSiteTreeSubsitesPolyhomeTest_Item; use SilverStripe\FullTextSearch\Tests\SearchVariantSiteTreeSubsitesPolyhomeTest\SearchVariantSiteTreeSubsitesPolyhomeTest_Item;
class SearchVariantSiteTreeSubsitesPolyhomeTest extends SapphireTest class SearchVariantSiteTreeSubsitesPolyhomeTest extends SapphireTest
{ {
private static $index = null; private static $index = null;

View File

@ -1,5 +1,7 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Tests;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
class SearchVariantSubsiteTest extends SapphireTest class SearchVariantSubsiteTest extends SapphireTest
@ -86,7 +88,5 @@ class SearchVariantSubsiteTest extends SapphireTest
//subsite filter has been modified with our arbitrary test value. The second value is not set //subsite filter has been modified with our arbitrary test value. The second value is not set
//this proves that the query has not been altered by the variant //this proves that the query has not been altered by the variant
$this->assertEquals(2, $query->require['_subsite'][0]); $this->assertEquals(2, $query->require['_subsite'][0]);
} }
} }

View File

@ -1,8 +1,10 @@
<?php <?php
use SilverStripe\Dev\SapphireTest; namespace SilverStripe\FullTextSearch\Tests;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\CMS\Model\SiteTree; use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\FullTextSearch\Search\FullTextSearch; use SilverStripe\FullTextSearch\Search\FullTextSearch;
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex_Recording; use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex_Recording;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariantVersioned; use SilverStripe\FullTextSearch\Search\Variants\SearchVariantVersioned;

View File

@ -16,4 +16,3 @@ class Solr4ServiceTest_RecordingService extends Solr4Service_Core
return $url; return $url;
} }
} }

View File

@ -1,5 +1,7 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Tests;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
use SilverStripe\FullTextSearch\Tests\SolrIndexSubsitesTest\SolrIndexSubsitesTest_Index; use SilverStripe\FullTextSearch\Tests\SolrIndexSubsitesTest\SolrIndexSubsitesTest_Index;
@ -10,7 +12,8 @@ if (class_exists('\Phockito')) {
/** /**
* Subsite specific solr testing * Subsite specific solr testing
*/ */
class SolrIndexSubsitesTest extends SapphireTest { class SolrIndexSubsitesTest extends SapphireTest
{
// @todo // @todo
// protected static $fixture_file = 'SolrIndexSubsitesTest/SolrIndexSubsitesTest.yml'; // protected static $fixture_file = 'SolrIndexSubsitesTest/SolrIndexSubsitesTest.yml';
@ -127,10 +130,10 @@ class SolrIndexSubsitesTest extends SapphireTest {
)); ));
\Phockito::verify($serviceMock)->addDocument($doc1); \Phockito::verify($serviceMock)->addDocument($doc1);
\Phockito::verify($serviceMock)->addDocument($doc2); \Phockito::verify($serviceMock)->addDocument($doc2);
} }
public function testCorrectSubsiteIDOnPageWrite() { public function testCorrectSubsiteIDOnPageWrite()
{
$mockWrites = array( $mockWrites = array(
'3367:SiteTree:a:1:{s:22:"SearchVariantVersioned";s:4:"Live";}' => array( '3367:SiteTree:a:1:{s:22:"SearchVariantVersioned";s:4:"Live";}' => array(
'base' => 'SiteTree', 'base' => 'SiteTree',
@ -187,7 +190,8 @@ class SolrIndexSubsitesTest extends SapphireTest {
} }
} }
public function testCorrectSubsiteIDOnFileWrite() { public function testCorrectSubsiteIDOnFileWrite()
{
$subsiteIDs = array('0') + $this->allFixtureIDs('Subsite'); $subsiteIDs = array('0') + $this->allFixtureIDs('Subsite');
$mockWrites = array( $mockWrites = array(
'35910:File:a:0:{}' => array( '35910:File:a:0:{}' => array(
@ -238,5 +242,4 @@ class SolrIndexSubsitesTest extends SapphireTest {
$this->assertEquals($subsite->ID, $statefulIDs['state']['SearchVariantSubsites']); $this->assertEquals($subsite->ID, $statefulIDs['state']['SearchVariantSubsites']);
} }
} }
} }

View File

@ -1,5 +1,8 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Tests;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Kernel; use SilverStripe\Core\Kernel;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
@ -8,14 +11,13 @@ use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_AmbiguousRelat
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_FakeIndex; use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_FakeIndex;
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_FakeIndex2; use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_FakeIndex2;
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_BoostedIndex; use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_BoostedIndex;
use SilverStripe\FullTextSearch\Solr\Services\Solr3Service;
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Container; use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Container;
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasOne; use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasOne;
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasMany; use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasMany;
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\FullTextSearch\Search\Queries\SearchQuery; use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
use SilverStripe\FullTextSearch\Solr\Services\Solr3Service;
class SolrIndexTest extends SapphireTest class SolrIndexTest extends SapphireTest
{ {
@ -181,7 +183,8 @@ class SolrIndexTest extends SapphireTest
$serviceMock->expects($this->exactly(2)) $serviceMock->expects($this->exactly(2))
->method('search') ->method('search')
->withConsecutive([ ->withConsecutive(
[
$this->equalTo('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)'), $this->equalTo('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)'),
$this->anything(), $this->anything(),
$this->anything(), $this->anything(),

View File

@ -1,5 +1,7 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Tests;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;

View File

@ -9,7 +9,8 @@ use SilverStripe\Versioned\Versioned;
/** /**
* Non-sitetree versioned dataobject * Non-sitetree versioned dataobject
*/ */
class SolrIndexVersionedTest_Object extends DataObject implements TestOnly { class SolrIndexVersionedTest_Object extends DataObject implements TestOnly
{
private static $table_name = 'SolrIndexVersionedTest_Object'; private static $table_name = 'SolrIndexVersionedTest_Object';

View File

@ -1,5 +1,7 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Tests;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;

View File

@ -1,5 +1,7 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Tests;
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\Updaters\SearchUpdater;

View File

@ -20,7 +20,7 @@ class SolrReindexTest_ItemExtension extends DataExtension implements TestOnly
* @param SQLSelect $query * @param SQLSelect $query
* @param DataQuery $dataQuery * @param DataQuery $dataQuery
*/ */
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = NULL) public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
{ {
$variant = SolrReindexTest_Variant::get_current(); $variant = SolrReindexTest_Variant::get_current();
if ($variant !== null && !$query->filtersOnID()) { if ($variant !== null && !$query->filtersOnID()) {

View File

@ -12,7 +12,13 @@ use SilverStripe\FullTextSearch\Solr\SolrIndex;
class SolrReindexTest_TestHandler extends SolrReindexBase class SolrReindexTest_TestHandler extends SolrReindexBase
{ {
public function processGroup( public function processGroup(
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName LoggerInterface $logger,
SolrIndex $indexInstance,
$state,
$class,
$groups,
$group,
$taskName
) { ) {
$indexName = $indexInstance->getIndexName(); $indexName = $indexInstance->getIndexName();
$stateName = json_encode($state); $stateName = json_encode($state);