@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | $stopwords = "a,the,then,this"; |
| 44 | 44 | $englishIndex = new EnglishIndexSettings(); |
| 45 | 45 | $englishIndex->setStopwords($stopwords); |
| 46 | - $expected = array('a','the','then','this'); |
|
| 46 | + $expected = array('a', 'the', 'then', 'this'); |
|
| 47 | 47 | $this->assertEquals($expected, $englishIndex->getStopwords()); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | public function testSetStopwordsConfigurationArray() { |
| 52 | - $stopwords = array('a','the','then','this'); |
|
| 52 | + $stopwords = array('a', 'the', 'then', 'this'); |
|
| 53 | 53 | $englishIndex = new EnglishIndexSettings(); |
| 54 | 54 | $englishIndex->setStopwords($stopwords); |
| 55 | - $expected = array('a','the','then','this'); |
|
| 55 | + $expected = array('a', 'the', 'then', 'this'); |
|
| 56 | 56 | $this->assertEquals($expected, $englishIndex->getStopwords()); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | public function testConfiguredStopWords() { |
| 77 | 77 | $englishIndex = new EnglishIndexSettings(); |
| 78 | 78 | $stopwords = $englishIndex->getStopwords(); |
| 79 | - $expected = array('that','into','a','an','and','are','as','at','be','but','by','for','if', |
|
| 80 | - 'in','into','is','it','of','on','or','such','that','the','their','then','there','these', |
|
| 81 | - 'they','this','to','was','will','with'); |
|
| 79 | + $expected = array('that', 'into', 'a', 'an', 'and', 'are', 'as', 'at', 'be', 'but', 'by', 'for', 'if', |
|
| 80 | + 'in', 'into', 'is', 'it', 'of', 'on', 'or', 'such', 'that', 'the', 'their', 'then', 'there', 'these', |
|
| 81 | + 'they', 'this', 'to', 'was', 'will', 'with'); |
|
| 82 | 82 | $this->assertEquals($expected, $stopwords); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | public function testResultListGetMap() { |
| 93 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 93 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 94 | 94 | //default is ID -> Title, useful for dropdowns |
| 95 | 95 | $mapping = $resultList->map(); |
| 96 | 96 | $ctr = 0; |
| 97 | - foreach ($resultList->getIterator() as $item) { |
|
| 97 | + foreach($resultList->getIterator() as $item) { |
|
| 98 | 98 | $mappedTitle = $mapping[$item->ID]; |
| 99 | 99 | $this->assertEquals($item->Title, $mappedTitle); |
| 100 | 100 | $ctr++; |
@@ -103,22 +103,22 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | public function testResultListColumn() { |
| 106 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 106 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 107 | 107 | $ids = $resultList->column(); |
| 108 | 108 | |
| 109 | 109 | $expected = array(); |
| 110 | - foreach ($resultList as $item) { |
|
| 110 | + foreach($resultList as $item) { |
|
| 111 | 111 | array_push($expected, $item->ID); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $this->assertEquals($expected,$ids); |
|
| 114 | + $this->assertEquals($expected, $ids); |
|
| 115 | 115 | |
| 116 | 116 | $expected = array(); |
| 117 | - foreach ($resultList as $item) { |
|
| 117 | + foreach($resultList as $item) { |
|
| 118 | 118 | array_push($expected, $item->Title); |
| 119 | 119 | } |
| 120 | 120 | $titles = $resultList->column('Title'); |
| 121 | - $this->assertEquals($expected,$titles); |
|
| 121 | + $this->assertEquals($expected, $titles); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $callback = function($fp) { |
| 127 | 127 | $this->assertTrue(true, 'Callback reached'); |
| 128 | 128 | }; |
| 129 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 129 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 130 | 130 | $resultList->each($callback); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -136,22 +136,22 @@ discard block |
||
| 136 | 136 | that all of the fixtures should have 'New Zealand' in them. Test page length from 1 to 100 |
| 137 | 137 | */ |
| 138 | 138 | public function testResultListPageLength() { |
| 139 | - for ($i=1; $i <= 100 ; $i++) { |
|
| 140 | - $resultList = $this->getResultsFor('New Zealand',$i); |
|
| 139 | + for($i = 1; $i <= 100; $i++) { |
|
| 140 | + $resultList = $this->getResultsFor('New Zealand', $i); |
|
| 141 | 141 | $this->assertEquals($i, $resultList->count()); |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | public function testResultListIndex() { |
| 147 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 147 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 148 | 148 | $index = $resultList->getService()->getIndex(); |
| 149 | 149 | $this->assertEquals('elastica_ss_module_test_en_us', $index->getName()); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | public function testResultListGetQuery() { |
| 154 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 154 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 155 | 155 | $query = $resultList->getQuery()->toArray(); |
| 156 | 156 | |
| 157 | 157 | $expected = array(); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | Check that the time for the search was more than zero |
| 177 | 177 | */ |
| 178 | 178 | public function testResultListGetTotalTime() { |
| 179 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 179 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 180 | 180 | $time = $resultList->getTotalTime(); |
| 181 | 181 | $this->assertGreaterThan(0, $time); |
| 182 | 182 | } |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | Test the result list iterator function |
| 187 | 187 | */ |
| 188 | 188 | public function testResultListGetIterator() { |
| 189 | - $resultList = $this->getResultsFor('New Zealand',100); |
|
| 189 | + $resultList = $this->getResultsFor('New Zealand', 100); |
|
| 190 | 190 | $ctr = 0; |
| 191 | - foreach ($resultList->getIterator() as $result) { |
|
| 191 | + foreach($resultList->getIterator() as $result) { |
|
| 192 | 192 | $ctr++; |
| 193 | 193 | } |
| 194 | - $this->assertEquals(100,$ctr); |
|
| 194 | + $this->assertEquals(100, $ctr); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | |
@@ -199,14 +199,14 @@ discard block |
||
| 199 | 199 | Check some basic properties of the array returned for a result |
| 200 | 200 | */ |
| 201 | 201 | public function testToArrayFunction() { |
| 202 | - $resultList = $this->getResultsFor('New Zealand',1); |
|
| 202 | + $resultList = $this->getResultsFor('New Zealand', 1); |
|
| 203 | 203 | $result = $resultList->toArray(); |
| 204 | 204 | |
| 205 | - $this->assertEquals(1,sizeof($result)); |
|
| 205 | + $this->assertEquals(1, sizeof($result)); |
|
| 206 | 206 | $fp = $result[0]; |
| 207 | 207 | $this->assertEquals('FlickrPhotoTO', $fp->ClassName); |
| 208 | 208 | $this->assertEquals(2147483647, $fp->FlickrID); |
| 209 | - $this->assertTrue(preg_match('/New Zealand/',$fp->Title) == 1); |
|
| 209 | + $this->assertTrue(preg_match('/New Zealand/', $fp->Title) == 1); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | |
@@ -214,20 +214,20 @@ discard block |
||
| 214 | 214 | Check some basic properties of the array returned for a result |
| 215 | 215 | */ |
| 216 | 216 | public function testToNestedArrayFunction() { |
| 217 | - $resultList = $this->getResultsFor('New Zealand',4); |
|
| 217 | + $resultList = $this->getResultsFor('New Zealand', 4); |
|
| 218 | 218 | $result = $resultList->toNestedArray(); |
| 219 | 219 | |
| 220 | - $this->assertEquals(4,sizeof($result)); |
|
| 220 | + $this->assertEquals(4, sizeof($result)); |
|
| 221 | 221 | $fp = $result[0]; |
| 222 | 222 | $this->assertEquals('FlickrPhotoTO', $fp['ClassName']); |
| 223 | 223 | $this->assertEquals(2147483647, $fp['FlickrID']); |
| 224 | - $this->assertTrue(preg_match('/New Zealand/',$fp['Title']) == 1); |
|
| 224 | + $this->assertTrue(preg_match('/New Zealand/', $fp['Title']) == 1); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | |
| 228 | 228 | public function testResultListOffsetExistsNotImplemented() { |
| 229 | 229 | try { |
| 230 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 230 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 231 | 231 | $resultList->offsetExists(10); |
| 232 | 232 | $this->assertFalse(true, "This line should not have been reached"); |
| 233 | 233 | } catch (Exception $e) { |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | public function testResultListOffsetGetNotImplemented() { |
| 240 | 240 | try { |
| 241 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 241 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 242 | 242 | $resultList->offsetGet(10); |
| 243 | 243 | $this->assertFalse(true, "This line should not have been reached"); |
| 244 | 244 | } catch (Exception $e) { |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | public function testResultListOffsetSetNotImplemented() { |
| 251 | 251 | try { |
| 252 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 253 | - $resultList->offsetSet(10,null); |
|
| 252 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 253 | + $resultList->offsetSet(10, null); |
|
| 254 | 254 | $this->assertFalse(true, "This line should not have been reached"); |
| 255 | 255 | } catch (Exception $e) { |
| 256 | 256 | $this->assertEquals('Not implemented', $e->getMessage()); |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | public function testResultListOffsetUnsetNotImplemented() { |
| 262 | 262 | try { |
| 263 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 263 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 264 | 264 | $resultList->offsetUnset(10); |
| 265 | 265 | $this->assertFalse(true, "This line should not have been reached"); |
| 266 | 266 | } catch (Exception $e) { |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | public function testResultListAddNotImplemented() { |
| 273 | 273 | try { |
| 274 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 274 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 275 | 275 | $fp = new FlickrPhotoTO(); |
| 276 | 276 | $resultList->add($fp); |
| 277 | 277 | $this->assertFalse(true, "This line should not have been reached"); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | public function testResultListRemoveNotImplemented() { |
| 285 | 285 | try { |
| 286 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 286 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 287 | 287 | $fp = new FlickrPhotoTO(); |
| 288 | 288 | $resultList->remove($fp); |
| 289 | 289 | $this->assertFalse(true, "This line should not have been reached"); |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | public function testResultListFindNotImplemented() { |
| 297 | 297 | try { |
| 298 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 298 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 299 | 299 | $fp = new FlickrPhotoTO(); |
| 300 | - $resultList->find(4,$fp); |
|
| 300 | + $resultList->find(4, $fp); |
|
| 301 | 301 | $this->assertFalse(true, "This line should not have been reached"); |
| 302 | 302 | } catch (Exception $e) { |
| 303 | 303 | $this->assertEquals('Not implemented', $e->getMessage()); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | public function testResultListToArray() { |
| 311 | 311 | $sfs = SearchableField::get()->filter(array('ClazzName' => 'FlickrPhotoTO', 'Type' => 'string')); |
| 312 | - foreach ($sfs->getIterator() as $sf) { |
|
| 312 | + foreach($sfs->getIterator() as $sf) { |
|
| 313 | 313 | echo "T2 $sf->ClazzName $sf->Name $sf->Type\n"; |
| 314 | 314 | $sf->ShowHighlights = true; |
| 315 | 315 | $sf->write(); |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | $toarr = $resultList->toArray(); |
| 323 | 323 | |
| 324 | - foreach ($toarr as $item) { |
|
| 324 | + foreach($toarr as $item) { |
|
| 325 | 325 | $hl = $item->SearchHighlights; |
| 326 | 326 | echo "HL:$hl"; // MORNING FIXME |
| 327 | 327 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | public function testResultListFirstNotImplemented() { |
| 333 | 333 | try { |
| 334 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 334 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 335 | 335 | $resultList->first(); |
| 336 | 336 | $this->assertFalse(true, "This line should not have been reached"); |
| 337 | 337 | } catch (Exception $e) { |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | public function testResultListLastNotImplemented() { |
| 344 | 344 | try { |
| 345 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
| 345 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
| 346 | 346 | $resultList->last(); |
| 347 | 347 | $this->assertFalse(true, "This line should not have been reached"); |
| 348 | 348 | } catch (Exception $e) { |