From df41fcdce4f3405897423856d79d09696132e796 Mon Sep 17 00:00:00 2001
From: Ingo Schommer <ingo@silverstripe.com>
Date: Tue, 11 Dec 2012 15:18:47 +0100
Subject: [PATCH] Skip SearchFormTest if DB driver doesn't support fulltext

For now, the only case are specific SQL Server setups.
---
 tests/search/SearchFormTest.php | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tests/search/SearchFormTest.php b/tests/search/SearchFormTest.php
index c0794fa0..e336d5e3 100644
--- a/tests/search/SearchFormTest.php
+++ b/tests/search/SearchFormTest.php
@@ -37,8 +37,24 @@ class ZZZSearchFormTest extends FunctionalTest {
 		
 		$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() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 	
 		$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
@@ -54,6 +70,8 @@ class ZZZSearchFormTest extends FunctionalTest {
 	}
 	
 	public function testDoubleQuotesPublishedPagesMatchedByTitle() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 
 		$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
@@ -72,6 +90,8 @@ class ZZZSearchFormTest extends FunctionalTest {
 	
 	/*
 	public function testUnpublishedPagesNotIncluded() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 		
 		$results = $sf->getResults(null, array('Search'=>'publicUnpublishedPage'));
@@ -85,6 +105,8 @@ class ZZZSearchFormTest extends FunctionalTest {
 	*/
 	
 	public function testPagesRestrictedToLoggedinUsersNotIncluded() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 		
 		$page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
@@ -107,6 +129,8 @@ class ZZZSearchFormTest extends FunctionalTest {
 	}
 
 	public function testPagesRestrictedToSpecificGroupNotIncluded() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 		
 		$page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers');
@@ -139,6 +163,8 @@ class ZZZSearchFormTest extends FunctionalTest {
 	}
 	
 	public function testInheritedRestrictedPagesNotInlucded() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 		
 		$page = $this->objFromFixture('SiteTree', 'inheritRestrictedView');
@@ -162,6 +188,8 @@ class ZZZSearchFormTest extends FunctionalTest {
 	}
 	
 	public function testDisabledShowInSearchFlagNotIncludedForSiteTree() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 		
 		$page = $this->objFromFixture('SiteTree', 'dontShowInSearchPage');
@@ -174,6 +202,8 @@ class ZZZSearchFormTest extends FunctionalTest {
 	}
 	
 	public function testDisabledShowInSearchFlagNotIncludedForFiles() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 		
 		$dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile');
@@ -194,6 +224,8 @@ class ZZZSearchFormTest extends FunctionalTest {
 	}
 
 	public function testSearchTitleAndContentWithSpecialCharacters() {
+		if(!$this->checkFulltextSupport()) return;
+
 		$sf = new SearchForm($this->mockController, 'SearchForm');
 		
 		$pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars');