mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
BUG Fix subsite document ID generation
This commit is contained in:
parent
c39c4b4983
commit
23a1ba6e1a
10
.travis.yml
10
.travis.yml
@ -1,6 +1,7 @@
|
|||||||
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details
|
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details
|
||||||
|
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.3
|
- 5.3
|
||||||
|
|
||||||
@ -11,11 +12,16 @@ matrix:
|
|||||||
include:
|
include:
|
||||||
- php: 5.3
|
- php: 5.3
|
||||||
env: DB=PGSQL CORE_RELEASE=3.1
|
env: DB=PGSQL CORE_RELEASE=3.1
|
||||||
|
- php: 5.3
|
||||||
|
env: DB=MYSQL CORE_RELEASE=3.1 SUBSITES=1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- composer self-update
|
||||||
|
- phpenv rehash
|
||||||
- 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
|
||||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
- "if [ \"$SUBSITES\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
|
||||||
|
- "if [ \"$SUBSITES\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/subsites; fi"
|
||||||
- cd ~/builds/ss
|
- cd ~/builds/ss
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpunit fulltextsearch/tests/
|
- vendor/bin/phpunit fulltextsearch/tests/
|
||||||
|
@ -16,15 +16,15 @@ class SearchVariantSubsites extends SearchVariant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function currentState() {
|
function currentState() {
|
||||||
return Subsite::currentSubsiteID();
|
return (string)Subsite::currentSubsiteID();
|
||||||
}
|
}
|
||||||
|
|
||||||
function reindexStates() {
|
function reindexStates() {
|
||||||
static $ids = null;
|
static $ids = null;
|
||||||
|
|
||||||
if ($ids === null) {
|
if ($ids === null) {
|
||||||
$ids = array(0);
|
$ids = array('0');
|
||||||
foreach (DataObject::get('Subsite') as $subsite) $ids[] = $subsite->ID;
|
foreach (DataObject::get('Subsite') as $subsite) $ids[] = (string)$subsite->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ids;
|
return $ids;
|
||||||
@ -77,7 +77,7 @@ class SearchVariantSubsites extends SearchVariant {
|
|||||||
|
|
||||||
foreach ($write['statefulids'] as $i => $statefulid) {
|
foreach ($write['statefulids'] as $i => $statefulid) {
|
||||||
foreach (self::$subsites as $subsiteID) {
|
foreach (self::$subsites as $subsiteID) {
|
||||||
$next[] = array('id' => $statefulid['id'], 'state' => array_merge($statefulid['state'], array($self => $subsiteID)));
|
$next[] = array('id' => $statefulid['id'], 'state' => array_merge($statefulid['state'], array($self => (string)$subsiteID)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
Users upgrading from 1.0.2 or below will need to run the Solr_Reindex task to refresh
|
Users upgrading from 1.0.2 or below will need to run the Solr_Reindex task to refresh
|
||||||
each SolrIndex. This is due to a change in record IDs, which are now generated from
|
each SolrIndex. This is due to a change in record IDs, which are now generated from
|
||||||
the base class of each DataObject, rather than the instance class.
|
the base class of each DataObject, rather than the instance class, as well as fixes
|
||||||
|
to integration with the subsites module.
|
||||||
|
|
||||||
Developers working locally should be aware that by default, all indexes will be updated
|
Developers working locally should be aware that by default, all indexes will be updated
|
||||||
in realtime when the environment is in dev mode, rather than attempting to queue these
|
in realtime when the environment is in dev mode, rather than attempting to queue these
|
||||||
|
@ -54,6 +54,11 @@ class SolrIndexVersionedTest extends SapphireTest {
|
|||||||
return Phockito::mock('Solr3Service');
|
return Phockito::mock('Solr3Service');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getExpectedDocumentId($id, $stage) {
|
||||||
|
// Prevent subsites from breaking tests
|
||||||
|
$subsites = class_exists('Subsite') ? '"SearchVariantSubsites":"0",' : '';
|
||||||
|
return $id.'-SiteTree-{'.$subsites.'"SearchVariantVersioned":"'.$stage.'"}';
|
||||||
|
}
|
||||||
|
|
||||||
public function testPublishing() {
|
public function testPublishing() {
|
||||||
|
|
||||||
@ -68,7 +73,7 @@ class SolrIndexVersionedTest extends SapphireTest {
|
|||||||
$item->write();
|
$item->write();
|
||||||
SearchUpdater::flush_dirty_indexes();
|
SearchUpdater::flush_dirty_indexes();
|
||||||
$doc = new SolrDocumentMatcher(array(
|
$doc = new SolrDocumentMatcher(array(
|
||||||
'_documentid' => $item->ID.'-SiteTree-{"SearchVariantVersioned":"Stage"}',
|
'_documentid' => $this->getExpectedDocumentId($item->ID, 'Stage'),
|
||||||
'ClassName' => 'SearchVariantVersionedTest_Item'
|
'ClassName' => 'SearchVariantVersionedTest_Item'
|
||||||
));
|
));
|
||||||
Phockito::verify($serviceMock)->addDocument($doc);
|
Phockito::verify($serviceMock)->addDocument($doc);
|
||||||
@ -81,7 +86,7 @@ class SolrIndexVersionedTest extends SapphireTest {
|
|||||||
$item->publish('Stage', 'Live');
|
$item->publish('Stage', 'Live');
|
||||||
SearchUpdater::flush_dirty_indexes();
|
SearchUpdater::flush_dirty_indexes();
|
||||||
$doc = new SolrDocumentMatcher(array(
|
$doc = new SolrDocumentMatcher(array(
|
||||||
'_documentid' => $item->ID.'-SiteTree-{"SearchVariantVersioned":"Live"}',
|
'_documentid' => $this->getExpectedDocumentId($item->ID, 'Live'),
|
||||||
'ClassName' => 'SearchVariantVersionedTest_Item'
|
'ClassName' => 'SearchVariantVersionedTest_Item'
|
||||||
));
|
));
|
||||||
Phockito::verify($serviceMock)->addDocument($doc);
|
Phockito::verify($serviceMock)->addDocument($doc);
|
||||||
@ -104,9 +109,9 @@ class SolrIndexVersionedTest extends SapphireTest {
|
|||||||
$item->delete();
|
$item->delete();
|
||||||
SearchUpdater::flush_dirty_indexes();
|
SearchUpdater::flush_dirty_indexes();
|
||||||
Phockito::verify($serviceMock, 1)
|
Phockito::verify($serviceMock, 1)
|
||||||
->deleteById($id.'-SiteTree-{"SearchVariantVersioned":"Live"}');
|
->deleteById($this->getExpectedDocumentId($id, 'Live'));
|
||||||
Phockito::verify($serviceMock, 0)
|
Phockito::verify($serviceMock, 0)
|
||||||
->deleteById($id.'-SiteTree-{"SearchVariantVersioned":"Stage"}');
|
->deleteById($this->getExpectedDocumentId($id, 'Stage'));
|
||||||
|
|
||||||
// Delete the stage record
|
// Delete the stage record
|
||||||
Versioned::reading_stage('Stage');
|
Versioned::reading_stage('Stage');
|
||||||
@ -118,9 +123,9 @@ class SolrIndexVersionedTest extends SapphireTest {
|
|||||||
$item->delete();
|
$item->delete();
|
||||||
SearchUpdater::flush_dirty_indexes();
|
SearchUpdater::flush_dirty_indexes();
|
||||||
Phockito::verify($serviceMock, 1)
|
Phockito::verify($serviceMock, 1)
|
||||||
->deleteById($id.'-SiteTree-{"SearchVariantVersioned":"Stage"}');
|
->deleteById($this->getExpectedDocumentId($id, 'Stage'));
|
||||||
Phockito::verify($serviceMock, 0)
|
Phockito::verify($serviceMock, 0)
|
||||||
->deleteById($id.'-SiteTree-{"SearchVariantVersioned":"Live"}');
|
->deleteById($this->getExpectedDocumentId($id, 'Live'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user