Completed
Push — dev2 ( a481f8...31fab1 )
by Gordon
20:45 queued 03:47
created
tests/ElasticsearchTestBase.php 2 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -132,6 +132,10 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 
135
+	/**
136
+	 * @param integer $depth
137
+	 * @param string $parentKey
138
+	 */
135 139
 	private function recurseArrayAssertion($toAssert, $depth, $parentKey) {
136 140
 		$prefix = str_repeat("\t",$depth);
137 141
 		echo "\t{$prefix}'$parentKey' => array(\n";
@@ -160,6 +164,10 @@  discard block
 block discarded – undo
160 164
 	/*
161 165
 	Helper methods for testing CMS fields
162 166
 	 */
167
+
168
+	/**
169
+	 * @param string $tabName
170
+	 */
163 171
 	public function checkTabExists($fields, $tabName) {
164 172
 		echo "Searching for tab $tabName\n";
165 173
 		$tab = $fields->findOrMakeTab("Root.{$tabName}");
@@ -184,6 +192,9 @@  discard block
 block discarded – undo
184 192
 	}
185 193
 
186 194
 
195
+	/**
196
+	 * @param string $fieldName
197
+	 */
187 198
 	public function checkFieldExists($tab,$fieldName) {
188 199
 		$fields = $tab->Fields();
189 200
 		echo "TAB:{$tab->Name}\n";
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 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
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 		// this needs to be called in order to create the list of searchable
42 42
 		// classes and fields that are available.  Simulates part of a build
43
-		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO',
43
+		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO',
44 44
 			'FlickrTagTO', 'FlickrAuthorTO');
45 45
 		$this->requireDefaultRecordsFrom = $classes;
46 46
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$this->service->setTestMode(true);
51 51
 
52 52
 		// A previous test may have deleted the index and then failed, so check for this
53
-		if (!$this->service->getIndex()->exists()) {
53
+		if(!$this->service->getIndex()->exists()) {
54 54
 			$this->service->getIndex()->create();
55 55
 		}
56 56
 		$this->service->reset();
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
 		$orig_fixture_file = static::$fixture_file;
63 63
 
64
-		foreach (static::$ignoreFixtureFileFor as $testPattern) {
65
-			$pattern = '/'.$testPattern.'/';
66
-			if (preg_match($pattern, $this->getName())) {
64
+		foreach(static::$ignoreFixtureFileFor as $testPattern) {
65
+			$pattern = '/' . $testPattern . '/';
66
+			if(preg_match($pattern, $this->getName())) {
67 67
 				static::$fixture_file = null;
68 68
 			}
69 69
 		}
@@ -92,55 +92,55 @@  discard block
 block discarded – undo
92 92
 
93 93
 
94 94
 	private function publishSiteTree() {
95
-		foreach (SiteTree::get()->getIterator() as $page) {
95
+		foreach(SiteTree::get()->getIterator() as $page) {
96 96
 			// temporarily disable Elasticsearch indexing, it will be done in a batch
97 97
 			$page->IndexingOff = true;
98
-			$page->publish('Stage','Live');
98
+			$page->publish('Stage', 'Live');
99 99
 		}
100 100
 	}
101 101
 
102 102
 
103 103
 	public function generateAssertionsFromArray($toAssert) {
104
-		echo '$expected = array('."\n";
105
-		foreach ($toAssert as $key => $value) {
104
+		echo '$expected = array(' . "\n";
105
+		foreach($toAssert as $key => $value) {
106 106
 			$escValue = str_replace("'", '\\\'', $value);
107 107
 			echo "'$key' => '$escValue',\n";
108 108
 		}
109 109
 		echo ");\n";
110
-		echo '$this->assertEquals($expected, $somevar);'."\n";
110
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
111 111
 	}
112 112
 
113 113
 
114 114
 	public function generateAssertionsFromArray1D($toAssert) {
115
-		echo '$expected = array('."\n";
116
-		foreach ($toAssert as $key => $value) {
115
+		echo '$expected = array(' . "\n";
116
+		foreach($toAssert as $key => $value) {
117 117
 			$escValue = str_replace("'", '\\\'', $value);
118 118
 			echo "'$escValue',";
119 119
 		}
120 120
 		echo ");\n";
121
-		echo '$this->assertEquals($expected, $somevar);'."\n";
121
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
122 122
 	}
123 123
 
124 124
 
125 125
 	public function generateAssertionsFromArrayRecurse($toAssert) {
126 126
 		echo '$expected = ';
127
-			$this->recurseArrayAssertion($toAssert,1, 'FIXME');
128
-		echo '$this->assertEquals($expected, $somevar);'."\n";
127
+			$this->recurseArrayAssertion($toAssert, 1, 'FIXME');
128
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
129 129
 	}
130 130
 
131 131
 
132 132
 	private function recurseArrayAssertion($toAssert, $depth, $parentKey) {
133
-		$prefix = str_repeat("\t",$depth);
133
+		$prefix = str_repeat("\t", $depth);
134 134
 		echo "\t{$prefix}'$parentKey' => array(\n";
135 135
 		$ctr = 0;
136 136
 		$len = sizeof(array_keys($toAssert));
137
-		foreach ($toAssert as $key => $value) {
138
-			if (is_array($value)) {
139
-				$this->recurseArrayAssertion($value, $depth+1, $key);
137
+		foreach($toAssert as $key => $value) {
138
+			if(is_array($value)) {
139
+				$this->recurseArrayAssertion($value, $depth + 1, $key);
140 140
 			} else {
141 141
 				$escValue = str_replace("'", '\\\'', $value);
142 142
 				$comma = ',';
143
-				if ($ctr == $len-1) {
143
+				if($ctr == $len - 1) {
144 144
 					$comma = '';
145 145
 				}
146 146
 				echo "\t\t$prefix'$key' => '$escValue'$comma\n";
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		$size = sizeof($splits);
165 165
 		$nameToCheck = end($splits);
166 166
 		$this->assertEquals($actualTabName, $nameToCheck);
167
-		if ($size == 1) {
167
+		if($size == 1) {
168 168
 			$this->assertEquals("Root_${tabName}", $tab->id());
169 169
 		} else {
170 170
 			$expected = "Root_{$splits[0]}_set_{$splits[1]}";
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	}
176 176
 
177 177
 
178
-	public function checkFieldExists($tab,$fieldName) {
178
+	public function checkFieldExists($tab, $fieldName) {
179 179
 		$fields = $tab->Fields();
180 180
 		$field = $tab->fieldByName($fieldName);
181 181
 		$this->assertTrue($field != null);
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 
210 210
 		$numberDocsInIndex = -1; // flag value for not yet indexed
211 211
 		error_log('CHECKING NUMBER OF INDEXED DOCUMENTS, SHOULD BE ' . $expectedAmount);
212
-		error_log(print_r($status,1));
212
+		error_log(print_r($status, 1));
213 213
 
214
-		if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
214
+		if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
215 215
 			$numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs'];
216
-			error_log('DOCUMENTS FOUND:'.$numberDocsInIndex);
216
+			error_log('DOCUMENTS FOUND:' . $numberDocsInIndex);
217 217
 		}
218 218
 
219
-		$this->assertEquals($expectedAmount,$numberDocsInIndex);
219
+		$this->assertEquals($expectedAmount, $numberDocsInIndex);
220 220
 	}
221 221
 
222 222
 	/*
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$status = $index->getStatus()->getData();
228 228
 
229 229
 		$numberDocsInIndex = -1; // flag value for not yet indexed
230
-		if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
230
+		if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
231 231
 			$numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs'];
232 232
 		}
233 233
 
Please login to merge, or discard this patch.