From 3f90b70db2d937e55f299c38c15e56c63a3cadd6 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 19 Oct 2010 01:27:18 +0000 Subject: [PATCH] BUGFIX: force the test to wait until indexing completes. Do not use stop words ('me') (from r110130) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112832 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'),