mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
commit
d8ed515fc7
@ -6,12 +6,11 @@ php:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
- DB=MYSQL CORE_RELEASE=3.1
|
- DB=MYSQL CORE_RELEASE=3.1
|
||||||
- DB=PGSQL CORE_RELEASE=master
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.4
|
- php: 5.3
|
||||||
env: DB=MYSQL CORE_RELEASE=master
|
env: DB=PGSQL CORE_RELEASE=3.1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
||||||
|
@ -464,13 +464,13 @@ abstract class SearchIndex extends ViewableData {
|
|||||||
|
|
||||||
foreach ($derivation['chain'] as $step) {
|
foreach ($derivation['chain'] as $step) {
|
||||||
if ($step['through'] == 'has_one') {
|
if ($step['through'] == 'has_one') {
|
||||||
$sql = new SQLQuery('ID', $step['class'], $step['foreignkey'].' IN ('.implode(',', $ids).')');
|
$sql = new SQLQuery('"ID"', '"'.$step['class'].'"', '"'.$step['foreignkey'].'" IN ('.implode(',', $ids).')');
|
||||||
singleton($step['class'])->extend('augmentSQL', $sql);
|
singleton($step['class'])->extend('augmentSQL', $sql);
|
||||||
|
|
||||||
$ids = $sql->execute()->column();
|
$ids = $sql->execute()->column();
|
||||||
}
|
}
|
||||||
else if ($step['through'] == 'has_many') {
|
else if ($step['through'] == 'has_many') {
|
||||||
$sql = new SQLQuery('"'.$step['class'].'"."ID"', $step['class'], '"'.$step['otherclass'].'"."ID" IN ('.implode(',', $ids).')');
|
$sql = new SQLQuery('"'.$step['class'].'"."ID"', '"'.$step['class'].'"', '"'.$step['otherclass'].'"."ID" IN ('.implode(',', $ids).')');
|
||||||
$sql->addInnerJoin($step['otherclass'], '"'.$step['class'].'"."ID" = "'.$step['otherclass'].'"."'.$step['foreignkey'].'"');
|
$sql->addInnerJoin($step['otherclass'], '"'.$step['class'].'"."ID" = "'.$step['otherclass'].'"."'.$step['foreignkey'].'"');
|
||||||
singleton($step['class'])->extend('augmentSQL', $sql);
|
singleton($step['class'])->extend('augmentSQL', $sql);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"silverstripe/framework": "~3.1"
|
"silverstripe/framework": "~3.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"silverstripe/cms": "~3.1",
|
||||||
"hafriedlander/silverstripe-phockito": "*"
|
"hafriedlander/silverstripe-phockito": "*"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev"
|
"minimum-stability": "dev"
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class SearchUpdaterTest_Container extends DataObject {
|
class SearchUpdaterTest_Container extends DataObject {
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'Field1' => 'Varchar',
|
'Field1' => 'Varchar',
|
||||||
'Field2' => 'Varchar',
|
'Field2' => 'Varchar',
|
||||||
'MyDate' => 'Date',
|
'MyDate' => 'Date',
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_one = array(
|
private static $has_one = array(
|
||||||
'HasOneObject' => 'SearchUpdaterTest_HasOne'
|
'HasOneObject' => 'SearchUpdaterTest_HasOne'
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_many = array(
|
private static $has_many = array(
|
||||||
'HasManyObjects' => 'SearchUpdaterTest_HasMany'
|
'HasManyObjects' => 'SearchUpdaterTest_HasMany'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SearchUpdaterTest_HasOne extends DataObject {
|
class SearchUpdaterTest_HasOne extends DataObject {
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'Field1' => 'Varchar',
|
'Field1' => 'Varchar',
|
||||||
'Field2' => 'Varchar'
|
'Field2' => 'Varchar'
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_many = array(
|
private static $has_many = array(
|
||||||
'HasManyContainers' => 'SearchUpdaterTest_Container'
|
'HasManyContainers' => 'SearchUpdaterTest_Container'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SearchUpdaterTest_HasMany extends DataObject {
|
class SearchUpdaterTest_HasMany extends DataObject {
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'Field1' => 'Varchar',
|
'Field1' => 'Varchar',
|
||||||
'Field2' => 'Varchar'
|
'Field2' => 'Varchar'
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_one = array(
|
private static $has_one = array(
|
||||||
'HasManyContainer' => 'SearchUpdaterTest_Container'
|
'HasManyContainer' => 'SearchUpdaterTest_Container'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -50,6 +50,8 @@ class SearchUpdaterTest_Index extends SearchIndex_Recording {
|
|||||||
|
|
||||||
class SearchUpdaterTest extends SapphireTest {
|
class SearchUpdaterTest extends SapphireTest {
|
||||||
|
|
||||||
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
private static $index = null;
|
private static $index = null;
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
@ -72,6 +74,8 @@ class SearchUpdaterTest extends SapphireTest {
|
|||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
Config::unnest();
|
Config::unnest();
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testBasic() {
|
function testBasic() {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
class SearchVariantSiteTreeSubsitesPolyhomeTest_Item extends SiteTree {
|
class SearchVariantSiteTreeSubsitesPolyhomeTest_Item extends SiteTree {
|
||||||
// TODO: Currently theres a failure if you addClass a non-table class
|
// TODO: Currently theres a failure if you addClass a non-table class
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'TestText' => 'Varchar'
|
'TestText' => 'Varchar'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
class SearchVariantVersionedTest_Item extends SiteTree {
|
class SearchVariantVersionedTest_Item extends SiteTree {
|
||||||
// TODO: Currently theres a failure if you addClass a non-table class
|
// TODO: Currently theres a failure if you addClass a non-table class
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'TestText' => 'Varchar'
|
'TestText' => 'Varchar'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class SolrIndexTest extends SapphireTest {
|
|||||||
|
|
||||||
function testBoost() {
|
function testBoost() {
|
||||||
$serviceMock = $this->getServiceMock();
|
$serviceMock = $this->getServiceMock();
|
||||||
Phockito::when($serviceMock)->search()->return($this->getFakeRawSolrResponse());
|
Phockito::when($serviceMock)->search(anything(), anything(), anything(), anything(), anything())->return($this->getFakeRawSolrResponse());
|
||||||
|
|
||||||
$index = new SolrIndexTest_FakeIndex();
|
$index = new SolrIndexTest_FakeIndex();
|
||||||
$index->setService($serviceMock);
|
$index->setService($serviceMock);
|
||||||
@ -31,7 +31,7 @@ class SolrIndexTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
$index->search($query);
|
$index->search($query);
|
||||||
|
|
||||||
Phockito::verify($serviceMock)->search('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)');
|
Phockito::verify($serviceMock)->search('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)', anything(), anything(), anything(), anything());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testIndexExcludesNullValues() {
|
function testIndexExcludesNullValues() {
|
||||||
@ -58,8 +58,9 @@ class SolrIndexTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testAddFieldExtraOptions() {
|
function testAddFieldExtraOptions() {
|
||||||
$origMode = Director::get_environment_type();
|
Config::inst()->nest();
|
||||||
Director::set_environment_type('live'); // dev mode would for stored=true for everything
|
Config::inst()->update('Director', 'environment_type', 'live'); // dev mode sets stored=true for everything
|
||||||
|
|
||||||
$index = new SolrIndexTest_FakeIndex();
|
$index = new SolrIndexTest_FakeIndex();
|
||||||
|
|
||||||
$defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
|
$defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
|
||||||
@ -71,7 +72,7 @@ class SolrIndexTest extends SapphireTest {
|
|||||||
$defField1 = $defs->xpath('field[@name="SearchUpdaterTest_Container_Field1"]');
|
$defField1 = $defs->xpath('field[@name="SearchUpdaterTest_Container_Field1"]');
|
||||||
$this->assertEquals((string)$defField1[0]['stored'], 'true');
|
$this->assertEquals((string)$defField1[0]['stored'], 'true');
|
||||||
|
|
||||||
Director::set_environment_type($origMode);
|
Config::inst()->unnest();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAddAnalyzer() {
|
function testAddAnalyzer() {
|
||||||
|
Loading…
Reference in New Issue
Block a user