@@ -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 | |
@@ -50,7 +50,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | $status = $index->getStatus()->getData(); |
| 209 | 209 | |
| 210 | 210 | $numberDocsInIndex = -1; // flag value for not yet indexed |
| 211 | - if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { |
|
| 211 | + if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { |
|
| 212 | 212 | error_log('CHECKING NUMBER OF INDEXED DOCUMENTS, SHOULD BE ' . $expectedAmount); |
| 213 | - error_log(print_r($status,1)); |
|
| 213 | + error_log(print_r($status, 1)); |
|
| 214 | 214 | $numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs']; |
| 215 | - error_log('DOCUMENTS FOUND:'.$numberDocsInIndex) |
|
| 215 | + error_log('DOCUMENTS FOUND:' . $numberDocsInIndex) |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $this->assertEquals($expectedAmount,$numberDocsInIndex); |
|
| 218 | + $this->assertEquals($expectedAmount, $numberDocsInIndex); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /* |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $status = $index->getStatus()->getData(); |
| 227 | 227 | |
| 228 | 228 | $numberDocsInIndex = -1; // flag value for not yet indexed |
| 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 | } |
| 232 | 232 | |