From 8b5ab77f4226151af7e8d89ce351f237e8ebd90c Mon Sep 17 00:00:00 2001 From: Mateusz Uzdowski Date: Thu, 26 Aug 2010 20:57:53 +0000 Subject: [PATCH] BUGFIX: force the test to wait until indexing completes. Do not use stop words ('me') git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@110130 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- tests/search/SearchFormTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/search/SearchFormTest.php b/tests/search/SearchFormTest.php index 805d2f122..a3b392d0d 100644 --- a/tests/search/SearchFormTest.php +++ b/tests/search/SearchFormTest.php @@ -24,6 +24,11 @@ class SearchFormTest extends FunctionalTest { ), ); + function waitUntilIndexingFinished() { + $db = DB::getConn(); + if (method_exists($db, 'waitUntilIndexingFinished')) DB::getConn()->waitUntilIndexingFinished(); + } + function setUpOnce() { // HACK Postgres doesn't refresh TSearch indexes when the schema changes after CREATE TABLE if(is_a(DB::getConn(), 'PostgreSQLDatabase')) { @@ -38,13 +43,17 @@ class SearchFormTest extends FunctionalTest { $holderPage = $this->objFromFixture('SiteTree', 'searchformholder'); $this->mockController = new ContentController($holderPage); + + $this->waitUntilIndexingFinished(); } - + function testPublishedPagesMatchedByTitle() { $sf = new SearchForm($this->mockController, 'SearchForm'); $publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage'); $publishedPage->publish('Stage', 'Live'); + + $this->waitUntilIndexingFinished(); $results = $sf->getResults(null, array('Search'=>'publicPublishedPage')); $this->assertContains( $publishedPage->ID, @@ -57,10 +66,12 @@ class SearchFormTest extends FunctionalTest { $sf = new SearchForm($this->mockController, 'SearchForm'); $publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage'); - $publishedPage->Title = "finding me"; + $publishedPage->Title = "finding butterflies"; $publishedPage->write(); $publishedPage->publish('Stage', 'Live'); - $results = $sf->getResults(null, array('Search'=>'"finding me"')); + + $this->waitUntilIndexingFinished(); + $results = $sf->getResults(null, array('Search'=>'"finding butterflies"')); $this->assertContains( $publishedPage->ID, $results->column('ID'),