@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function setUpOnce() { |
| 16 | 16 | //Add translatable if it exists |
| 17 | - if (class_exists('Translatable')) { |
|
| 17 | + if(class_exists('Translatable')) { |
|
| 18 | 18 | SiteTree::add_extension('Translatable'); |
| 19 | 19 | } |
| 20 | 20 | parent::setUpOnce(); |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | // Delete and assert that it does not exist |
| 21 | - $sql = "SELECT ID,Name,ClazzName from SearchableField"; |
|
| 21 | + $sql = "SELECT ID,Name,ClazzName from SearchableField"; |
|
| 22 | 22 | $records = DB::query($sql); |
| 23 | 23 | |
| 24 | 24 | $filter = array('Name' => 'Title', 'ClazzName' => 'FlickrPhotoTO'); |
| 25 | 25 | $sf = SearchableField::get()->filter($filter)->first(); |
| 26 | - $sql = "UPDATE ElasticSearchPage_ElasticaSearchableFields SET Searchable=1,". |
|
| 27 | - "EnableAutocomplete=1 where SearchableFieldID=".$sf->ID; |
|
| 26 | + $sql = "UPDATE ElasticSearchPage_ElasticaSearchableFields SET Searchable=1," . |
|
| 27 | + "EnableAutocomplete=1 where SearchableFieldID=" . $sf->ID; |
|
| 28 | 28 | |
| 29 | 29 | DB::query($sql); |
| 30 | 30 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $this->assertEquals('the', $result->Query); |
| 45 | 45 | $lquery = strtolower($result->Query); |
| 46 | - foreach ($result->suggestions as $suggestion) { |
|
| 46 | + foreach($result->suggestions as $suggestion) { |
|
| 47 | 47 | $value = $suggestion->value; |
| 48 | 48 | $value = strtolower($value); |
| 49 | 49 | $this->assertContains($lquery, $value); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | $locales = array(); |
| 33 | 33 | if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable')) { |
| 34 | - foreach (\Translatable::get_existing_content_languages('SiteTree') as $code => $val) { |
|
| 34 | + foreach(\Translatable::get_existing_content_languages('SiteTree') as $code => $val) { |
|
| 35 | 35 | array_push($locales, $code); |
| 36 | 36 | } |
| 37 | 37 | } else { |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // now iterate all the locales indexing each locale in turn using it's owner index settings |
| 42 | - foreach ($locales as $locale) { |
|
| 42 | + foreach($locales as $locale) { |
|
| 43 | 43 | Searchable::$index_ctr = 0; |
| 44 | - $message('Indexing locale '.$locale); |
|
| 44 | + $message('Indexing locale ' . $locale); |
|
| 45 | 45 | |
| 46 | - if (class_exists('Translatable')) { |
|
| 46 | + if(class_exists('Translatable')) { |
|
| 47 | 47 | \Translatable::set_current_locale($locale); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | $this->service->refresh(); |
| 61 | 61 | // display indexing speed stats |
| 62 | 62 | $endTime = microtime(true); |
| 63 | - $elapsed = $endTime-$startTime; |
|
| 63 | + $elapsed = $endTime - $startTime; |
|
| 64 | 64 | $perSecond = Searchable::$index_ctr / $elapsed; |
| 65 | - $info = "\nReindexing $locale completed \n ".Searchable::$index_ctr." docs in ".round($elapsed,2)." seconds "; |
|
| 66 | - $info .= "at ".round($perSecond,2)." documents per second\n\n"; |
|
| 65 | + $info = "\nReindexing $locale completed \n " . Searchable::$index_ctr . " docs in " . round($elapsed, 2) . " seconds "; |
|
| 66 | + $info .= "at " . round($perSecond, 2) . " documents per second\n\n"; |
|
| 67 | 67 | $message($info); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $locales = array(); |
| 27 | 27 | |
| 28 | - if ($this->locale == null) { |
|
| 29 | - if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) { |
|
| 28 | + if($this->locale == null) { |
|
| 29 | + if(class_exists('Translatable') && \SiteTree::has_extension('Translatable')) { |
|
| 30 | 30 | $this->locale = \Translatable::get_current_locale(); |
| 31 | 31 | } else { |
| 32 | - foreach (\Translatable::get_existing_content_languages('SiteTree') as $code => $val) { |
|
| 32 | + foreach(\Translatable::get_existing_content_languages('SiteTree') as $code => $val) { |
|
| 33 | 33 | array_push($locales, $code); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | $es->setPageLength(20); |
| 43 | 43 | $es->addFilter('IsInSiteTree', true); |
| 44 | 44 | $results = $es->search($query); |
| 45 | - foreach ($results as $result) { |
|
| 46 | - $title = '['.$result->ClassName.', '.$result->ID.'] '; |
|
| 45 | + foreach($results as $result) { |
|
| 46 | + $title = '[' . $result->ClassName . ', ' . $result->ID . '] '; |
|
| 47 | 47 | $title .= $result->Title; |
| 48 | 48 | $message($title); |
| 49 | - if ($result->SearchHighlightsByField->Content) { |
|
| 50 | - foreach ($result->SearchHighlightsByField->Content as $highlight) { |
|
| 51 | - $message("- ".$highlight->Snippet); |
|
| 49 | + if($result->SearchHighlightsByField->Content) { |
|
| 50 | + foreach($result->SearchHighlightsByField->Content as $highlight) { |
|
| 51 | + $message("- " . $highlight->Snippet); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -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 |
@@ -201,16 +201,16 @@ discard block |
||
| 201 | 201 | $paginated = $es->search($query, $fields); |
| 202 | 202 | $ctr = 0; |
| 203 | 203 | |
| 204 | - foreach ($paginated->getList()->toArray() as $result) { |
|
| 204 | + foreach($paginated->getList()->toArray() as $result) { |
|
| 205 | 205 | $ctr++; |
| 206 | - foreach ($result->SearchHighlightsByField->Description_standard->getIterator() as $highlight) { |
|
| 206 | + foreach($result->SearchHighlightsByField->Description_standard->getIterator() as $highlight) { |
|
| 207 | 207 | $snippet = $highlight->Snippet; |
| 208 | 208 | $snippet = strtolower($snippet); |
| 209 | 209 | $wordFound = false; |
| 210 | 210 | $lcquery = explode(' ', strtolower($query)); |
| 211 | - foreach ($lcquery as $part) { |
|
| 211 | + foreach($lcquery as $part) { |
|
| 212 | 212 | $bracketed = '<strong class="hl">' . $part . '</strong>'; |
| 213 | - if (strpos($snippet, $bracketed) > 0) { |
|
| 213 | + if(strpos($snippet, $bracketed) > 0) { |
|
| 214 | 214 | $wordFound = true; |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -230,17 +230,17 @@ discard block |
||
| 230 | 230 | $paginated = $es->search($query, $fields); |
| 231 | 231 | $ctr = 0; |
| 232 | 232 | |
| 233 | - foreach ($paginated->getList()->toArray() as $result) { |
|
| 233 | + foreach($paginated->getList()->toArray() as $result) { |
|
| 234 | 234 | $ctr++; |
| 235 | 235 | |
| 236 | - foreach ($result->SearchHighlightsByField->Description->getIterator() as $highlight) { |
|
| 236 | + foreach($result->SearchHighlightsByField->Description->getIterator() as $highlight) { |
|
| 237 | 237 | $snippet = $highlight->Snippet; |
| 238 | 238 | $snippet = strtolower($snippet); |
| 239 | 239 | $wordFound = false; |
| 240 | 240 | $lcquery = explode(' ', strtolower($query)); |
| 241 | - foreach ($lcquery as $part) { |
|
| 241 | + foreach($lcquery as $part) { |
|
| 242 | 242 | $bracketed = '<strong class="hl">' . $part . '</strong>'; |
| 243 | - if (strpos($snippet, $bracketed) > 0) { |
|
| 243 | + if(strpos($snippet, $bracketed) > 0) { |
|
| 244 | 244 | $wordFound = true; |
| 245 | 245 | } |
| 246 | 246 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $query = 'Lond'; |
| 258 | 258 | $results = $es->autocomplete_search($query, 'Title'); |
| 259 | 259 | $this->assertEquals(7, $results->getTotalItems()); |
| 260 | - foreach ($results->toArray() as $result) { |
|
| 260 | + foreach($results->toArray() as $result) { |
|
| 261 | 261 | $this->assertTrue(strpos($result->Title, $query) > 0); |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $results = $paginated->getList()->toArray(); |
| 268 | 268 | $ctr = 0; |
| 269 | 269 | echo '$result = $paginated->getList()->toArray();' . "\n"; |
| 270 | - foreach ($results as $result) { |
|
| 270 | + foreach($results as $result) { |
|
| 271 | 271 | echo '$this->assertEquals("' . $result->Title . '", $results[' . $ctr . ']->Title);' . "\n"; |
| 272 | 272 | $ctr++; |
| 273 | 273 | } |
@@ -168,7 +168,7 @@ |
||
| 168 | 168 | $this->assertEquals(14, $paginated->getTotalItems()); |
| 169 | 169 | $this->makeCode($paginated); |
| 170 | 170 | } |
| 171 | - **/ |
|
| 171 | + **/ |
|
| 172 | 172 | |
| 173 | 173 | public function testSimilarNullFields() { |
| 174 | 174 | $fp = $this->objFromFixture('FlickrPhotoTO', 'photo0076'); |
@@ -18,7 +18,7 @@ |
||
| 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); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * Note: characters are stripped from the content; make sure that your assertions take this into account. |
| 126 | 126 | * |
| 127 | 127 | * @param string $selector A basic CSS selector, e.g. 'li.jobs h3' |
| 128 | - * @param array|string $expectedMatches The content of at least one of the matched tags |
|
| 128 | + * @param integer $index |
|
| 129 | 129 | * @throws PHPUnit_Framework_AssertionFailedError |
| 130 | 130 | * @return boolean |
| 131 | 131 | */ |
@@ -155,7 +155,8 @@ discard block |
||
| 155 | 155 | * Note: characters are stripped from the content; make sure that your assertions take this into account. |
| 156 | 156 | * |
| 157 | 157 | * @param string $selector A basic CSS selector, e.g. 'li.jobs h3' |
| 158 | - * @param array|string $expectedMatches The content of at least one of the matched tags |
|
| 158 | + * @param integer $index |
|
| 159 | + * @param string $expectedClause |
|
| 159 | 160 | * @throws PHPUnit_Framework_AssertionFailedError |
| 160 | 161 | * @return boolean |
| 161 | 162 | */ |
@@ -183,6 +184,12 @@ discard block |
||
| 183 | 184 | /* |
| 184 | 185 | Check all the nodes matching the selector for attribute name = expected value |
| 185 | 186 | */ |
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * @param string $selector |
|
| 190 | + * @param string $attributeName |
|
| 191 | + * @param string $expectedValue |
|
| 192 | + */ |
|
| 186 | 193 | public function assertAttributeHasExactValue($selector, $attributeName, $expectedValue) { |
| 187 | 194 | $items = $this->cssParser()->getBySelector($selector); |
| 188 | 195 | foreach ($items as $item) { |
@@ -191,6 +198,9 @@ discard block |
||
| 191 | 198 | } |
| 192 | 199 | |
| 193 | 200 | |
| 201 | + /** |
|
| 202 | + * @param string $selector |
|
| 203 | + */ |
|
| 194 | 204 | public function assertAttributesHaveExactValues($selector, $expectedValues) { |
| 195 | 205 | $attributeNames = array_keys($expectedValues); |
| 196 | 206 | $items = $this->cssParser()->getBySelector($selector); |
@@ -204,6 +214,10 @@ discard block |
||
| 204 | 214 | } |
| 205 | 215 | |
| 206 | 216 | |
| 217 | + /** |
|
| 218 | + * @param string $selector |
|
| 219 | + * @param integer $expectedAmount |
|
| 220 | + */ |
|
| 207 | 221 | public function assertNumberOfNodes($selector, $expectedAmount) { |
| 208 | 222 | $items = $this->cssParser()->getBySelector($selector); |
| 209 | 223 | foreach ($items as $item) { |
@@ -150,15 +150,15 @@ |
||
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | - *Assert that the indexth matching css node has a prefix as expected |
|
| 154 | - * |
|
| 155 | - * Note: characters are stripped from the content; make sure that your assertions take this into account. |
|
| 156 | - * |
|
| 157 | - * @param string $selector A basic CSS selector, e.g. 'li.jobs h3' |
|
| 158 | - * @param array|string $expectedMatches The content of at least one of the matched tags |
|
| 159 | - * @throws PHPUnit_Framework_AssertionFailedError |
|
| 160 | - * @return boolean |
|
| 161 | - */ |
|
| 153 | + *Assert that the indexth matching css node has a prefix as expected |
|
| 154 | + * |
|
| 155 | + * Note: characters are stripped from the content; make sure that your assertions take this into account. |
|
| 156 | + * |
|
| 157 | + * @param string $selector A basic CSS selector, e.g. 'li.jobs h3' |
|
| 158 | + * @param array|string $expectedMatches The content of at least one of the matched tags |
|
| 159 | + * @throws PHPUnit_Framework_AssertionFailedError |
|
| 160 | + * @return boolean |
|
| 161 | + */ |
|
| 162 | 162 | public function assertSelectorContains($selector, $index, $expectedClause) { |
| 163 | 163 | $items = $this->cssParser()->getBySelector($selector); |
| 164 | 164 | |
@@ -9,8 +9,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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++; |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $ctr = 0; |
| 173 | 173 | $item = strip_tags($items[$index]); |
| 174 | - if ($downcase) { |
|
| 174 | + if($downcase) { |
|
| 175 | 175 | $item = strtolower($item); |
| 176 | 176 | $expectedClause = strtolower($expectedClause); |
| 177 | 177 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function assertAttributeHasExactValue($selector, $attributeName, $expectedValue) { |
| 191 | 191 | $items = $this->cssParser()->getBySelector($selector); |
| 192 | - foreach ($items as $item) { |
|
| 192 | + foreach($items as $item) { |
|
| 193 | 193 | $this->assertEquals($expectedValue, $item['value']); |
| 194 | 194 | } |
| 195 | 195 | } |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | public function assertAttributesHaveExactValues($selector, $expectedValues) { |
| 199 | 199 | $attributeNames = array_keys($expectedValues); |
| 200 | 200 | $items = $this->cssParser()->getBySelector($selector); |
| 201 | - foreach ($items as $item) { |
|
| 201 | + foreach($items as $item) { |
|
| 202 | 202 | $actualValues = array(); |
| 203 | - foreach ($attributeNames as $attributeName) { |
|
| 203 | + foreach($attributeNames as $attributeName) { |
|
| 204 | 204 | $actualValues[$attributeName] = (string)$item[$attributeName]; |
| 205 | 205 | } |
| 206 | 206 | $this->assertEquals($expectedValues, $actualValues); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | public function assertNumberOfNodes($selector, $expectedAmount) { |
| 212 | 212 | $items = $this->cssParser()->getBySelector($selector); |
| 213 | - foreach ($items as $item) { |
|
| 213 | + foreach($items as $item) { |
|
| 214 | 214 | $text = strip_tags($item); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | public function collateSearchResults() { |
| 224 | 224 | $items = $this->cssParser()->getBySelector('div.searchResults .searchResult'); |
| 225 | 225 | $result = array(); |
| 226 | - foreach ($items as $item) { |
|
| 226 | + foreach($items as $item) { |
|
| 227 | 227 | $attr = $item->attributes()->id; |
| 228 | - array_push($result, $attr.""); |
|
| 228 | + array_push($result, $attr . ""); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | return $result; |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | $this->assertEquals(200, $searchPage->getStatusCode()); |
| 75 | 75 | $url = rtrim($url, '/'); |
| 76 | 76 | |
| 77 | - $response = $this->get($url); |
|
| 77 | + $response = $this->get($url); |
|
| 78 | 78 | |
| 79 | - $this->assertEquals(200, $response->getStatusCode()); |
|
| 79 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 80 | 80 | |
| 81 | - $this->assertSelectorStartsWithOrEquals('ul.iso span.count', 0, '(5)'); |
|
| 81 | + $this->assertSelectorStartsWithOrEquals('ul.iso span.count', 0, '(5)'); |
|
| 82 | 82 | $this->assertSelectorStartsWithOrEquals('ul.iso span.count', 1, '(11)'); |
| 83 | 83 | $this->assertSelectorStartsWithOrEquals('ul.iso span.count', 2, '(12)'); |
| 84 | 84 | $this->assertSelectorStartsWithOrEquals('ul.iso span.count', 3, '(13)'); |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | $url = rtrim($url, '/'); |
| 129 | 129 | $url .= '?ISO=400'; |
| 130 | 130 | |
| 131 | - $response = $this->get($url); |
|
| 131 | + $response = $this->get($url); |
|
| 132 | 132 | |
| 133 | - $this->assertEquals(200, $response->getStatusCode()); |
|
| 133 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 134 | 134 | |
| 135 | - // These are less than in the no facets selected case, as expected |
|
| 135 | + // These are less than in the no facets selected case, as expected |
|
| 136 | 136 | $this->assertSelectorStartsWithOrEquals('ul.focal_length span.count', 0, '(2)'); |
| 137 | 137 | $this->assertSelectorStartsWithOrEquals('ul.focal_length span.count', 1, '(1)'); |
| 138 | 138 | $this->assertSelectorStartsWithOrEquals('ul.focal_length span.count', 2, '(2)'); |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | $url = rtrim($url, '/'); |
| 177 | 177 | $url .= '?ISO=400&ShutterSpeed=2%2F250'; |
| 178 | 178 | |
| 179 | - $response = $this->get($url); |
|
| 180 | - $this->assertEquals(200, $response->getStatusCode()); |
|
| 179 | + $response = $this->get($url); |
|
| 180 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 181 | 181 | |
| 182 | - // These are less than in the one facet selected case, as expected |
|
| 183 | - $this->assertSelectorStartsWithOrEquals('ul.focal_length span.count', 0, '(1)'); |
|
| 182 | + // These are less than in the one facet selected case, as expected |
|
| 183 | + $this->assertSelectorStartsWithOrEquals('ul.focal_length span.count', 0, '(1)'); |
|
| 184 | 184 | $this->assertSelectorStartsWithOrEquals('ul.focal_length span.count', 1, '(2)'); |
| 185 | 185 | $this->assertSelectorStartsWithOrEquals('ul.aperture span.count', 0, '(1)'); |
| 186 | 186 | $this->assertSelectorStartsWithOrEquals('ul.aperture span.count', 1, '(1)'); |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | $url = rtrim($url, '/'); |
| 208 | 208 | $url .= '?ISO=400&ShutterSpeed=2%2F250&Aspect=Vertical'; |
| 209 | 209 | |
| 210 | - $response = $this->get($url); |
|
| 211 | - $this->assertEquals(200, $response->getStatusCode()); |
|
| 210 | + $response = $this->get($url); |
|
| 211 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 212 | 212 | |
| 213 | - // These are less than in the one facet selected case, as expected |
|
| 214 | - $this->assertSelectorStartsWithOrEquals('span.count', 0, '(2)'); |
|
| 213 | + // These are less than in the one facet selected case, as expected |
|
| 214 | + $this->assertSelectorStartsWithOrEquals('span.count', 0, '(2)'); |
|
| 215 | 215 | $this->assertSelectorStartsWithOrEquals('span.count', 1, '(1)'); |
| 216 | 216 | $this->assertSelectorStartsWithOrEquals('span.count', 2, '(1)'); |
| 217 | 217 | } |
@@ -542,13 +542,13 @@ discard block |
||
| 542 | 542 | $searchPage = $this->get($searchPageObj->URLSegment); |
| 543 | 543 | $this->assertEquals(200, $searchPage->getStatusCode()); |
| 544 | 544 | |
| 545 | - $response = $this->submitForm("ElasticSearchForm_SearchForm", null, array( |
|
| 546 | - 'q' => 'New Zealand' |
|
| 547 | - )); |
|
| 545 | + $response = $this->submitForm("ElasticSearchForm_SearchForm", null, array( |
|
| 546 | + 'q' => 'New Zealand' |
|
| 547 | + )); |
|
| 548 | 548 | |
| 549 | 549 | $url = rtrim($url, '/'); |
| 550 | - $this->assertEquals(302, $response->getStatusCode()); |
|
| 551 | - $this->assertEquals($url . '?q=New Zealand&sfid=testwithagg', $response->getHeader('Location')); |
|
| 550 | + $this->assertEquals(302, $response->getStatusCode()); |
|
| 551 | + $this->assertEquals($url . '?q=New Zealand&sfid=testwithagg', $response->getHeader('Location')); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | |
@@ -243,7 +243,7 @@ discard block |
||
| 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 |
||
| 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'); |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $this->assertEquals(200, $response->getStatusCode()); |
| 414 | 414 | |
| 415 | 415 | // results vary slightly due to sharding, hence check for a string instead of absolute results |
| 416 | - while ($ctr < 18) { |
|
| 416 | + while($ctr < 18) { |
|
| 417 | 417 | $this->assertSelectorContains('div.searchResult a', $ctr, 'New', true); |
| 418 | 418 | $ctr++; |
| 419 | 419 | $this->assertSelectorStartsWithOrEquals('div.searchResult a', $ctr, 'Similar'); |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | //Note pages need to be published, by default fixtures only reside in Stage |
| 451 | 451 | $searchPageObj = $this->ElasticSearchPage2; |
| 452 | 452 | $url = rtrim($searchPageObj->Link(), '/'); |
| 453 | - $url = $url.'?q='.$searchTerm; |
|
| 453 | + $url = $url . '?q=' . $searchTerm; |
|
| 454 | 454 | $response = $this->get($url); |
| 455 | 455 | $this->assertEquals(200, $response->getStatusCode()); |
| 456 | 456 | |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | //Note pages need to be published, by default fixtures only reside in Stage |
| 518 | 518 | $searchPageObj = $this->ElasticSearchPage; |
| 519 | 519 | $url = rtrim($searchPageObj->Link(), '/'); |
| 520 | - $url = $url.'?q='.$searchTerm; |
|
| 520 | + $url = $url . '?q=' . $searchTerm; |
|
| 521 | 521 | $response = $this->get($url); |
| 522 | 522 | $this->assertEquals(200, $response->getStatusCode()); |
| 523 | 523 | |
@@ -648,18 +648,18 @@ discard block |
||
| 648 | 648 | //increase the number of results and assert that they are the same as per pages 1,2 joined |
| 649 | 649 | $searchPageObj->ResultsPerPage = 20; |
| 650 | 650 | $searchPageObj->write(); |
| 651 | - $searchPageObj->publish('Stage','Live'); |
|
| 651 | + $searchPageObj->publish('Stage', 'Live'); |
|
| 652 | 652 | $response3 = $this->get($firstPageURL); |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | |
| 656 | 656 | private function enableHighlights() { |
| 657 | - foreach (SearchableField::get()->filter('Name', 'Title') as $sf) { |
|
| 657 | + foreach(SearchableField::get()->filter('Name', 'Title') as $sf) { |
|
| 658 | 658 | $sf->ShowHighlights = true; |
| 659 | 659 | $sf->write(); |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | - foreach (SearchableField::get()->filter('Name', 'Content') as $sf) { |
|
| 662 | + foreach(SearchableField::get()->filter('Name', 'Content') as $sf) { |
|
| 663 | 663 | $sf->ShowHighlights = true; |
| 664 | 664 | $sf->write(); |
| 665 | 665 | } |