@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | $fields = $sc->getCMSFields(); |
16 | 16 | |
17 | - $tab = $this->checkTabExists($fields,'Main'); |
|
17 | + $tab = $this->checkTabExists($fields, 'Main'); |
|
18 | 18 | |
19 | 19 | //Check fields |
20 | 20 | $nf = $this->checkFieldExists($tab, 'Name'); |
@@ -9,7 +9,7 @@ |
||
9 | 9 | public function setUp() { |
10 | 10 | // this needs to be called in order to create the list of searchable |
11 | 11 | // classes and fields that are available. Simulates part of a build |
12 | - $classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO', |
|
12 | + $classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO', |
|
13 | 13 | 'FlickrTagTO', 'FlickrAuthorTO', 'FlickrSetTO'); |
14 | 14 | $this->requireDefaultRecordsFrom = $classes; |
15 | 15 |
@@ -139,37 +139,37 @@ discard block |
||
139 | 139 | * Add a mapping for the location of the photograph |
140 | 140 | */ |
141 | 141 | public function updateElasticsearchMapping(\Elastica\Type\Mapping $mapping) |
142 | - { |
|
143 | - // get the properties of the individual fields as an array |
|
144 | - $properties = $mapping->getProperties(); |
|
145 | - |
|
146 | - // add a location with geo point |
|
147 | - $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
|
148 | - $properties['location'] = array( |
|
149 | - 'type' => 'geo_point', |
|
150 | - 'fielddata' => $precision1cm, |
|
151 | - ); |
|
152 | - |
|
153 | - $properties['ShutterSpeed'] = array( |
|
154 | - 'type' => 'string', |
|
155 | - 'index' => 'not_analyzed' |
|
142 | + { |
|
143 | + // get the properties of the individual fields as an array |
|
144 | + $properties = $mapping->getProperties(); |
|
145 | + |
|
146 | + // add a location with geo point |
|
147 | + $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
|
148 | + $properties['location'] = array( |
|
149 | + 'type' => 'geo_point', |
|
150 | + 'fielddata' => $precision1cm, |
|
156 | 151 | ); |
157 | 152 | |
158 | - $properties['Aperture'] = array( |
|
159 | - // do not use float as the rounding makes facets impossible |
|
160 | - 'type' => 'double' |
|
161 | - ); |
|
153 | + $properties['ShutterSpeed'] = array( |
|
154 | + 'type' => 'string', |
|
155 | + 'index' => 'not_analyzed' |
|
156 | + ); |
|
162 | 157 | |
163 | - $properties['FlickrID'] = array('type' => 'integer'); |
|
158 | + $properties['Aperture'] = array( |
|
159 | + // do not use float as the rounding makes facets impossible |
|
160 | + 'type' => 'double' |
|
161 | + ); |
|
164 | 162 | |
165 | - // by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s |
|
166 | - //$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s'); |
|
163 | + $properties['FlickrID'] = array('type' => 'integer'); |
|
167 | 164 | |
168 | - // set the new properties on the mapping |
|
169 | - $mapping->setProperties($properties); |
|
165 | + // by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s |
|
166 | + //$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s'); |
|
170 | 167 | |
171 | - return $mapping; |
|
172 | - } |
|
168 | + // set the new properties on the mapping |
|
169 | + $mapping->setProperties($properties); |
|
170 | + |
|
171 | + return $mapping; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | |
175 | 175 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | $sortable = $sortable . '|' . $this->owner->ShutterSpeed; |
207 | 207 | $document->set('ShutterSpeed', $sortable); |
208 | - return $document; |
|
208 | + return $document; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | * @subpackage tests |
7 | 7 | */ |
8 | 8 | class FlickrPhotoTO extends DataObject implements TestOnly { |
9 | - private static $searchable_fields = array('Title','FlickrID','Description','TakenAt', 'TakenAtDT', 'FirstViewed', |
|
10 | - 'Aperture','ShutterSpeed','FocalLength35mm','ISO','AspectRatio', 'TestMethod', 'TestMethodHTML'); |
|
9 | + private static $searchable_fields = array('Title', 'FlickrID', 'Description', 'TakenAt', 'TakenAtDT', 'FirstViewed', |
|
10 | + 'Aperture', 'ShutterSpeed', 'FocalLength35mm', 'ISO', 'AspectRatio', 'TestMethod', 'TestMethodHTML'); |
|
11 | 11 | |
12 | 12 | private static $searchable_relationships = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs'); |
13 | 13 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @subpackage tests |
89 | 89 | */ |
90 | 90 | class FlickrSetTO extends DataObject implements TestOnly { |
91 | - private static $searchable_fields = array('Title','FlickrID','Description'); |
|
91 | + private static $searchable_fields = array('Title', 'FlickrID', 'Description'); |
|
92 | 92 | |
93 | 93 | private static $db = array( |
94 | 94 | 'Title' => 'Varchar(255)', |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | |
135 | 135 | |
136 | -class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface,TestOnly { |
|
136 | +class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface, TestOnly { |
|
137 | 137 | |
138 | 138 | /** |
139 | 139 | * Add a mapping for the location of the photograph |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | // add a location with geo point |
147 | 147 | $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
148 | - $properties['location'] = array( |
|
148 | + $properties['location'] = array( |
|
149 | 149 | 'type' => 'geo_point', |
150 | 150 | 'fielddata' => $precision1cm, |
151 | 151 | ); |
@@ -181,27 +181,27 @@ discard block |
||
181 | 181 | { |
182 | 182 | // self::$ctr++; |
183 | 183 | |
184 | - if ($this->owner->Lat != null && $this->owner->Lon != null) { |
|
184 | + if($this->owner->Lat != null && $this->owner->Lon != null) { |
|
185 | 185 | $coors = array('lat' => $this->owner->Lat, 'lon' => $this->owner->Lon); |
186 | - $document->set('location',$coors); |
|
186 | + $document->set('location', $coors); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $sortable = $this->owner->ShutterSpeed; |
190 | 190 | $sortable = explode('/', $sortable); |
191 | - if (sizeof($sortable) == 1) { |
|
191 | + if(sizeof($sortable) == 1) { |
|
192 | 192 | $sortable = trim($sortable[0]); |
193 | 193 | |
194 | - if ($this->owner->ShutterSpeed == null) { |
|
194 | + if($this->owner->ShutterSpeed == null) { |
|
195 | 195 | $sortable = null; |
196 | 196 | } |
197 | 197 | |
198 | - if ($sortable == 1) { |
|
198 | + if($sortable == 1) { |
|
199 | 199 | $sortable = '1.000000'; |
200 | 200 | } |
201 | 201 | |
202 | - } else if (sizeof($sortable) == 2) { |
|
203 | - $sortable = floatval($sortable[0])/intval($sortable[1]); |
|
204 | - $sortable = round($sortable,6); |
|
202 | + } else if(sizeof($sortable) == 2) { |
|
203 | + $sortable = floatval($sortable[0]) / intval($sortable[1]); |
|
204 | + $sortable = round($sortable, 6); |
|
205 | 205 | } |
206 | 206 | $sortable = $sortable . '|' . $this->owner->ShutterSpeed; |
207 | 207 | $document->set('ShutterSpeed', $sortable); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * @subpackage tests |
6 | 6 | */ |
7 | 7 | class SearchableTestPage extends Page implements TestOnly { |
8 | - private static $searchable_fields = array('Country','PageDate'); |
|
8 | + private static $searchable_fields = array('Country', 'PageDate'); |
|
9 | 9 | |
10 | 10 | private static $db = array( |
11 | 11 | 'Country' => 'Varchar', |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct() { |
12 | 12 | $aspectAgg = new RangedAggregation('Aspect', 'AspectRatio'); |
13 | - $aspectAgg->addRange(0.0000001, 0.3, 'Panoramic'); |
|
14 | - $aspectAgg->addRange(0.3, 0.9, 'Horizontal'); |
|
15 | - $aspectAgg->addRange(0.9, 1.2, 'Square'); |
|
16 | - $aspectAgg->addRange(1.2, 1.79, 'Vertical'); |
|
17 | - $aspectAgg->addRange(1.79, 1e7, 'Tallest'); |
|
13 | + $aspectAgg->addRange(0.0000001, 0.3, 'Panoramic'); |
|
14 | + $aspectAgg->addRange(0.3, 0.9, 'Horizontal'); |
|
15 | + $aspectAgg->addRange(0.9, 1.2, 'Square'); |
|
16 | + $aspectAgg->addRange(1.2, 1.79, 'Vertical'); |
|
17 | + $aspectAgg->addRange(1.79, 1e7, 'Tallest'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | private static $titleFieldMapping = array( |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | |
75 | 75 | $aspectRangedAgg = RangedAggregation::getByTitle('Aspect'); |
76 | - $query->addAggregation($aspectRangedAgg->getRangeAgg()); |
|
76 | + $query->addAggregation($aspectRangedAgg->getRangeAgg()); |
|
77 | 77 | |
78 | 78 | // leave this out for the moment as way too many terms being returned slowing things down |
79 | 79 | /* |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use SilverStripe\Elastica\RangedAggregation; |
7 | 7 | |
8 | 8 | |
9 | -class FlickrPhotoTOElasticaSearchHelper implements ElasticaSearchHelperInterface,TestOnly { |
|
9 | +class FlickrPhotoTOElasticaSearchHelper implements ElasticaSearchHelperInterface, TestOnly { |
|
10 | 10 | |
11 | 11 | public function __construct() { |
12 | 12 | $aspectAgg = new RangedAggregation('Aspect', 'AspectRatio'); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | 'query_string' => array('query' => '*') |
37 | 37 | ); |
38 | 38 | |
39 | - if ($query->OriginalQueryText == '') { |
|
39 | + if($query->OriginalQueryText == '') { |
|
40 | 40 | $query->setSort(array('TakenAt'=> 'desc')); |
41 | 41 | } |
42 | 42 | |
@@ -104,27 +104,27 @@ discard block |
||
104 | 104 | // shutter speed is stored as decimal to 6 decimal places, then a |
105 | 105 | // vertical bar followed by the displayed speed as a fraction or a |
106 | 106 | // whole number. This puts the decimal back for matching purposes |
107 | - if (isset($filters['ShutterSpeed'])) { |
|
107 | + if(isset($filters['ShutterSpeed'])) { |
|
108 | 108 | |
109 | 109 | $sortable = $filters['ShutterSpeed']; |
110 | 110 | |
111 | 111 | echo "SORTABLE:$sortable\n"; |
112 | 112 | |
113 | 113 | $sortable = explode('/', $sortable); |
114 | - if (sizeof($sortable) == 1) { |
|
114 | + if(sizeof($sortable) == 1) { |
|
115 | 115 | $sortable = trim($sortable[0]); |
116 | 116 | |
117 | - if ($sortable === '1') { |
|
117 | + if($sortable === '1') { |
|
118 | 118 | $sortable = '1.000000|1'; |
119 | 119 | } |
120 | 120 | |
121 | - } else if (sizeof($sortable) == 2) { |
|
122 | - if ($sortable[0] === '' || $sortable[1] === '') { |
|
121 | + } else if(sizeof($sortable) == 2) { |
|
122 | + if($sortable[0] === '' || $sortable[1] === '') { |
|
123 | 123 | $sortable = ''; |
124 | 124 | |
125 | 125 | } else { |
126 | - $sortable = floatval($sortable[0])/intval($sortable[1]); |
|
127 | - $sortable = round($sortable,6); |
|
126 | + $sortable = floatval($sortable[0]) / intval($sortable[1]); |
|
127 | + $sortable = round($sortable, 6); |
|
128 | 128 | $sortable = $sortable . '|' . $filters['ShutterSpeed']; |
129 | 129 | } |
130 | 130 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | // the shutter speeds are of the form decimal number | fraction, keep the latter half |
148 | 148 | $shutterSpeeds = $aggs['ShutterSpeed']['buckets']; |
149 | 149 | $ctr = 0; |
150 | - foreach ($shutterSpeeds as $bucket) { |
|
150 | + foreach($shutterSpeeds as $bucket) { |
|
151 | 151 | $key = $bucket['key']; |
152 | 152 | $splits = explode('|', $key); |
153 | 153 | $shutterSpeeds[$ctr]['key'] = end($splits); |
@@ -17,8 +17,8 @@ |
||
17 | 17 | sort($terms); |
18 | 18 | $expected = array('Description', 'Description.shingles', 'Description.standard', |
19 | 19 | 'ShutterSpeed', |
20 | - 'TestMethod','TestMethod.shingles','TestMethod.standard', |
|
21 | - 'TestMethodHTML','TestMethodHTML.shingles','TestMethodHTML.standard', |
|
20 | + 'TestMethod', 'TestMethod.shingles', 'TestMethod.standard', |
|
21 | + 'TestMethodHTML', 'TestMethodHTML.shingles', 'TestMethodHTML.standard', |
|
22 | 22 | 'Title', 'Title.autocomplete', 'Title.shingles', 'Title.standard'); |
23 | 23 | $this->assertEquals($expected, $terms); |
24 | 24 |
@@ -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 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $this->invokeMethod($this->service, 'createIndex', array()); |
28 | 28 | $this->assertFalse(true, "Creation of index with unknown locale should have failed"); |
29 | 29 | } catch (Exception $e) { |
30 | - $this->assertTrue(true,"Creation of index with unknown locale failed as expected"); |
|
30 | + $this->assertTrue(true, "Creation of index with unknown locale failed as expected"); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $fp->write(); |
117 | 117 | $this->service->getIndex()->refresh(); |
118 | 118 | |
119 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart-1); |
|
119 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart - 1); |
|
120 | 120 | |
121 | 121 | $fp->ShowInSearch = true; |
122 | 122 | $fp->write(); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $fp->doUnpublish(); |
135 | 135 | |
136 | 136 | $this->service->getIndex()->refresh(); |
137 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart-1); |
|
137 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart - 1); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $fp->delete(); |
147 | 147 | |
148 | 148 | $this->service->getIndex()->refresh(); |
149 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart-1); |
|
149 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart - 1); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $fp->delete(); |
159 | 159 | |
160 | 160 | $this->service->getIndex()->refresh(); |
161 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart-1); |
|
161 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart - 1); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | //Check that the number of indexing requests has increased by 2 |
178 | 178 | $deltaReqs = $this->service->getIndexingRequestCtr() - $reqs; |
179 | 179 | //One call is made for each of Page and FlickrPhotoTO |
180 | - $this->assertEquals(2,$deltaReqs); |
|
180 | + $this->assertEquals(2, $deltaReqs); |
|
181 | 181 | |
182 | 182 | // default installed pages plus 100 FlickrPhotoTOs |
183 | 183 | $this->checkNumberOfIndexedDocuments(103); |
@@ -195,21 +195,21 @@ discard block |
||
195 | 195 | $fp = new FlickrPhotoTO(); |
196 | 196 | $fp->Title = 'The cat sits on the mat'; |
197 | 197 | $fp->write(); |
198 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart+1); |
|
198 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart + 1); |
|
199 | 199 | |
200 | 200 | $fp2 = new FlickrPhotoTO(); |
201 | 201 | $fp2->Title = 'The cat sat on the hat'; |
202 | 202 | $fp2->write(); |
203 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart+2); |
|
203 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart + 2); |
|
204 | 204 | |
205 | 205 | $fp3 = new FlickrPhotoTO(); |
206 | 206 | $fp3->Title = 'The bat flew around the cat'; |
207 | 207 | $fp3->write(); |
208 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart+3); |
|
208 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart + 3); |
|
209 | 209 | |
210 | 210 | //Check that the number of indexing requests has increased by 3 |
211 | 211 | $deltaReqs = $this->service->getIndexingRequestCtr() - $reqs; |
212 | - $this->assertEquals(3,$deltaReqs); |
|
212 | + $this->assertEquals(3, $deltaReqs); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -283,6 +283,6 @@ discard block |
||
283 | 283 | public function testListIndexes() { |
284 | 284 | $message = 'This is a test trace'; |
285 | 285 | $trace = $this->service->listIndexes($message); |
286 | - $this->assertContains('elastica_ss_module_test_en_us', print_r($trace,1)); |
|
286 | + $this->assertContains('elastica_ss_module_test_en_us', print_r($trace, 1)); |
|
287 | 287 | } |
288 | 288 | } |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | // don't check the server name as this will differ, just check the path is /search/ |
26 | 26 | $uri = $searchPage->SearchPageURI('testsearchpage'); |
27 | 27 | $splits = explode('/', $uri); |
28 | - $this->assertEquals($splits[3],'search'); |
|
28 | + $this->assertEquals($splits[3], 'search'); |
|
29 | 29 | |
30 | 30 | // check the form |
31 | 31 | $form = $searchPage->SearchPageForm('testsearchpage'); |
32 | - $this->assertInstanceOf('ElasticSearchForm',$form); |
|
32 | + $this->assertInstanceOf('ElasticSearchForm', $form); |
|
33 | 33 | |
34 | 34 | $fields = $form->Fields(); |
35 | 35 | $actions = $form->Actions(); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function testButtonOverride() { |
46 | 46 | $searchPage = $this->objFromFixture('ElasticSearchPage', 'search'); |
47 | 47 | $buttonText = 'Search Me!'; |
48 | - $form = $searchPage->SearchPageForm('testsearchpage',$buttonText); |
|
48 | + $form = $searchPage->SearchPageForm('testsearchpage', $buttonText); |
|
49 | 49 | $actions = $form->Actions(); |
50 | 50 | $this->assertEquals($buttonText, $actions->FieldByName('action_submit')->Title()); |
51 | 51 | } |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | $esp = new ElasticSearchPage(); |
87 | 87 | // ensure default identifier |
88 | 88 | $esp->Identifier = $searchPage->Identifier; |
89 | - $esp->Title='This should not be saved'; |
|
89 | + $esp->Title = 'This should not be saved'; |
|
90 | 90 | try { |
91 | 91 | $esp->write(); |
92 | 92 | $this->assertFalse(true, 'Duplicate identifier was incorrectly saved'); |
93 | 93 | } catch (Exception $e) { |
94 | - $this->assertTrue(true,'The page could not be saved as expected, due to duplicate '. |
|
94 | + $this->assertTrue(true, 'The page could not be saved as expected, due to duplicate ' . |
|
95 | 95 | 'identifier'); |
96 | 96 | } |
97 | 97 | } |