Completed
Push — dev2 ( f75d77...01a103 )
by Gordon
15:27
created
tests/ElasticSearchPageControllerTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	public function testQueryInSearchBoxForOneFormOnly() {
244 244
 		$searchPageObj = $this->ElasticSearchPage2;
245 245
 		$url = rtrim($searchPageObj->Link(), '/');
246
-		$url .= "?q=Auckland&sfid=".$searchPageObj->Identifier;
246
+		$url .= "?q=Auckland&sfid=" . $searchPageObj->Identifier;
247 247
 		$response = $this->get($url);
248 248
 		$this->assertEquals(200, $response->getStatusCode());
249 249
 		$this->assertAttributeHasExactValue('#ElasticSearchForm_SearchForm_q', 'q',
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		$ctr = 0;
379 379
 
380 380
 		// results vary slightly due to sharding, hence check for a string instead of absolute results
381
-		while ($ctr < 18) {
381
+		while($ctr < 18) {
382 382
 			$this->assertSelectorContains('div.searchResult a', $ctr, 'New Orleans, Southern Pacific');
383 383
 			$ctr++;
384 384
 			$this->assertSelectorStartsWithOrEquals('div.searchResult a', $ctr, 'Similar');
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 		$url = rtrim($searchPageObj->Link(), '/');
398 398
 		$url .= "?q=New%20Zealind&TestMode=true";
399 399
 		$response = $this->get($url);
400
-		error_log(print_r($response,1));
400
+		error_log(print_r($response, 1));
401 401
 		$this->assertEquals(200, $response->getStatusCode());
402 402
 
403 403
 		$ctr = 0;
404 404
 
405 405
 		// results vary slightly due to sharding, hence check for a string instead of absolute results
406
-		while ($ctr < 18) {
406
+		while($ctr < 18) {
407 407
 			$this->assertSelectorContains('div.searchResult a', $ctr, 'New');
408 408
 			$ctr++;
409 409
 			$this->assertSelectorStartsWithOrEquals('div.searchResult a', $ctr, 'Similar');
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 		//Note pages need to be published, by default fixtures only reside in Stage
502 502
 		$searchPageObj = $this->ElasticSearchPage2;
503 503
 		$url = rtrim($searchPageObj->Link(), '/');
504
-		$url = $url.'?q='.$searchTerm;
504
+		$url = $url . '?q=' . $searchTerm;
505 505
 		$response = $this->get($url);
506 506
 		$this->assertEquals(200, $response->getStatusCode());
507 507
 
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		//Note pages need to be published, by default fixtures only reside in Stage
569 569
 		$searchPageObj = $this->ElasticSearchPage;
570 570
 		$url = rtrim($searchPageObj->Link(), '/');
571
-		$url = $url.'?q='.$searchTerm;
571
+		$url = $url . '?q=' . $searchTerm;
572 572
 		$response = $this->get($url);
573 573
 		$this->assertEquals(200, $response->getStatusCode());
574 574
 
@@ -699,18 +699,18 @@  discard block
 block discarded – undo
699 699
 		//increase the number of results and assert that they are the same as per pages 1,2 joined
700 700
 		$searchPageObj->ResultsPerPage = 20;
701 701
 		$searchPageObj->write();
702
-		$searchPageObj->publish('Stage','Live');
702
+		$searchPageObj->publish('Stage', 'Live');
703 703
 		$response3 = $this->get($firstPageURL);
704 704
 	}
705 705
 
706 706
 
707 707
 	private function enableHighlights() {
708
-		foreach (SearchableField::get()->filter('Name', 'Title') as $sf) {
708
+		foreach(SearchableField::get()->filter('Name', 'Title') as $sf) {
709 709
 			$sf->ShowHighlights = true;
710 710
 			$sf->write();
711 711
 		}
712 712
 
713
-		foreach (SearchableField::get()->filter('Name', 'Content') as $sf) {
713
+		foreach(SearchableField::get()->filter('Name', 'Content') as $sf) {
714 714
 			$sf->ShowHighlights = true;
715 715
 			$sf->write();
716 716
 		}
Please login to merge, or discard this patch.
tests/ElasticsearchFunctionalTestBase.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 	public static $ignoreFixtureFileFor = array();
10 10
 
11 11
 	protected $extraDataObjects = array(
12
-		'SearchableTestPage','FlickrPhotoTO','FlickrAuthorTO','FlickrSetTO','FlickrTagTO',
13
-		'SearchableTestFatherPage','SearchableTestGrandFatherPage'
12
+		'SearchableTestPage', 'FlickrPhotoTO', 'FlickrAuthorTO', 'FlickrSetTO', 'FlickrTagTO',
13
+		'SearchableTestFatherPage', 'SearchableTestGrandFatherPage'
14 14
 	);
15 15
 
16 16
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 	public function setUp() {
29 29
 
30
-		error_log("*************** TEST: ".$this->getName());
30
+		error_log("*************** TEST: " . $this->getName());
31 31
 
32 32
 		$cache = SS_Cache::factory('elasticsearch');
33 33
 		$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 		// this needs to be called in order to create the list of searchable
37 37
 		// classes and fields that are available.  Simulates part of a build
38
-		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO',
38
+		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO',
39 39
 			'FlickrTagTO', 'FlickrAuthorTO');
40 40
 		$this->requireDefaultRecordsFrom = $classes;
41 41
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			$this->service->setTestMode(true);
55 55
 
56 56
 			// A previous test may have deleted the index and then failed, so check for this
57
-			if (!$this->service->getIndex()->exists()) {
57
+			if(!$this->service->getIndex()->exists()) {
58 58
 				$this->service->getIndex()->create();
59 59
 			}
60 60
 			$this->service->reset();
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 			// load fixtures
66 66
 			$orig_fixture_file = static::$fixture_file;
67 67
 
68
-			foreach (static::$ignoreFixtureFileFor as $testPattern) {
69
-				$pattern = '/'.$testPattern.'/';
70
-				if (preg_match($pattern, $this->getName())) {
68
+			foreach(static::$ignoreFixtureFileFor as $testPattern) {
69
+				$pattern = '/' . $testPattern . '/';
70
+				if(preg_match($pattern, $this->getName())) {
71 71
 					static::$fixture_file = null;
72 72
 				}
73 73
 			}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		// this has to be executed otherwise nesting exceptions occur
80 80
 		parent::setUp();
81 81
 
82
-		if ($elasticaException) {
82
+		if($elasticaException) {
83 83
 			$this->fail('T1 Exception with Elasticsearch');
84 84
 		}
85 85
 
@@ -101,18 +101,18 @@  discard block
 block discarded – undo
101 101
 			$elasticaException = true;
102 102
 		}
103 103
 
104
-		if ($elasticaException) {
104
+		if($elasticaException) {
105 105
 			$this->fail('T2 Exception with Elasticsearch');
106 106
 		}
107 107
 	}
108 108
 
109 109
 
110 110
 	private function publishSiteTree() {
111
-		foreach (SiteTree::get()->getIterator() as $page) {
111
+		foreach(SiteTree::get()->getIterator() as $page) {
112 112
 			// temporarily disable Elasticsearch indexing, it will be done in a batch
113 113
 			$page->IndexingOff = true;
114 114
 
115
-			$page->publish('Stage','Live');
115
+			$page->publish('Stage', 'Live');
116 116
 		}
117 117
 	}
118 118
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		$items = $this->cssParser()->getBySelector($selector);
134 134
 
135 135
 		$ctr = 0;
136
-		foreach ($items as $item) {
136
+		foreach($items as $item) {
137 137
 			$text = strip_tags($item);
138 138
 			$escaped = str_replace("'", "\'", $text);
139 139
 			$ctr++;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		$items = $this->cssParser()->getBySelector($selector);
164 164
 
165 165
 		$ctr = 0;
166
-		foreach ($items as $item) {
166
+		foreach($items as $item) {
167 167
 			$text = strip_tags($item);
168 168
 			$escaped = str_replace("'", "\'", $text);
169 169
 			$ctr++;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	public function assertAttributeHasExactValue($selector, $attributeName, $expectedValue) {
187 187
 		$items = $this->cssParser()->getBySelector($selector);
188
-		foreach ($items as $item) {
188
+		foreach($items as $item) {
189 189
 			$this->assertEquals($expectedValue, $item['value']);
190 190
 		}
191 191
 	}
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 	public function assertAttributesHaveExactValues($selector, $expectedValues) {
195 195
 		$attributeNames = array_keys($expectedValues);
196 196
 		$items = $this->cssParser()->getBySelector($selector);
197
-		foreach ($items as $item) {
197
+		foreach($items as $item) {
198 198
 			$actualValues = array();
199
-			foreach ($attributeNames as $attributeName) {
199
+			foreach($attributeNames as $attributeName) {
200 200
 				$actualValues[$attributeName] = (string)$item[$attributeName];
201 201
 			}
202 202
 			$this->assertEquals($expectedValues, $actualValues);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 	public function assertNumberOfNodes($selector, $expectedAmount) {
208 208
 		$items = $this->cssParser()->getBySelector($selector);
209
-		foreach ($items as $item) {
209
+		foreach($items as $item) {
210 210
 			$text = strip_tags($item);
211 211
 		}
212 212
 
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 	public function collateSearchResults() {
220 220
 		$items = $this->cssParser()->getBySelector('div.searchResults .searchResult');
221 221
 		$result = array();
222
-		foreach ($items as $item) {
222
+		foreach($items as $item) {
223 223
 			$attr = $item->attributes()->id;
224
-			array_push($result, $attr."");
224
+			array_push($result, $attr . "");
225 225
 		}
226 226
 
227 227
 		return $result;
Please login to merge, or discard this patch.