@@ -38,6 +38,9 @@ |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | + /** |
|
42 | + * @param string $q |
|
43 | + */ |
|
41 | 44 | private function getDefaultSuggest($q) { |
42 | 45 | return array( |
43 | 46 | 'query-phrase-suggestions' => array( |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $qg->setShowResultsForEmptyQuery(false); |
124 | 124 | $qs = array('multi_match' => array( |
125 | - 'fields' => array('Title','Title.*','Description','Description.*'), |
|
125 | + 'fields' => array('Title', 'Title.*', 'Description', 'Description.*'), |
|
126 | 126 | 'type' => 'most_fields', |
127 | 127 | 'query' => 'New Zealand', |
128 | 128 | 'lenient' => true |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $qg->setShowResultsForEmptyQuery(false); |
159 | 159 | $qs = array( |
160 | 160 | 'multi_match' => array( |
161 | - 'fields' => array('Title','Title.*','Description','Description.*'), |
|
161 | + 'fields' => array('Title', 'Title.*', 'Description', 'Description.*'), |
|
162 | 162 | 'type' => 'most_fields', |
163 | 163 | 'query' => '', |
164 | 164 | 'lenient' => true |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | 'filtered' => array( |
370 | 370 | 'filter' => |
371 | 371 | array('and' => array( |
372 | - 0 => array( 'term' => array('ISO' => 400)), |
|
373 | - 1 => array( 'range' => array( |
|
372 | + 0 => array('term' => array('ISO' => 400)), |
|
373 | + 1 => array('range' => array( |
|
374 | 374 | 'AspectRatio' => array( |
375 | 375 | 'gte' => '0.9', |
376 | 376 | 'lt' => '1.2' |
@@ -413,14 +413,14 @@ discard block |
||
413 | 413 | 'query' => array( |
414 | 414 | 'filtered' => array('filter' => |
415 | 415 | array('and' => array( |
416 | - 0 => array( 'term' => array('ISO' => 400)), |
|
417 | - 1 => array( 'range' => array( |
|
416 | + 0 => array('term' => array('ISO' => 400)), |
|
417 | + 1 => array('range' => array( |
|
418 | 418 | 'AspectRatio' => array( |
419 | 419 | 'gte' => '0.9', |
420 | 420 | 'lt' => '1.2' |
421 | 421 | ) |
422 | 422 | )), |
423 | - 2 => array( 'term' => array('Aperture' => 5.6)), |
|
423 | + 2 => array('term' => array('Aperture' => 5.6)), |
|
424 | 424 | ) |
425 | 425 | )) |
426 | 426 | ), |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | $expected['query']['filtered']['query']['multi_match'] = array( |
473 | 473 | 'query' => 'New Zealand', |
474 | 474 | 'lenient' => true, |
475 | - 'fields' => array('Title^2', 'Title.*^2','Content', 'Content.*'), |
|
475 | + 'fields' => array('Title^2', 'Title.*^2', 'Content', 'Content.*'), |
|
476 | 476 | 'type' => 'most_fields' |
477 | 477 | ); |
478 | 478 | |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | 'filtered' => array( |
504 | 504 | 'filter' => |
505 | 505 | array('and' => array( |
506 | - 0 => array( 'term' => array('ISO' => 400)), |
|
507 | - 1 => array( 'range' => array( |
|
506 | + 0 => array('term' => array('ISO' => 400)), |
|
507 | + 1 => array('range' => array( |
|
508 | 508 | 'AspectRatio' => array( |
509 | 509 | 'gte' => '0.9', |
510 | 510 | 'lt' => '1.2' |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | $expected['query']['filtered']['query']['multi_match'] = array( |
526 | 526 | 'query' => 'New Zealand', |
527 | 527 | 'lenient' => true, |
528 | - 'fields' => array('Title^2', 'Title.*^2','Content', 'Content.*'), |
|
528 | + 'fields' => array('Title^2', 'Title.*^2', 'Content', 'Content.*'), |
|
529 | 529 | 'type' => 'most_fields' |
530 | 530 | ); |
531 | 531 | $expected['suggest'] = $this->getDefaultSuggest('New Zealand'); |
@@ -553,14 +553,14 @@ discard block |
||
553 | 553 | 'query' => array( |
554 | 554 | 'filtered' => array('filter' => |
555 | 555 | array('and' => array( |
556 | - 0 => array( 'term' => array('ISO' => 400)), |
|
557 | - 1 => array( 'range' => array( |
|
556 | + 0 => array('term' => array('ISO' => 400)), |
|
557 | + 1 => array('range' => array( |
|
558 | 558 | 'AspectRatio' => array( |
559 | 559 | 'gte' => '0.9', |
560 | 560 | 'lt' => '1.2' |
561 | 561 | ) |
562 | 562 | )), |
563 | - 2 => array( 'term' => array('Aperture' => 5.6)), |
|
563 | + 2 => array('term' => array('Aperture' => 5.6)), |
|
564 | 564 | ) |
565 | 565 | )) |
566 | 566 | ), |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | $expected['query']['filtered']['query']['multi_match'] = array( |
576 | 576 | 'query' => 'New Zealand', |
577 | 577 | 'lenient' => true, |
578 | - 'fields' => array('Title^2', 'Title.*^2','Content', 'Content.*'), |
|
578 | + 'fields' => array('Title^2', 'Title.*^2', 'Content', 'Content.*'), |
|
579 | 579 | 'type' => 'most_fields' |
580 | 580 | ); |
581 | 581 | $expected['suggest'] = $this->getDefaultSuggest('New Zealand'); |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | $qg = new QueryGenerator(); |
591 | 591 | $qg->setClasses('FlickrPhotoTO'); |
592 | 592 | $fields = array('Title' => 1, 'Description' => 1); |
593 | - $expected = array('Title', 'Title.*','Description', 'Description.*'); |
|
593 | + $expected = array('Title', 'Title.*', 'Description', 'Description.*'); |
|
594 | 594 | $this->assertEquals($expected, $qg->convertWeightedFieldsForElastica($fields)); |
595 | 595 | } |
596 | 596 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | $qg = new QueryGenerator(); |
600 | 600 | $qg->setClasses('FlickrPhotoTO'); |
601 | 601 | $fields = array('Title' => 2, 'Description' => 1); |
602 | - $expected = array('Title^2', 'Title.*^2','Description', 'Description.*'); |
|
602 | + $expected = array('Title^2', 'Title.*^2', 'Description', 'Description.*'); |
|
603 | 603 | $this->assertEquals($expected, $qg->convertWeightedFieldsForElastica($fields)); |
604 | 604 | } |
605 | 605 | |
@@ -631,10 +631,10 @@ discard block |
||
631 | 631 | $qg = new QueryGenerator(); |
632 | 632 | $qg->setClasses('FlickrPhotoTO,Page'); |
633 | 633 | $fields = array('Title' => 2, 'Description' => 1); |
634 | - $expected = array('Title^2', 'Title.*^2','Description', 'Description.*'); |
|
634 | + $expected = array('Title^2', 'Title.*^2', 'Description', 'Description.*'); |
|
635 | 635 | $this->assertEquals($expected, $qg->convertWeightedFieldsForElastica($fields)); |
636 | 636 | |
637 | - $qg->setClasses(array('FlickrPhotoTO','Page')); |
|
637 | + $qg->setClasses(array('FlickrPhotoTO', 'Page')); |
|
638 | 638 | $this->assertEquals($expected, $qg->convertWeightedFieldsForElastica($fields)); |
639 | 639 | |
640 | 640 | } |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | $qg = new QueryGenerator(); |
649 | 649 | $qg->setClasses('FlickrPhotoTO,Page'); |
650 | 650 | $fields = array('Title' => 2, 'Description' => 1); |
651 | - $expected = array('Title^2', 'Title.*^2','Description', 'Description.*'); |
|
651 | + $expected = array('Title^2', 'Title.*^2', 'Description', 'Description.*'); |
|
652 | 652 | $this->assertEquals($expected, $qg->convertWeightedFieldsForElastica($fields)); |
653 | 653 | |
654 | 654 | //Execute a 2nd time |
@@ -667,11 +667,11 @@ discard block |
||
667 | 667 | $qg = new QueryGenerator(); |
668 | 668 | $qg->setClasses(null); // select all of site tree classes |
669 | 669 | $fields = array('Title' => 2, 'Content' => 1); |
670 | - $expected = array('Title^2', 'Title.*^2','Content', 'Content.*'); |
|
670 | + $expected = array('Title^2', 'Title.*^2', 'Content', 'Content.*'); |
|
671 | 671 | $this->assertEquals($expected, $qg->convertWeightedFieldsForElastica($fields)); |
672 | 672 | |
673 | 673 | echo "--------------------\n"; |
674 | - $qg->setClasses(array('FlickrPhotoTO','Page')); |
|
674 | + $qg->setClasses(array('FlickrPhotoTO', 'Page')); |
|
675 | 675 | $this->assertEquals($expected, $qg->convertWeightedFieldsForElastica($fields)); |
676 | 676 | |
677 | 677 | } |
@@ -720,21 +720,21 @@ discard block |
||
720 | 720 | 'order' => array('_term' => 'asc') |
721 | 721 | ) |
722 | 722 | ); |
723 | - $result['ShutterSpeed'] = array( |
|
723 | + $result['ShutterSpeed'] = array( |
|
724 | 724 | 'terms' => array( |
725 | 725 | 'field' => 'ShutterSpeed', |
726 | 726 | 'size' => 0, |
727 | 727 | 'order' => array('_term' => 'asc') |
728 | 728 | ) |
729 | 729 | ); |
730 | - $result['FocalLength35mm'] = array( |
|
730 | + $result['FocalLength35mm'] = array( |
|
731 | 731 | 'terms' => array( |
732 | 732 | 'field' => 'FocalLength35mm', |
733 | 733 | 'size' => 0, |
734 | 734 | 'order' => array('_term' => 'asc') |
735 | 735 | ) |
736 | 736 | ); |
737 | - $result['ISO'] = array( |
|
737 | + $result['ISO'] = array( |
|
738 | 738 | 'terms' => array( |
739 | 739 | 'field' => 'ISO', |
740 | 740 | 'size' => 0, |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | $ranges[3] = array('from' => '1.2', 'to' => '1.79', 'key' => 'Vertical'); |
750 | 750 | $ranges[4] = array('from' => '1.79', 'to' => '10000000', 'key' => 'Tallest'); |
751 | 751 | |
752 | - $result['Aspect'] = array( |
|
752 | + $result['Aspect'] = array( |
|
753 | 753 | 'range' => array( |
754 | 754 | 'field' => 'AspectRatio', |
755 | 755 | 'ranges' => $ranges |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | |
770 | 770 | public function testToQuotedCSVFromArray() { |
771 | 771 | $expected = "'Bangkok','Nonthaburi','Saraburi','Chiang Mai'"; |
772 | - $items = array('Bangkok','Nonthaburi','Saraburi','Chiang Mai'); |
|
772 | + $items = array('Bangkok', 'Nonthaburi', 'Saraburi', 'Chiang Mai'); |
|
773 | 773 | $quoted = QueryGenerator::convertToQuotedCSV($items); |
774 | 774 | $this->assertEquals($expected, $quoted); |
775 | 775 | } |
@@ -479,6 +479,9 @@ |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | |
482 | + /** |
|
483 | + * @param string $query |
|
484 | + */ |
|
482 | 485 | private function getResultsFor($query, $pageLength = 10, $fields = array('Title' => 1, 'Description' => 1)) { |
483 | 486 | $es = new ElasticSearcher(); |
484 | 487 | $es->setStart(0); |
@@ -140,7 +140,7 @@ |
||
140 | 140 | |
141 | 141 | public function testEach() { |
142 | 142 | $callback = function($fp) { |
143 | - $this->assertTrue(true, 'Callback reached'); |
|
143 | + $this->assertTrue(true, 'Callback reached'); |
|
144 | 144 | }; |
145 | 145 | $resultList = $this->getResultsFor('New Zealand',10); |
146 | 146 | $resultList->each($callback); |
@@ -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 | |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | 'ISO' => 1 |
93 | 93 | ); |
94 | 94 | |
95 | - $expected = array('that','into','a','an','and','are','as','at','be','but','by','for','if', |
|
96 | - 'in','into','is','it','of','on','or','such','that','the','their','then','there','these', |
|
97 | - 'they','this','to','was','will','with'); |
|
95 | + $expected = array('that', 'into', 'a', 'an', 'and', 'are', 'as', 'at', 'be', 'but', 'by', 'for', 'if', |
|
96 | + 'in', 'into', 'is', 'it', 'of', 'on', 'or', 'such', 'that', 'the', 'their', 'then', 'there', 'these', |
|
97 | + 'they', 'this', 'to', 'was', 'will', 'with'); |
|
98 | 98 | $this->assertEquals($expected, $stopwords); |
99 | 99 | } |
100 | 100 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | |
108 | 108 | public function testResultListGetMap() { |
109 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
109 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
110 | 110 | //default is ID -> Title, useful for dropdowns |
111 | 111 | $mapping = $resultList->map(); |
112 | 112 | $ctr = 0; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | |
121 | 121 | public function testResultListColumn() { |
122 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
122 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
123 | 123 | $ids = $resultList->column(); |
124 | 124 | |
125 | 125 | $expected = array(); |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | array_push($expected, $item->ID); |
128 | 128 | } |
129 | 129 | |
130 | - $this->assertEquals($expected,$ids); |
|
130 | + $this->assertEquals($expected, $ids); |
|
131 | 131 | |
132 | 132 | $expected = array(); |
133 | 133 | foreach ($resultList as $item) { |
134 | 134 | array_push($expected, $item->Title); |
135 | 135 | } |
136 | 136 | $titles = $resultList->column('Title'); |
137 | - $this->assertEquals($expected,$titles); |
|
137 | + $this->assertEquals($expected, $titles); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $callback = function($fp) { |
143 | 143 | $this->assertTrue(true, 'Callback reached'); |
144 | 144 | }; |
145 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
145 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
146 | 146 | $resultList->each($callback); |
147 | 147 | } |
148 | 148 | |
@@ -152,22 +152,22 @@ discard block |
||
152 | 152 | that all of the fixtures should have 'New Zealand' in them. Test page length from 1 to 100 |
153 | 153 | */ |
154 | 154 | public function testResultListPageLength() { |
155 | - for ($i=1; $i <= 100 ; $i++) { |
|
156 | - $resultList = $this->getResultsFor('New Zealand',$i); |
|
155 | + for ($i = 1; $i <= 100; $i++) { |
|
156 | + $resultList = $this->getResultsFor('New Zealand', $i); |
|
157 | 157 | $this->assertEquals($i, $resultList->count()); |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | 162 | public function testResultListIndex() { |
163 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
163 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
164 | 164 | $index = $resultList->getService()->getIndex(); |
165 | 165 | $this->assertEquals('elastica_ss_module_test_en_us', $index->getName()); |
166 | 166 | } |
167 | 167 | |
168 | 168 | |
169 | 169 | public function testResultListGetQuery() { |
170 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
170 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
171 | 171 | $query = $resultList->getQuery()->toArray(); |
172 | 172 | |
173 | 173 | $expected = array(); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | Check that the time for the search was more than zero |
193 | 193 | */ |
194 | 194 | public function testResultListGetTotalTime() { |
195 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
195 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
196 | 196 | $time = $resultList->getTotalTime(); |
197 | 197 | $this->assertGreaterThan(0, $time); |
198 | 198 | } |
@@ -202,12 +202,12 @@ discard block |
||
202 | 202 | Test the result list iterator function |
203 | 203 | */ |
204 | 204 | public function testResultListGetIterator() { |
205 | - $resultList = $this->getResultsFor('New Zealand',100); |
|
205 | + $resultList = $this->getResultsFor('New Zealand', 100); |
|
206 | 206 | $ctr = 0; |
207 | 207 | foreach ($resultList->getIterator() as $result) { |
208 | 208 | $ctr++; |
209 | 209 | } |
210 | - $this->assertEquals(100,$ctr); |
|
210 | + $this->assertEquals(100, $ctr); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | Check some basic properties of the array returned for a result |
216 | 216 | */ |
217 | 217 | public function testToArrayFunction() { |
218 | - $resultList = $this->getResultsFor('New Zealand',1); |
|
218 | + $resultList = $this->getResultsFor('New Zealand', 1); |
|
219 | 219 | $expected = array(); |
220 | 220 | $result = $resultList->toArray(); |
221 | 221 | |
222 | - $this->assertEquals(1,sizeof($result)); |
|
222 | + $this->assertEquals(1, sizeof($result)); |
|
223 | 223 | $fp = $result[0]; |
224 | 224 | $this->assertEquals('FlickrPhotoTO', $fp->ClassName); |
225 | 225 | $this->assertEquals(2147483647, $fp->FlickrID); |
226 | - $this->assertTrue(preg_match('/New Zealand/',$fp->Title) == 1); |
|
226 | + $this->assertTrue(preg_match('/New Zealand/', $fp->Title) == 1); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -231,21 +231,21 @@ discard block |
||
231 | 231 | Check some basic properties of the array returned for a result |
232 | 232 | */ |
233 | 233 | public function testToNestedArrayFunction() { |
234 | - $resultList = $this->getResultsFor('New Zealand',4); |
|
234 | + $resultList = $this->getResultsFor('New Zealand', 4); |
|
235 | 235 | $expected = array(); |
236 | 236 | $result = $resultList->toNestedArray(); |
237 | 237 | |
238 | - $this->assertEquals(4,sizeof($result)); |
|
238 | + $this->assertEquals(4, sizeof($result)); |
|
239 | 239 | $fp = $result[0]; |
240 | 240 | $this->assertEquals('FlickrPhotoTO', $fp['ClassName']); |
241 | 241 | $this->assertEquals(2147483647, $fp['FlickrID']); |
242 | - $this->assertTrue(preg_match('/New Zealand/',$fp['Title']) == 1); |
|
242 | + $this->assertTrue(preg_match('/New Zealand/', $fp['Title']) == 1); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
246 | 246 | public function testResultListOffsetExistsNotImplemented() { |
247 | 247 | try { |
248 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
248 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
249 | 249 | $resultList->offsetExists(10); |
250 | 250 | $this->assertFalse(true, "This line should not have been reached"); |
251 | 251 | } catch (Exception $e) { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | public function testResultListOffsetGetNotImplemented() { |
258 | 258 | try { |
259 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
259 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
260 | 260 | $resultList->offsetGet(10); |
261 | 261 | $this->assertFalse(true, "This line should not have been reached"); |
262 | 262 | } catch (Exception $e) { |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | |
268 | 268 | public function testResultListOffsetSetNotImplemented() { |
269 | 269 | try { |
270 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
271 | - $resultList->offsetSet(10,null); |
|
270 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
271 | + $resultList->offsetSet(10, null); |
|
272 | 272 | $this->assertFalse(true, "This line should not have been reached"); |
273 | 273 | } catch (Exception $e) { |
274 | 274 | $this->assertEquals('Not implemented', $e->getMessage()); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | public function testResultListOffsetUnsetNotImplemented() { |
280 | 280 | try { |
281 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
281 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
282 | 282 | $resultList->offsetUnset(10); |
283 | 283 | $this->assertFalse(true, "This line should not have been reached"); |
284 | 284 | } catch (Exception $e) { |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | public function testResultListAddNotImplemented() { |
291 | 291 | try { |
292 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
292 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
293 | 293 | $fp = new FlickrPhotoTO(); |
294 | 294 | $resultList->add($fp); |
295 | 295 | $this->assertFalse(true, "This line should not have been reached"); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | public function testResultListRemoveNotImplemented() { |
303 | 303 | try { |
304 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
304 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
305 | 305 | $fp = new FlickrPhotoTO(); |
306 | 306 | $resultList->remove($fp); |
307 | 307 | $this->assertFalse(true, "This line should not have been reached"); |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | |
314 | 314 | public function testResultListFindNotImplemented() { |
315 | 315 | try { |
316 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
316 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
317 | 317 | $fp = new FlickrPhotoTO(); |
318 | - $resultList->find(4,$fp); |
|
318 | + $resultList->find(4, $fp); |
|
319 | 319 | $this->assertFalse(true, "This line should not have been reached"); |
320 | 320 | } catch (Exception $e) { |
321 | 321 | $this->assertEquals('Not implemented', $e->getMessage()); |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | |
352 | 352 | public function testResultListFirstNotImplemented() { |
353 | 353 | try { |
354 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
354 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
355 | 355 | $fp = new FlickrPhotoTO(); |
356 | - $resultList->first(4,$fp); |
|
356 | + $resultList->first(4, $fp); |
|
357 | 357 | $this->assertFalse(true, "This line should not have been reached"); |
358 | 358 | } catch (Exception $e) { |
359 | 359 | $this->assertEquals('Not implemented', $e->getMessage()); |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | |
364 | 364 | public function testResultListLastNotImplemented() { |
365 | 365 | try { |
366 | - $resultList = $this->getResultsFor('New Zealand',10); |
|
366 | + $resultList = $this->getResultsFor('New Zealand', 10); |
|
367 | 367 | $fp = new FlickrPhotoTO(); |
368 | - $resultList->last(4,$fp); |
|
368 | + $resultList->last(4, $fp); |
|
369 | 369 | $this->assertFalse(true, "This line should not have been reached"); |
370 | 370 | } catch (Exception $e) { |
371 | 371 | $this->assertEquals('Not implemented', $e->getMessage()); |
@@ -233,6 +233,9 @@ |
||
233 | 233 | |
234 | 234 | |
235 | 235 | |
236 | + /** |
|
237 | + * @param PaginatedList $paginated |
|
238 | + */ |
|
236 | 239 | private function makeCode($paginated) { |
237 | 240 | $results = $paginated->getList()->toArray(); |
238 | 241 | $ctr = 0; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $form = new \ElasticSearchForm(new \Controller(), 'TestForm'); |
21 | 21 | $fields = $form->Fields(); |
22 | 22 | $result = array(); |
23 | - foreach($fields as $field) { |
|
23 | + foreach ($fields as $field) { |
|
24 | 24 | echo $field->getName(); |
25 | 25 | $result[$field->getName()] = $field->Value(); |
26 | 26 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | $wordFound = false; |
52 | 52 | $lcquery = explode(' ', strtolower($query)); |
53 | 53 | foreach ($lcquery as $part) { |
54 | - $bracketed = '<strong class="hl">'.$part.'</strong>'; |
|
54 | + $bracketed = '<strong class="hl">' . $part . '</strong>'; |
|
55 | 55 | if (strpos($snippet, $bracketed) > 0) { |
56 | 56 | $wordFound = true; |
57 | 57 | } |
58 | 58 | } |
59 | - $this->assertTrue($wordFound,'Highlight should have been found'); |
|
59 | + $this->assertTrue($wordFound, 'Highlight should have been found'); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $es->setLocale($locale); |
90 | 90 | $es->setClasses('FlickrPhotoTO'); |
91 | 91 | |
92 | - $fields = array('Description.standard' => 1,'Title.standard' => 1); |
|
92 | + $fields = array('Description.standard' => 1, 'Title.standard' => 1); |
|
93 | 93 | $results = $es->moreLikeThis($fp, $fields, true); |
94 | 94 | |
95 | 95 | echo "RESULTS:\n"; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $expected = array('texas'); |
111 | 111 | $this->assertEquals($expected, $terms['Title.standard']); |
112 | 112 | |
113 | - $expected = array('new', 'see','photographs', 'information','resolution', 'company', 'view', |
|
113 | + $expected = array('new', 'see', 'photographs', 'information', 'resolution', 'company', 'view', |
|
114 | 114 | 'high', 'collection', 'pacific', 'orleans', 'degolyer', 'southern', 'everett', |
115 | 115 | 'railroad', 'texas'); |
116 | 116 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $fields = array('Title.standard' => 1, 'Description.standard' => 1); |
145 | 145 | $paginated = $es->moreLikeThis($fp, $fields, true); |
146 | 146 | foreach ($paginated->getList() as $result) { |
147 | - echo $result->ID. ' : '.$result->Title."\n"; |
|
147 | + echo $result->ID . ' : ' . $result->Title . "\n"; |
|
148 | 148 | } |
149 | 149 | $this->assertEquals(32, $paginated->getTotalItems()); |
150 | 150 | $results = $paginated->getList()->toArray(); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | //Check that the number of indexing requests has increased by 2 |
180 | 180 | $deltaReqs = $this->service->getIndexingRequestCtr() - $reqs; |
181 | 181 | //One call is made for each of Page and FlickrPhotoTO |
182 | - $this->assertEquals(2,$deltaReqs); |
|
182 | + $this->assertEquals(2, $deltaReqs); |
|
183 | 183 | |
184 | 184 | // default installed pages plus 100 FlickrPhotoTOs |
185 | 185 | $this->checkNumberOfIndexedDocuments(103); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $fields = array('Title.standard' => 1, 'Description.standard' => 1); |
196 | 196 | $paginated = $es->moreLikeThis($fp, $fields, true); |
197 | 197 | foreach ($paginated->getList() as $result) { |
198 | - echo $result->ID. ' : '.$result->Title."\n"; |
|
198 | + echo $result->ID . ' : ' . $result->Title . "\n"; |
|
199 | 199 | } |
200 | 200 | $this->assertEquals(14, $paginated->getTotalItems()); |
201 | 201 | $results = $paginated->getList()->toArray(); |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | private function makeCode($paginated) { |
237 | 237 | $results = $paginated->getList()->toArray(); |
238 | 238 | $ctr = 0; |
239 | - echo '$result = $paginated->getList()->toArray();'."\n"; |
|
239 | + echo '$result = $paginated->getList()->toArray();' . "\n"; |
|
240 | 240 | foreach ($results as $result) { |
241 | - echo '$this->assertEquals("'.$result->Title.'", $results['.$ctr.']->Title);'."\n"; |
|
241 | + echo '$this->assertEquals("' . $result->Title . '", $results[' . $ctr . ']->Title);' . "\n"; |
|
242 | 242 | $ctr++; |
243 | 243 | } |
244 | 244 | } |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | $config->removeComponent($config->getComponentByType('GridFieldDeleteAction')); |
30 | 30 | |
31 | 31 | $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array( |
32 | - 'Name' => 'Name', |
|
33 | - 'Weight' => 'Weighting', |
|
34 | - 'Searchable' => 'Search this field?' |
|
35 | - )); |
|
32 | + 'Name' => 'Name', |
|
33 | + 'Weight' => 'Weighting', |
|
34 | + 'Searchable' => 'Search this field?' |
|
35 | + )); |
|
36 | 36 | |
37 | 37 | |
38 | - $gridField = new GridField( |
|
39 | - 'SearchableField', // Field name |
|
40 | - 'Field Name', // Field title |
|
41 | - SearchableField::get()->filter('SearchableClassID', $this->ID)->sort('Name'), |
|
42 | - $config |
|
43 | - ); |
|
38 | + $gridField = new GridField( |
|
39 | + 'SearchableField', // Field name |
|
40 | + 'Field Name', // Field title |
|
41 | + SearchableField::get()->filter('SearchableClassID', $this->ID)->sort('Name'), |
|
42 | + $config |
|
43 | + ); |
|
44 | 44 | |
45 | - $fields->addFieldToTab('Root.Main', $gridField); |
|
45 | + $fields->addFieldToTab('Root.Main', $gridField); |
|
46 | 46 | |
47 | 47 | /* |
48 | 48 | $fields = new FieldList(); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | |
52 | 52 | */ |
53 | - return $fields; |
|
53 | + return $fields; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 |
@@ -15,10 +15,10 @@ |
||
15 | 15 | |
16 | 16 | $fields = new FieldList(); |
17 | 17 | |
18 | - $fields->push( new TabSet( "Root", $mainTab = new Tab( "Main" ) ) ); |
|
19 | - $mainTab->setTitle( _t( 'SiteTree.TABMAIN', "Main" ) ); |
|
18 | + $fields->push(new TabSet("Root", $mainTab = new Tab("Main"))); |
|
19 | + $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main")); |
|
20 | 20 | |
21 | - $fields->addFieldToTab( 'Root.Main', $nf = new TextField( 'Name', 'Name') ); |
|
21 | + $fields->addFieldToTab('Root.Main', $nf = new TextField('Name', 'Name')); |
|
22 | 22 | $nf->setReadOnly(true); |
23 | 23 | $nf->setDisabled(true); |
24 | 24 |
@@ -24,10 +24,10 @@ |
||
24 | 24 | |
25 | 25 | function getCMSFields() { |
26 | 26 | $fields = new FieldList(); |
27 | - $fields->push( new TabSet( "Root", $mainTab = new Tab( "Main" ) ) ); |
|
28 | - $mainTab->setTitle( _t( 'SiteTree.TABMAIN', "Main" ) ); |
|
29 | - $fields->addFieldToTab( 'Root.Main', $cf = new TextField( 'ClazzName', 'Class sourced from') ); |
|
30 | - $fields->addFieldToTab( 'Root.Main', $nf = new TextField( 'Name', 'Name') ); |
|
27 | + $fields->push(new TabSet("Root", $mainTab = new Tab("Main"))); |
|
28 | + $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main")); |
|
29 | + $fields->addFieldToTab('Root.Main', $cf = new TextField('ClazzName', 'Class sourced from')); |
|
30 | + $fields->addFieldToTab('Root.Main', $nf = new TextField('Name', 'Name')); |
|
31 | 31 | $cf->setDisabled(true); |
32 | 32 | $nf->setDisabled(true); |
33 | 33 | $cf->setReadOnly(true); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | // Makes most sense to only provide one field here, e.g. Title, Name |
21 | 21 | $field = $this->request->getVar('field'); |
22 | 22 | |
23 | - error_log('QUERY:'.$query); |
|
23 | + error_log('QUERY:' . $query); |
|
24 | 24 | |
25 | 25 | // start, and page length, i.e. pagination |
26 | 26 | $es->setPageLength(10); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $es->addFilter('InSiteTree', true); |
33 | 33 | } |
34 | 34 | |
35 | - $resultList = $es->autocomplete_search($query,$field); |
|
35 | + $resultList = $es->autocomplete_search($query, $field); |
|
36 | 36 | $result = array(); |
37 | 37 | $result['Query'] = $query; |
38 | 38 | $suggestions = array(); |
@@ -92,26 +92,26 @@ discard block |
||
92 | 92 | //Need to check capitalisation of terms suggested that are different |
93 | 93 | |
94 | 94 | $chr = mb_substr ($possiblyUppercase, 0, 1, "UTF-8"); |
95 | - if (mb_strtolower($chr, "UTF-8") != $chr) { |
|
96 | - $upperLowercaseWord = $lowercaseWord; |
|
97 | - $upperLowercaseWord[0] = $chr; |
|
95 | + if (mb_strtolower($chr, "UTF-8") != $chr) { |
|
96 | + $upperLowercaseWord = $lowercaseWord; |
|
97 | + $upperLowercaseWord[0] = $chr; |
|
98 | 98 | |
99 | - //$possiblyUppercaseHighlighted = str_replace($lowercaseWord, $possiblyUppercase, $possiblyUppercaseHighlighted); |
|
100 | - $withHighlights = str_replace($lowercaseWord, $upperLowercaseWord, $possiblyUppercaseHighlighted); |
|
99 | + //$possiblyUppercaseHighlighted = str_replace($lowercaseWord, $possiblyUppercase, $possiblyUppercaseHighlighted); |
|
100 | + $withHighlights = str_replace($lowercaseWord, $upperLowercaseWord, $possiblyUppercaseHighlighted); |
|
101 | 101 | |
102 | - $lowercaseWord[0] = $chr; |
|
102 | + $lowercaseWord[0] = $chr; |
|
103 | 103 | |
104 | - //str_replace(search, replace, subject) |
|
104 | + //str_replace(search, replace, subject) |
|
105 | 105 | |
106 | - array_push($plain, $lowercaseWord); |
|
107 | - array_push($highlighted, $withHighlights); |
|
108 | - } else { |
|
109 | - //No need to capitalise, so add suggested word |
|
110 | - array_push($plain, $lowercaseWord); |
|
106 | + array_push($plain, $lowercaseWord); |
|
107 | + array_push($highlighted, $withHighlights); |
|
108 | + } else { |
|
109 | + //No need to capitalise, so add suggested word |
|
110 | + array_push($plain, $lowercaseWord); |
|
111 | 111 | |
112 | - //No need to capitalise, so add suggested highlighted word |
|
113 | - array_push($highlighted, $possiblyUppercaseHighlighted); |
|
114 | - } |
|
112 | + //No need to capitalise, so add suggested highlighted word |
|
113 | + array_push($highlighted, $possiblyUppercaseHighlighted); |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -144,37 +144,37 @@ discard block |
||
144 | 144 | |
145 | 145 | $explanation = explode('-ConstantScore', $explanation)[0]; |
146 | 146 | |
147 | - $bracketPos = strpos($explanation, ')~'); |
|
147 | + $bracketPos = strpos($explanation, ')~'); |
|
148 | 148 | |
149 | - if (substr($explanation, 0,2) == '((') { |
|
150 | - $explanation = substr($explanation, 2, $bracketPos-2); |
|
151 | - } elseif (substr($explanation, 0,1) == '(') { |
|
152 | - $explanation = substr($explanation, 1, $bracketPos-2); |
|
153 | - } |
|
149 | + if (substr($explanation, 0,2) == '((') { |
|
150 | + $explanation = substr($explanation, 2, $bracketPos-2); |
|
151 | + } elseif (substr($explanation, 0,1) == '(') { |
|
152 | + $explanation = substr($explanation, 1, $bracketPos-2); |
|
153 | + } |
|
154 | 154 | |
155 | - $terms = array(); |
|
155 | + $terms = array(); |
|
156 | 156 | |
157 | - //Field name(s) => terms |
|
158 | - $splits = explode(' ', $explanation); |
|
157 | + //Field name(s) => terms |
|
158 | + $splits = explode(' ', $explanation); |
|
159 | 159 | |
160 | - foreach ($splits as $fieldAndTerm) { |
|
161 | - $splits = explode(':', $fieldAndTerm); |
|
160 | + foreach ($splits as $fieldAndTerm) { |
|
161 | + $splits = explode(':', $fieldAndTerm); |
|
162 | 162 | |
163 | - // This is the no terms case |
|
164 | - if (sizeof($splits) < 2) { |
|
165 | - break; |
|
166 | - } |
|
163 | + // This is the no terms case |
|
164 | + if (sizeof($splits) < 2) { |
|
165 | + break; |
|
166 | + } |
|
167 | 167 | |
168 | - $fieldname = $splits[0]; |
|
169 | - $term = $splits[1]; |
|
168 | + $fieldname = $splits[0]; |
|
169 | + $term = $splits[1]; |
|
170 | 170 | |
171 | - if (!isset($terms[$fieldname])) { |
|
172 | - $terms[$fieldname] = array(); |
|
173 | - } |
|
171 | + if (!isset($terms[$fieldname])) { |
|
172 | + $terms[$fieldname] = array(); |
|
173 | + } |
|
174 | 174 | |
175 | - array_push($terms[$fieldname], $term); |
|
176 | - } |
|
175 | + array_push($terms[$fieldname], $term); |
|
176 | + } |
|
177 | 177 | |
178 | - return $terms; |
|
178 | + return $terms; |
|
179 | 179 | } |
180 | 180 | } |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | $originalParts = explode(' ', $originalQuery); |
59 | 59 | $suggestedParts = explode(' ', $suggestedPhrase); |
60 | 60 | |
61 | - $markedHighlightedParts = ' '.$suggestedPhraseHighlighted.' '; |
|
62 | - $markedHighlightedParts = str_replace(' '.$preTags, ' '.self::$pre_marker, $markedHighlightedParts); |
|
61 | + $markedHighlightedParts = ' ' . $suggestedPhraseHighlighted . ' '; |
|
62 | + $markedHighlightedParts = str_replace(' ' . $preTags, ' ' . self::$pre_marker, $markedHighlightedParts); |
|
63 | 63 | |
64 | - $markedHighlightedParts = str_replace($postTags.' ', self::$post_marker, $markedHighlightedParts); |
|
64 | + $markedHighlightedParts = str_replace($postTags . ' ', self::$post_marker, $markedHighlightedParts); |
|
65 | 65 | |
66 | 66 | $markedHighlightedParts = trim($markedHighlightedParts); |
67 | 67 | $markedHighlightedParts = trim($markedHighlightedParts); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } else { |
92 | 92 | //Need to check capitalisation of terms suggested that are different |
93 | 93 | |
94 | - $chr = mb_substr ($possiblyUppercase, 0, 1, "UTF-8"); |
|
94 | + $chr = mb_substr($possiblyUppercase, 0, 1, "UTF-8"); |
|
95 | 95 | if (mb_strtolower($chr, "UTF-8") != $chr) { |
96 | 96 | $upperLowercaseWord = $lowercaseWord; |
97 | 97 | $upperLowercaseWord[0] = $chr; |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - $highlighted = ' '.implode(' ', $highlighted).' '; |
|
119 | - $highlighted = str_replace(self::$pre_marker, ' '.$preTags, $highlighted); |
|
120 | - $highlighted = str_replace(self::$post_marker, $postTags.' ', $highlighted); |
|
118 | + $highlighted = ' ' . implode(' ', $highlighted) . ' '; |
|
119 | + $highlighted = str_replace(self::$pre_marker, ' ' . $preTags, $highlighted); |
|
120 | + $highlighted = str_replace(self::$post_marker, $postTags . ' ', $highlighted); |
|
121 | 121 | |
122 | 122 | $resultArray['suggestedQuery'] = implode(' ', $plain); |
123 | 123 | $resultArray['suggestedQueryHighlighted'] = trim($highlighted); |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | |
147 | 147 | $bracketPos = strpos($explanation, ')~'); |
148 | 148 | |
149 | - if (substr($explanation, 0,2) == '((') { |
|
150 | - $explanation = substr($explanation, 2, $bracketPos-2); |
|
151 | - } elseif (substr($explanation, 0,1) == '(') { |
|
152 | - $explanation = substr($explanation, 1, $bracketPos-2); |
|
149 | + if (substr($explanation, 0, 2) == '((') { |
|
150 | + $explanation = substr($explanation, 2, $bracketPos - 2); |
|
151 | + } elseif (substr($explanation, 0, 1) == '(') { |
|
152 | + $explanation = substr($explanation, 1, $bracketPos - 2); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | $terms = array(); |
@@ -553,10 +553,10 @@ |
||
553 | 553 | print_r($sr); |
554 | 554 | |
555 | 555 | |
556 | - //$sr2 = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs'); |
|
556 | + //$sr2 = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs'); |
|
557 | 557 | |
558 | - // MUST REMOVE FIRST. Otherwise append and the erroroneus value above still exists |
|
559 | - $config->remove('FlickrPhotoTO', 'searchable_relationships'); |
|
558 | + // MUST REMOVE FIRST. Otherwise append and the erroroneus value above still exists |
|
559 | + $config->remove('FlickrPhotoTO', 'searchable_relationships'); |
|
560 | 560 | $config->update('FlickrPhotoTO' ,'searchable_relationships', $sr); |
561 | 561 | } |
562 | 562 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | public function setUp() { |
14 | 14 | // this needs to be called in order to create the list of searchable |
15 | 15 | // classes and fields that are available. Simulates part of a build |
16 | - $classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO', |
|
16 | + $classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO', |
|
17 | 17 | 'FlickrTagTO', 'FlickrAuthorTO', 'FlickrSetTO'); |
18 | 18 | $this->requireDefaultRecordsFrom = $classes; |
19 | 19 | |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | |
189 | 189 | |
190 | 190 | // check strings |
191 | - $shouldBeString = array('Title','Description'); |
|
192 | - $shouldBeInt = array('ISO','FlickrID','FocalLength35mm'); |
|
191 | + $shouldBeString = array('Title', 'Description'); |
|
192 | + $shouldBeInt = array('ISO', 'FlickrID', 'FocalLength35mm'); |
|
193 | 193 | $shouldBeBoolean = array('IsInSiteTree'); |
194 | 194 | $shouldBeDouble = array('Aperture'); |
195 | 195 | $shouldBeDateTime = array('TakenAt'); |
196 | 196 | $shouldBeDate = array('FirstViewed'); |
197 | 197 | |
198 | 198 | // tokens are strings that have analyzer 'not_analyzed', namely the string is indexed as is |
199 | - $shouldBeTokens = array('ShutterSpeed','Link'); |
|
199 | + $shouldBeTokens = array('ShutterSpeed', 'Link'); |
|
200 | 200 | |
201 | 201 | |
202 | 202 | // check strings |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | // check for unstemmed analaysis |
215 | 215 | |
216 | - $this->assertEquals($expectedStandardArray,$fieldProperties['fields']['standard']); |
|
216 | + $this->assertEquals($expectedStandardArray, $fieldProperties['fields']['standard']); |
|
217 | 217 | |
218 | 218 | // check for only 3 entries |
219 | 219 | $this->assertEquals(4, sizeof(array_keys($fieldProperties))); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $fieldProperties = $properties[$fieldName]; |
225 | 225 | $type = $fieldProperties['type']; |
226 | 226 | $this->assertEquals(1, sizeof(array_keys($fieldProperties))); |
227 | - $this->assertEquals('integer',$type); |
|
227 | + $this->assertEquals('integer', $type); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $fieldProperties = $properties[$fieldName]; |
234 | 234 | $type = $fieldProperties['type']; |
235 | 235 | $this->assertEquals(1, sizeof(array_keys($fieldProperties))); |
236 | - $this->assertEquals('double',$type); |
|
236 | + $this->assertEquals('double', $type); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | // check boolean |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $fieldProperties = $properties[$fieldName]; |
242 | 242 | $type = $fieldProperties['type']; |
243 | 243 | $this->assertEquals(1, sizeof(array_keys($fieldProperties))); |
244 | - $this->assertEquals('boolean',$type); |
|
244 | + $this->assertEquals('boolean', $type); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $fieldProperties = $properties[$fieldName]; |
250 | 250 | $type = $fieldProperties['type']; |
251 | 251 | $this->assertEquals(2, sizeof(array_keys($fieldProperties))); |
252 | - $this->assertEquals('date',$type); |
|
252 | + $this->assertEquals('date', $type); |
|
253 | 253 | $this->assertEquals('y-M-d', $fieldProperties['format']); |
254 | 254 | } |
255 | 255 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $fieldProperties = $properties[$fieldName]; |
261 | 261 | $type = $fieldProperties['type']; |
262 | 262 | $this->assertEquals(2, sizeof(array_keys($fieldProperties))); |
263 | - $this->assertEquals('date',$type); |
|
263 | + $this->assertEquals('date', $type); |
|
264 | 264 | $this->assertEquals('y-M-d H:m:s', $fieldProperties['format']); |
265 | 265 | } |
266 | 266 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $doc = $flickrPhoto->getElasticaDocument()->getData(); |
300 | 300 | |
301 | 301 | $expected = array(); |
302 | - $expected['Title'] = 'Bangkok' ; |
|
302 | + $expected['Title'] = 'Bangkok'; |
|
303 | 303 | $expected['FlickrID'] = '1234567'; |
304 | 304 | $expected['Description'] = 'Test photograph'; |
305 | 305 | $expected['TakenAt'] = '2011-07-04 20:36:00'; |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $page = $this->objFromFixture('SiteTree', 'sitetree001'); |
389 | 389 | $page->doUnpublish(); |
390 | 390 | |
391 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart-1); |
|
391 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart - 1); |
|
392 | 392 | |
393 | 393 | $page->doPublish(); |
394 | 394 | $this->checkNumberOfIndexedDocuments($nDocsAtStart); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | $flickrPhoto = $this->objFromFixture('FlickrPhotoTO', 'photo0001'); |
482 | 482 | $fields = $flickrPhoto->getCMSFields(); |
483 | 483 | |
484 | - $tab = $this->checkTabExists($fields,'ElasticaTermsset'); |
|
484 | + $tab = $this->checkTabExists($fields, 'ElasticaTermsset'); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | $this->assertEquals('The field $searchable_fields must be set for the class FlickrPhotoTO', $e->getMessage()); |
498 | 498 | } |
499 | 499 | |
500 | - $config->update('FlickrPhotoTO' ,'searchable_fields', $sf); |
|
500 | + $config->update('FlickrPhotoTO', 'searchable_fields', $sf); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | $this->assertEquals('The field $searchable_fields must be set for the class FlickrTagTO', $e->getMessage()); |
514 | 514 | } |
515 | 515 | |
516 | - $config->update('FlickrTagTO' ,'searchable_fields', $sf); |
|
516 | + $config->update('FlickrTagTO', 'searchable_fields', $sf); |
|
517 | 517 | |
518 | 518 | } |
519 | 519 | |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | $this->assertEquals('The field $searchable_fields must be set for the class FlickrAuthorTO', $e->getMessage()); |
531 | 531 | } |
532 | 532 | |
533 | - $config->update('FlickrAuthorTO' ,'searchable_fields', $sf); |
|
533 | + $config->update('FlickrAuthorTO', 'searchable_fields', $sf); |
|
534 | 534 | |
535 | 535 | } |
536 | 536 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | $config = Config::inst(); |
540 | 540 | $sr = $config->get('FlickrPhotoTO', 'searchable_relationships'); |
541 | 541 | $config->remove('FlickrPhotoTO', 'searchable_relationships'); |
542 | - $config->update('FlickrPhotoTO', 'searchable_relationships',array('thisMethodDoesNotExist')); |
|
542 | + $config->update('FlickrPhotoTO', 'searchable_relationships', array('thisMethodDoesNotExist')); |
|
543 | 543 | $fp = Injector::inst()->create('FlickrPhotoTO'); |
544 | 544 | try { |
545 | 545 | $fields = $fp->getAllSearchableFields(); |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | // MUST REMOVE FIRST. Otherwise append and the erroroneus value above still exists |
559 | 559 | $config->remove('FlickrPhotoTO', 'searchable_relationships'); |
560 | - $config->update('FlickrPhotoTO' ,'searchable_relationships', $sr); |
|
560 | + $config->update('FlickrPhotoTO', 'searchable_relationships', $sr); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -669,9 +669,9 @@ discard block |
||
669 | 669 | |
670 | 670 | $photographer->write(); |
671 | 671 | |
672 | - $flickrPhoto->PhotographerID = $photographer->ID;; |
|
672 | + $flickrPhoto->PhotographerID = $photographer->ID; ; |
|
673 | 673 | $flickrPhoto->write(); |
674 | - echo 'ID='.$flickrPhoto->PhotographerID; |
|
674 | + echo 'ID=' . $flickrPhoto->PhotographerID; |
|
675 | 675 | $a = $flickrPhoto->getFieldValuesAsArray(); |
676 | 676 | |
677 | 677 | print_r($a); |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | |
719 | 719 | |
720 | 720 | $flickrPhoto->write(); |
721 | - echo 'ID='.$flickrPhoto->PhotographerID; |
|
721 | + echo 'ID=' . $flickrPhoto->PhotographerID; |
|
722 | 722 | $a = $flickrPhoto->getFieldValuesAsArray(); |
723 | 723 | |
724 | 724 | print_r($a); |
@@ -766,15 +766,15 @@ discard block |
||
766 | 766 | foreach ($tab->FieldList() as $field) { |
767 | 767 | array_push($tabFields, $field->getName()); |
768 | 768 | } |
769 | - $expectedName = 'TermsFor'.$tab->getName();; |
|
769 | + $expectedName = 'TermsFor' . $tab->getName(); ; |
|
770 | 770 | $expected = array($expectedName); |
771 | 771 | $this->assertEquals($expected, $tabFields); |
772 | 772 | array_push($tabNames, $tab->getName()); |
773 | 773 | } |
774 | - $expected = array('Description','Description_shingles','Description_standard', |
|
775 | - 'ShutterSpeed', 'TestMethod', 'TestMethod_shingles', 'TestMethod_standard', |
|
774 | + $expected = array('Description', 'Description_shingles', 'Description_standard', |
|
775 | + 'ShutterSpeed', 'TestMethod', 'TestMethod_shingles', 'TestMethod_standard', |
|
776 | 776 | 'TestMethodHTML', 'TestMethodHTML_shingles', 'TestMethodHTML_standard', |
777 | - 'Title','Title_autocomplete','Title_shingles','Title_standard'); |
|
777 | + 'Title', 'Title_autocomplete', 'Title_shingles', 'Title_standard'); |
|
778 | 778 | |
779 | 779 | $this->assertEquals($expected, $tabNames); |
780 | 780 | } |
@@ -798,13 +798,13 @@ discard block |
||
798 | 798 | foreach ($tab->FieldList() as $field) { |
799 | 799 | array_push($tabFields, $field->getName()); |
800 | 800 | } |
801 | - $expectedName = 'TermsFor'.$tab->getName();; |
|
801 | + $expectedName = 'TermsFor' . $tab->getName(); ; |
|
802 | 802 | $expected = array($expectedName); |
803 | 803 | $this->assertEquals($expected, $tabFields); |
804 | 804 | array_push($tabNames, $tab->getName()); |
805 | 805 | } |
806 | 806 | $expected = array( |
807 | - 'Content','Content_standard','Link','Title','Title_autocomplete','Title_shingles', |
|
807 | + 'Content', 'Content_standard', 'Link', 'Title', 'Title_autocomplete', 'Title_shingles', |
|
808 | 808 | 'Title_standard'); |
809 | 809 | $this->generateAssertionsFromArray1D($tabNames); |
810 | 810 | $this->assertEquals($expected, $tabNames); |
@@ -479,6 +479,9 @@ |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | |
482 | + /** |
|
483 | + * @param string $query |
|
484 | + */ |
|
482 | 485 | private function getResultsFor($query, $pageLength = 10, $fields = array('Title' => 1, 'Description' => 1)) { |
483 | 486 | $es = new ElasticSearcher(); |
484 | 487 | $es->setStart(0); |
@@ -31,13 +31,13 @@ |
||
31 | 31 | public function testRequireDefaultRecords() { |
32 | 32 | $this->AutoCompleteOption->requireDefaultRecords(); |
33 | 33 | |
34 | - $similar = AutoCompleteOption::get()->filter('Name','Similar')->first(); |
|
34 | + $similar = AutoCompleteOption::get()->filter('Name', 'Similar')->first(); |
|
35 | 35 | $this->assertEquals(1, $similar->ID); |
36 | 36 | |
37 | - $search = AutoCompleteOption::get()->filter('Name','Search')->first(); |
|
37 | + $search = AutoCompleteOption::get()->filter('Name', 'Search')->first(); |
|
38 | 38 | $this->assertEquals(2, $search->ID); |
39 | 39 | |
40 | - $goto = AutoCompleteOption::get()->filter('Name','GoToRecord')->first(); |
|
40 | + $goto = AutoCompleteOption::get()->filter('Name', 'GoToRecord')->first(); |
|
41 | 41 | $this->assertEquals(3, $goto->ID); |
42 | 42 | |
43 | 43 | } |