Completed
Push — dev2 ( 774f9d...0919fb )
by Gordon
05:50
created
tests/AutocompleteFilteredControllerTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
 		$this->assertEquals('the', $result->Query);
20 20
 		$lquery = strtolower($result->Query);
21
-		foreach ($result->suggestions as $suggestion) {
21
+		foreach($result->suggestions as $suggestion) {
22 22
 			$value = $suggestion->value;
23 23
 			$value = strtolower($value);
24 24
 			$this->assertContains($lquery, $value);
Please login to merge, or discard this patch.
tests/ElasticsearchFunctionalTestBase.php 1 patch
Spacing   +19 added lines, -19 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++;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function assertAttributeHasExactValue($selector, $attributeName, $expectedValue) {
157 157
 		$items = $this->cssParser()->getBySelector($selector);
158
-		foreach ($items as $item) {
158
+		foreach($items as $item) {
159 159
 			$this->assertEquals($expectedValue, $item['value']);
160 160
 		}
161 161
 	}
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	public function assertAttributesHaveExactValues($selector, $expectedValues) {
165 165
 		$attributeNames = array_keys($expectedValues);
166 166
 		$items = $this->cssParser()->getBySelector($selector);
167
-		foreach ($items as $item) {
167
+		foreach($items as $item) {
168 168
 			$actualValues = array();
169
-			foreach ($attributeNames as $attributeName) {
169
+			foreach($attributeNames as $attributeName) {
170 170
 				$actualValues[$attributeName] = (string)$item[$attributeName];
171 171
 			}
172 172
 			$this->assertEquals($expectedValues, $actualValues);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 	public function assertNumberOfNodes($selector, $expectedAmount) {
178 178
 		$items = $this->cssParser()->getBySelector($selector);
179
-		foreach ($items as $item) {
179
+		foreach($items as $item) {
180 180
 			$text = strip_tags($item);
181 181
 		}
182 182
 
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 	public function collateSearchResults() {
190 190
 		$items = $this->cssParser()->getBySelector('div.searchResults .searchResult');
191 191
 		$result = array();
192
-		foreach ($items as $item) {
192
+		foreach($items as $item) {
193 193
 			$attr = $item->attributes()->id;
194
-			array_push($result, $attr."");
194
+			array_push($result, $attr . "");
195 195
 		}
196 196
 
197 197
 		return $result;
Please login to merge, or discard this patch.
tests/ElasticsearchTestBase.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 	public static $ignoreFixtureFileFor = array();
9 9
 
10 10
 	protected $extraDataObjects = array(
11
-		'SearchableTestPage','FlickrPhotoTO','FlickrAuthorTO','FlickrSetTO','FlickrTagTO',
12
-		'SearchableTestFatherPage','SearchableTestGrandFatherPage','AutoCompleteOption'
11
+		'SearchableTestPage', 'FlickrPhotoTO', 'FlickrAuthorTO', 'FlickrSetTO', 'FlickrTagTO',
12
+		'SearchableTestFatherPage', 'SearchableTestGrandFatherPage', 'AutoCompleteOption'
13 13
 	);
14 14
 
15 15
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 		// this needs to be called in order to create the list of searchable
44 44
 		// classes and fields that are available.  Simulates part of a build
45
-		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO',
45
+		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO',
46 46
 			'FlickrTagTO', 'FlickrAuthorTO');
47 47
 		$this->requireDefaultRecordsFrom = $classes;
48 48
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
 		try {
60 60
 			// A previous test may have deleted the index and then failed, so check for this
61
-			if (!$this->service->getIndex()->exists()) {
61
+			if(!$this->service->getIndex()->exists()) {
62 62
 				error_log('++++ EL BASE SET UP T4a');
63 63
 
64 64
 				$this->service->getIndex()->create();
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 			$orig_fixture_file = static::$fixture_file;
74 74
 			error_log('++++ EL BASE SET UP T5');
75 75
 
76
-			foreach (static::$ignoreFixtureFileFor as $testPattern) {
77
-				$pattern = '/'.$testPattern.'/';
78
-				if (preg_match($pattern, $this->getName())) {
76
+			foreach(static::$ignoreFixtureFileFor as $testPattern) {
77
+				$pattern = '/' . $testPattern . '/';
78
+				if(preg_match($pattern, $this->getName())) {
79 79
 					static::$fixture_file = null;
80 80
 				}
81 81
 			}
82 82
 
83 83
 			error_log('++++ EL BASE SET UP T6');
84 84
 		} catch (Exception $e) {
85
-			error_log("**** EXCEPTION T1 ".$e->getMessage());
85
+			error_log("**** EXCEPTION T1 " . $e->getMessage());
86 86
 			$elasticException = true;
87 87
 		}
88 88
 			error_log('++++ EL BASE SET UP T7');
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		// this needs to run otherwise nested injector errors show up
92 92
 		parent::setUp();
93 93
 
94
-		if ($elasticException) {
94
+		if($elasticException) {
95 95
 			$this->fail('T1 An error has occurred trying to contact Elasticsearch server');
96 96
 		}
97 97
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 
108 108
 			$task->run(null);
109 109
 		} catch (Exception $e) {
110
-			error_log("**** EXCEPTION T2 ".$e->getMessage());
110
+			error_log("**** EXCEPTION T2 " . $e->getMessage());
111 111
 			$elasticException = true;
112 112
 		}
113 113
 
114
-		if ($elasticException) {
114
+		if($elasticException) {
115 115
 			$this->fail('T2 An error has occurred trying to contact Elasticsearch server');
116 116
 		}
117 117
 
@@ -126,55 +126,55 @@  discard block
 block discarded – undo
126 126
 
127 127
 
128 128
 	private function publishSiteTree() {
129
-		foreach (SiteTree::get()->getIterator() as $page) {
129
+		foreach(SiteTree::get()->getIterator() as $page) {
130 130
 			// temporarily disable Elasticsearch indexing, it will be done in a batch
131 131
 			$page->IndexingOff = true;
132
-			$page->publish('Stage','Live');
132
+			$page->publish('Stage', 'Live');
133 133
 		}
134 134
 	}
135 135
 
136 136
 
137 137
 	public function generateAssertionsFromArray($toAssert) {
138
-		echo '$expected = array('."\n";
139
-		foreach ($toAssert as $key => $value) {
138
+		echo '$expected = array(' . "\n";
139
+		foreach($toAssert as $key => $value) {
140 140
 			$escValue = str_replace("'", '\\\'', $value);
141 141
 			echo "'$key' => '$escValue',\n";
142 142
 		}
143 143
 		echo ");\n";
144
-		echo '$this->assertEquals($expected, $somevar);'."\n";
144
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
145 145
 	}
146 146
 
147 147
 
148 148
 	public function generateAssertionsFromArray1D($toAssert) {
149
-		echo '$expected = array('."\n";
150
-		foreach ($toAssert as $key => $value) {
149
+		echo '$expected = array(' . "\n";
150
+		foreach($toAssert as $key => $value) {
151 151
 			$escValue = str_replace("'", '\\\'', $value);
152 152
 			echo "'$escValue',";
153 153
 		}
154 154
 		echo ");\n";
155
-		echo '$this->assertEquals($expected, $somevar);'."\n";
155
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
156 156
 	}
157 157
 
158 158
 
159 159
 	public function generateAssertionsFromArrayRecurse($toAssert) {
160 160
 		echo '$expected = ';
161
-			$this->recurseArrayAssertion($toAssert,1, 'FIXME');
162
-		echo '$this->assertEquals($expected, $somevar);'."\n";
161
+			$this->recurseArrayAssertion($toAssert, 1, 'FIXME');
162
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
163 163
 	}
164 164
 
165 165
 
166 166
 	private function recurseArrayAssertion($toAssert, $depth, $parentKey) {
167
-		$prefix = str_repeat("\t",$depth);
167
+		$prefix = str_repeat("\t", $depth);
168 168
 		echo "\t{$prefix}'$parentKey' => array(\n";
169 169
 		$ctr = 0;
170 170
 		$len = sizeof(array_keys($toAssert));
171
-		foreach ($toAssert as $key => $value) {
172
-			if (is_array($value)) {
173
-				$this->recurseArrayAssertion($value, $depth+1, $key);
171
+		foreach($toAssert as $key => $value) {
172
+			if(is_array($value)) {
173
+				$this->recurseArrayAssertion($value, $depth + 1, $key);
174 174
 			} else {
175 175
 				$escValue = str_replace("'", '\\\'', $value);
176 176
 				$comma = ',';
177
-				if ($ctr == $len-1) {
177
+				if($ctr == $len - 1) {
178 178
 					$comma = '';
179 179
 				}
180 180
 				echo "\t\t$prefix'$key' => '$escValue'$comma\n";
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 		$size = sizeof($splits);
199 199
 		$nameToCheck = end($splits);
200 200
 		$this->assertEquals($actualTabName, $nameToCheck);
201
-		if ($size == 1) {
201
+		if($size == 1) {
202 202
 			$this->assertEquals("Root_${tabName}", $tab->id());
203 203
 		} else {
204 204
 			$expected = "Root_{$splits[0]}_set_{$splits[1]}";
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 
212
-	public function checkFieldExists($tab,$fieldName) {
212
+	public function checkFieldExists($tab, $fieldName) {
213 213
 		$fields = $tab->Fields();
214 214
 		$field = $tab->fieldByName($fieldName);
215 215
 		$this->assertTrue($field != null);
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
 
244 244
 		$numberDocsInIndex = -1; // flag value for not yet indexed
245 245
 		error_log('CHECKING NUMBER OF INDEXED DOCUMENTS, SHOULD BE ' . $expectedAmount);
246
-		error_log(print_r($status,1));
246
+		error_log(print_r($status, 1));
247 247
 
248
-		if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
248
+		if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
249 249
 			$numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs'];
250
-			error_log('DOCUMENTS FOUND:'.$numberDocsInIndex);
250
+			error_log('DOCUMENTS FOUND:' . $numberDocsInIndex);
251 251
 		} else {
252 252
 			$numberDocsInIndex = 0;
253 253
 		}
254 254
 
255
-		$this->assertEquals($expectedAmount,$numberDocsInIndex);
255
+		$this->assertEquals($expectedAmount, $numberDocsInIndex);
256 256
 	}
257 257
 
258 258
 	/*
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		$status = $index->getStatus()->getData();
264 264
 
265 265
 		$numberDocsInIndex = -1; // flag value for not yet indexed
266
-		if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
266
+		if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
267 267
 			$numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs'];
268 268
 		}
269 269
 
Please login to merge, or discard this patch.