@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | // FIXME - this test appears fragile due to sharding issues with more like this |
| 131 | 131 | $ctr = 0; |
| 132 | - if ($ctr < 9) { |
|
| 132 | + if($ctr < 9) { |
|
| 133 | 133 | $this->assertStringStartsWith( |
| 134 | 134 | '[Texas and New Orleans, Southern Pacific', |
| 135 | 135 | $results[$ctr]->Title |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | $paginated = $es->moreLikeThis($fp, $fields, true); |
| 150 | 150 | $results = $paginated->getList()->toArray(); |
| 151 | 151 | |
| 152 | - foreach ($results as $result) { |
|
| 152 | + foreach($results as $result) { |
|
| 153 | 153 | error_log($result->Title); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | $ctr = 0; |
| 157 | - foreach ($results as $result) { |
|
| 157 | + foreach($results as $result) { |
|
| 158 | 158 | $ctr++; |
| 159 | - if ($ctr < 9) { |
|
| 159 | + if($ctr < 9) { |
|
| 160 | 160 | $this->assertStringStartsWith( |
| 161 | 161 | '[Texas and New Orleans, Southern Pacific', |
| 162 | 162 | $result->Title |
@@ -216,16 +216,16 @@ discard block |
||
| 216 | 216 | $paginated = $es->search($query, $fields); |
| 217 | 217 | $ctr = 0; |
| 218 | 218 | |
| 219 | - foreach ($paginated->getList()->toArray() as $result) { |
|
| 219 | + foreach($paginated->getList()->toArray() as $result) { |
|
| 220 | 220 | $ctr++; |
| 221 | - foreach ($result->SearchHighlightsByField->Description_standard->getIterator() as $highlight) { |
|
| 221 | + foreach($result->SearchHighlightsByField->Description_standard->getIterator() as $highlight) { |
|
| 222 | 222 | $snippet = $highlight->Snippet; |
| 223 | 223 | $snippet = strtolower($snippet); |
| 224 | 224 | $wordFound = false; |
| 225 | 225 | $lcquery = explode(' ', strtolower($query)); |
| 226 | - foreach ($lcquery as $part) { |
|
| 226 | + foreach($lcquery as $part) { |
|
| 227 | 227 | $bracketed = '<strong class="hl">' . $part . '</strong>'; |
| 228 | - if (strpos($snippet, $bracketed) > 0) { |
|
| 228 | + if(strpos($snippet, $bracketed) > 0) { |
|
| 229 | 229 | $wordFound = true; |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -245,17 +245,17 @@ discard block |
||
| 245 | 245 | $paginated = $es->search($query, $fields); |
| 246 | 246 | $ctr = 0; |
| 247 | 247 | |
| 248 | - foreach ($paginated->getList()->toArray() as $result) { |
|
| 248 | + foreach($paginated->getList()->toArray() as $result) { |
|
| 249 | 249 | $ctr++; |
| 250 | 250 | |
| 251 | - foreach ($result->SearchHighlightsByField->Description->getIterator() as $highlight) { |
|
| 251 | + foreach($result->SearchHighlightsByField->Description->getIterator() as $highlight) { |
|
| 252 | 252 | $snippet = $highlight->Snippet; |
| 253 | 253 | $snippet = strtolower($snippet); |
| 254 | 254 | $wordFound = false; |
| 255 | 255 | $lcquery = explode(' ', strtolower($query)); |
| 256 | - foreach ($lcquery as $part) { |
|
| 256 | + foreach($lcquery as $part) { |
|
| 257 | 257 | $bracketed = '<strong class="hl">' . $part . '</strong>'; |
| 258 | - if (strpos($snippet, $bracketed) > 0) { |
|
| 258 | + if(strpos($snippet, $bracketed) > 0) { |
|
| 259 | 259 | $wordFound = true; |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $query = 'Lond'; |
| 273 | 273 | $results = $es->autocomplete_search($query, 'Title'); |
| 274 | 274 | $this->assertEquals(7, $results->getTotalItems()); |
| 275 | - foreach ($results->toArray() as $result) { |
|
| 275 | + foreach($results->toArray() as $result) { |
|
| 276 | 276 | $this->assertTrue(strpos($result->Title, $query) > 0); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $results = $paginated->getList()->toArray(); |
| 283 | 283 | $ctr = 0; |
| 284 | 284 | echo '$result = $paginated->getList()->toArray();' . "\n"; |
| 285 | - foreach ($results as $result) { |
|
| 285 | + foreach($results as $result) { |
|
| 286 | 286 | echo '$this->assertEquals("' . $result->Title . '", $results[' . $ctr . ']->Title);' . "\n"; |
| 287 | 287 | $ctr++; |
| 288 | 288 | } |
@@ -8,8 +8,8 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | try { |
| 54 | 54 | // A previous test may have deleted the index and then failed, so check for this |
| 55 | - if (!$this->service->getIndex()->exists()) { |
|
| 55 | + if(!$this->service->getIndex()->exists()) { |
|
| 56 | 56 | $this->service->getIndex()->create(); |
| 57 | 57 | } |
| 58 | 58 | $this->service->reset(); |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $orig_fixture_file = static::$fixture_file; |
| 64 | 64 | |
| 65 | - foreach (static::$ignoreFixtureFileFor as $testPattern) { |
|
| 66 | - $pattern = '/'.$testPattern.'/'; |
|
| 67 | - if (preg_match($pattern, $this->getName())) { |
|
| 65 | + foreach(static::$ignoreFixtureFileFor as $testPattern) { |
|
| 66 | + $pattern = '/' . $testPattern . '/'; |
|
| 67 | + if(preg_match($pattern, $this->getName())) { |
|
| 68 | 68 | static::$fixture_file = null; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // this needs to run otherwise nested injector errors show up |
| 77 | 77 | parent::setUp(); |
| 78 | 78 | |
| 79 | - if ($elasticException) { |
|
| 79 | + if($elasticException) { |
|
| 80 | 80 | $this->fail('T1 An error has occurred trying to contact Elasticsearch server'); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $elasticException = true; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ($elasticException) { |
|
| 98 | + if($elasticException) { |
|
| 99 | 99 | $this->fail('T2 An error has occurred trying to contact Elasticsearch server'); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -110,55 +110,55 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | private function publishSiteTree() { |
| 113 | - foreach (SiteTree::get()->getIterator() as $page) { |
|
| 113 | + foreach(SiteTree::get()->getIterator() as $page) { |
|
| 114 | 114 | // temporarily disable Elasticsearch indexing, it will be done in a batch |
| 115 | 115 | $page->IndexingOff = true; |
| 116 | - $page->publish('Stage','Live'); |
|
| 116 | + $page->publish('Stage', 'Live'); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | public function generateAssertionsFromArray($toAssert) { |
| 122 | - echo '$expected = array('."\n"; |
|
| 123 | - foreach ($toAssert as $key => $value) { |
|
| 122 | + echo '$expected = array(' . "\n"; |
|
| 123 | + foreach($toAssert as $key => $value) { |
|
| 124 | 124 | $escValue = str_replace("'", '\\\'', $value); |
| 125 | 125 | echo "'$key' => '$escValue',\n"; |
| 126 | 126 | } |
| 127 | 127 | echo ");\n"; |
| 128 | - echo '$this->assertEquals($expected, $somevar);'."\n"; |
|
| 128 | + echo '$this->assertEquals($expected, $somevar);' . "\n"; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | public function generateAssertionsFromArray1D($toAssert) { |
| 133 | - echo '$expected = array('."\n"; |
|
| 134 | - foreach ($toAssert as $key => $value) { |
|
| 133 | + echo '$expected = array(' . "\n"; |
|
| 134 | + foreach($toAssert as $key => $value) { |
|
| 135 | 135 | $escValue = str_replace("'", '\\\'', $value); |
| 136 | 136 | echo "'$escValue',"; |
| 137 | 137 | } |
| 138 | 138 | echo ");\n"; |
| 139 | - echo '$this->assertEquals($expected, $somevar);'."\n"; |
|
| 139 | + echo '$this->assertEquals($expected, $somevar);' . "\n"; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | public function generateAssertionsFromArrayRecurse($toAssert) { |
| 144 | 144 | echo '$expected = '; |
| 145 | - $this->recurseArrayAssertion($toAssert,1, 'FIXME'); |
|
| 146 | - echo '$this->assertEquals($expected, $somevar);'."\n"; |
|
| 145 | + $this->recurseArrayAssertion($toAssert, 1, 'FIXME'); |
|
| 146 | + echo '$this->assertEquals($expected, $somevar);' . "\n"; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | private function recurseArrayAssertion($toAssert, $depth, $parentKey) { |
| 151 | - $prefix = str_repeat("\t",$depth); |
|
| 151 | + $prefix = str_repeat("\t", $depth); |
|
| 152 | 152 | echo "\t{$prefix}'$parentKey' => array(\n"; |
| 153 | 153 | $ctr = 0; |
| 154 | 154 | $len = sizeof(array_keys($toAssert)); |
| 155 | - foreach ($toAssert as $key => $value) { |
|
| 156 | - if (is_array($value)) { |
|
| 157 | - $this->recurseArrayAssertion($value, $depth+1, $key); |
|
| 155 | + foreach($toAssert as $key => $value) { |
|
| 156 | + if(is_array($value)) { |
|
| 157 | + $this->recurseArrayAssertion($value, $depth + 1, $key); |
|
| 158 | 158 | } else { |
| 159 | 159 | $escValue = str_replace("'", '\\\'', $value); |
| 160 | 160 | $comma = ','; |
| 161 | - if ($ctr == $len-1) { |
|
| 161 | + if($ctr == $len - 1) { |
|
| 162 | 162 | $comma = ''; |
| 163 | 163 | } |
| 164 | 164 | echo "\t\t$prefix'$key' => '$escValue'$comma\n"; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $size = sizeof($splits); |
| 182 | 182 | $nameToCheck = end($splits); |
| 183 | 183 | $this->assertEquals($actualTabName, $nameToCheck); |
| 184 | - if ($size == 1) { |
|
| 184 | + if($size == 1) { |
|
| 185 | 185 | $this->assertEquals("Root_${tabName}", $tab->id()); |
| 186 | 186 | } else { |
| 187 | 187 | $expected = "Root_{$splits[0]}_set_{$splits[1]}"; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | |
| 195 | - public function checkFieldExists($tab,$fieldName) { |
|
| 195 | + public function checkFieldExists($tab, $fieldName) { |
|
| 196 | 196 | $fields = $tab->Fields(); |
| 197 | 197 | $field = $tab->fieldByName($fieldName); |
| 198 | 198 | $this->assertTrue($field != null); |
@@ -226,13 +226,13 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | $numberDocsInIndex = -1; // flag value for not yet indexed |
| 228 | 228 | |
| 229 | - if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { |
|
| 229 | + if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { |
|
| 230 | 230 | $numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs']; |
| 231 | 231 | } else { |
| 232 | 232 | $numberDocsInIndex = 0; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $this->assertEquals($expectedAmount,$numberDocsInIndex); |
|
| 235 | + $this->assertEquals($expectedAmount, $numberDocsInIndex); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /* |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $status = $index->getStatus()->getData(); |
| 244 | 244 | |
| 245 | 245 | $numberDocsInIndex = -1; // flag value for not yet indexed |
| 246 | - if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { |
|
| 246 | + if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { |
|
| 247 | 247 | $numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs']; |
| 248 | 248 | } |
| 249 | 249 | |