Skip SearchFormTest if DB driver doesn't support fulltext

For now, the only case are specific SQL Server setups.
This commit is contained in:
Ingo Schommer 2012-12-11 15:18:47 +01:00
parent 8cd29b627c
commit df41fcdce4

View File

@ -38,7 +38,23 @@ class ZZZSearchFormTest extends FunctionalTest {
$this->waitUntilIndexingFinished(); $this->waitUntilIndexingFinished();
} }
/**
* @return Boolean
*/
protected function checkFulltextSupport() {
$conn = DB::getConn();
if(class_exists('MSSQLDatabase') && $conn instanceof MSSQLDatabase) {
$supports = $conn->fullTextEnabled();
} else {
$supports = true;
}
if(!$supports) $this->markTestSkipped('Fulltext not supported by DB driver or setup');
return $supports;
}
public function testPublishedPagesMatchedByTitle() { public function testPublishedPagesMatchedByTitle() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage'); $publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
@ -54,6 +70,8 @@ class ZZZSearchFormTest extends FunctionalTest {
} }
public function testDoubleQuotesPublishedPagesMatchedByTitle() { public function testDoubleQuotesPublishedPagesMatchedByTitle() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage'); $publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
@ -72,6 +90,8 @@ class ZZZSearchFormTest extends FunctionalTest {
/* /*
public function testUnpublishedPagesNotIncluded() { public function testUnpublishedPagesNotIncluded() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$results = $sf->getResults(null, array('Search'=>'publicUnpublishedPage')); $results = $sf->getResults(null, array('Search'=>'publicUnpublishedPage'));
@ -85,6 +105,8 @@ class ZZZSearchFormTest extends FunctionalTest {
*/ */
public function testPagesRestrictedToLoggedinUsersNotIncluded() { public function testPagesRestrictedToLoggedinUsersNotIncluded() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers'); $page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
@ -107,6 +129,8 @@ class ZZZSearchFormTest extends FunctionalTest {
} }
public function testPagesRestrictedToSpecificGroupNotIncluded() { public function testPagesRestrictedToSpecificGroupNotIncluded() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers'); $page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers');
@ -139,6 +163,8 @@ class ZZZSearchFormTest extends FunctionalTest {
} }
public function testInheritedRestrictedPagesNotInlucded() { public function testInheritedRestrictedPagesNotInlucded() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$page = $this->objFromFixture('SiteTree', 'inheritRestrictedView'); $page = $this->objFromFixture('SiteTree', 'inheritRestrictedView');
@ -162,6 +188,8 @@ class ZZZSearchFormTest extends FunctionalTest {
} }
public function testDisabledShowInSearchFlagNotIncludedForSiteTree() { public function testDisabledShowInSearchFlagNotIncludedForSiteTree() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$page = $this->objFromFixture('SiteTree', 'dontShowInSearchPage'); $page = $this->objFromFixture('SiteTree', 'dontShowInSearchPage');
@ -174,6 +202,8 @@ class ZZZSearchFormTest extends FunctionalTest {
} }
public function testDisabledShowInSearchFlagNotIncludedForFiles() { public function testDisabledShowInSearchFlagNotIncludedForFiles() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile'); $dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile');
@ -194,6 +224,8 @@ class ZZZSearchFormTest extends FunctionalTest {
} }
public function testSearchTitleAndContentWithSpecialCharacters() { public function testSearchTitleAndContentWithSpecialCharacters() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars'); $pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars');