Merge pull request #29 from hafriedlander/fix/tests

Make tests run
This commit is contained in:
Mateusz U 2013-09-10 20:06:48 -07:00
commit d8ed515fc7
7 changed files with 24 additions and 19 deletions

View File

@ -6,12 +6,11 @@ php:
env:
- DB=MYSQL CORE_RELEASE=3.1
- DB=PGSQL CORE_RELEASE=master
matrix:
include:
- php: 5.4
env: DB=MYSQL CORE_RELEASE=master
- php: 5.3
env: DB=PGSQL CORE_RELEASE=3.1
before_script:
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support

View File

@ -464,13 +464,13 @@ abstract class SearchIndex extends ViewableData {
foreach ($derivation['chain'] as $step) {
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);
$ids = $sql->execute()->column();
}
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'].'"');
singleton($step['class'])->extend('augmentSQL', $sql);

View File

@ -13,6 +13,7 @@
"silverstripe/framework": "~3.1"
},
"require-dev": {
"silverstripe/cms": "~3.1",
"hafriedlander/silverstripe-phockito": "*"
},
"minimum-stability": "dev"

View File

@ -1,39 +1,39 @@
<?php
class SearchUpdaterTest_Container extends DataObject {
static $db = array(
private static $db = array(
'Field1' => 'Varchar',
'Field2' => 'Varchar',
'MyDate' => 'Date',
);
static $has_one = array(
private static $has_one = array(
'HasOneObject' => 'SearchUpdaterTest_HasOne'
);
static $has_many = array(
private static $has_many = array(
'HasManyObjects' => 'SearchUpdaterTest_HasMany'
);
}
class SearchUpdaterTest_HasOne extends DataObject {
static $db = array(
private static $db = array(
'Field1' => 'Varchar',
'Field2' => 'Varchar'
);
static $has_many = array(
private static $has_many = array(
'HasManyContainers' => 'SearchUpdaterTest_Container'
);
}
class SearchUpdaterTest_HasMany extends DataObject {
static $db = array(
private static $db = array(
'Field1' => 'Varchar',
'Field2' => 'Varchar'
);
static $has_one = array(
private static $has_one = array(
'HasManyContainer' => 'SearchUpdaterTest_Container'
);
}
@ -50,6 +50,8 @@ class SearchUpdaterTest_Index extends SearchIndex_Recording {
class SearchUpdaterTest extends SapphireTest {
protected $usesDatabase = true;
private static $index = null;
function setUp() {
@ -72,6 +74,8 @@ class SearchUpdaterTest extends SapphireTest {
function tearDown() {
Config::unnest();
parent::tearDown();
}
function testBasic() {

View File

@ -2,7 +2,7 @@
class SearchVariantSiteTreeSubsitesPolyhomeTest_Item extends SiteTree {
// TODO: Currently theres a failure if you addClass a non-table class
static $db = array(
private static $db = array(
'TestText' => 'Varchar'
);
}

View File

@ -2,7 +2,7 @@
class SearchVariantVersionedTest_Item extends SiteTree {
// TODO: Currently theres a failure if you addClass a non-table class
static $db = array(
private static $db = array(
'TestText' => 'Varchar'
);
}

View File

@ -18,7 +18,7 @@ class SolrIndexTest extends SapphireTest {
function testBoost() {
$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->setService($serviceMock);
@ -31,7 +31,7 @@ class SolrIndexTest extends SapphireTest {
);
$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() {
@ -58,8 +58,9 @@ class SolrIndexTest extends SapphireTest {
}
function testAddFieldExtraOptions() {
$origMode = Director::get_environment_type();
Director::set_environment_type('live'); // dev mode would for stored=true for everything
Config::inst()->nest();
Config::inst()->update('Director', 'environment_type', 'live'); // dev mode sets stored=true for everything
$index = new SolrIndexTest_FakeIndex();
$defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
@ -71,7 +72,7 @@ class SolrIndexTest extends SapphireTest {
$defField1 = $defs->xpath('field[@name="SearchUpdaterTest_Container_Field1"]');
$this->assertEquals((string)$defField1[0]['stored'], 'true');
Director::set_environment_type($origMode);
Config::inst()->unnest();
}
function testAddAnalyzer() {