Completed
Push — dev2 ( 81982f...c82b6b )
by Gordon
02:56
created
tests/ElasticSearchPageControllerTest.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
 		$this->assertEquals(200, $searchPage->getStatusCode());
116 116
 		$url = rtrim($url,'/');
117 117
 
118
-        $response = $this->get($url);
119
-        $this->assertEquals(200, $response->getStatusCode());
118
+		$response = $this->get($url);
119
+		$this->assertEquals(200, $response->getStatusCode());
120 120
 
121
-        $this->assertSelectorStartsWithOrEquals('span.count', 0, '(5)');
121
+		$this->assertSelectorStartsWithOrEquals('span.count', 0, '(5)');
122 122
 		$this->assertSelectorStartsWithOrEquals('span.count', 1, '(11)');
123 123
 		$this->assertSelectorStartsWithOrEquals('span.count', 2, '(12)');
124 124
 		$this->assertSelectorStartsWithOrEquals('span.count', 3, '(13)');
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 		$url = rtrim($url,'/');
169 169
 		$url .= '?ISO=400';
170 170
 
171
-        $response = $this->get($url);
172
-        $this->assertEquals(200, $response->getStatusCode());
171
+		$response = $this->get($url);
172
+		$this->assertEquals(200, $response->getStatusCode());
173 173
 
174
-        // These are less than in the no facets selected case, as expected
174
+		// These are less than in the no facets selected case, as expected
175 175
 		$this->assertSelectorStartsWithOrEquals('span.count', 0, '(2)');
176 176
 		$this->assertSelectorStartsWithOrEquals('span.count', 1, '(1)');
177 177
 		$this->assertSelectorStartsWithOrEquals('span.count', 2, '(2)');
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 		$url = rtrim($url,'/');
216 216
 		$url .= '?ISO=400&ShutterSpeed=2%2F250';
217 217
 
218
-        $response = $this->get($url);
218
+		$response = $this->get($url);
219 219
 		print_r($response);
220
-        $this->assertEquals(200, $response->getStatusCode());
220
+		$this->assertEquals(200, $response->getStatusCode());
221 221
 
222
-        // These are less than in the one facet selected case, as expected
223
-        $this->assertSelectorStartsWithOrEquals('span.count', 0, '(1)');
222
+		// These are less than in the one facet selected case, as expected
223
+		$this->assertSelectorStartsWithOrEquals('span.count', 0, '(1)');
224 224
 		$this->assertSelectorStartsWithOrEquals('span.count', 1, '(2)');
225 225
 		$this->assertSelectorStartsWithOrEquals('span.count', 2, '(1)');
226 226
 		$this->assertSelectorStartsWithOrEquals('span.count', 3, '(1)');
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
 		$url = rtrim($url,'/');
250 250
 		$url .= '?ISO=400&ShutterSpeed=2%2F250&Aspect=Vertical';
251 251
 
252
-        $response = $this->get($url);
252
+		$response = $this->get($url);
253 253
 		print_r($response);
254
-        $this->assertEquals(200, $response->getStatusCode());
254
+		$this->assertEquals(200, $response->getStatusCode());
255 255
 
256
-        // These are less than in the one facet selected case, as expected
257
-        $this->assertSelectorStartsWithOrEquals('span.count', 0, '(2)');
256
+		// These are less than in the one facet selected case, as expected
257
+		$this->assertSelectorStartsWithOrEquals('span.count', 0, '(2)');
258 258
 		$this->assertSelectorStartsWithOrEquals('span.count', 1, '(1)');
259 259
 		$this->assertSelectorStartsWithOrEquals('span.count', 2, '(1)');
260 260
 	}
@@ -602,13 +602,13 @@  discard block
 block discarded – undo
602 602
 		$searchPage = $this->get($searchPageObj->URLSegment);
603 603
 		$this->assertEquals(200, $searchPage->getStatusCode());
604 604
 
605
-        $response = $this->submitForm("ElasticSearchForm_SearchForm", null, array(
606
-            'q' => 'New Zealand'
607
-        ));
605
+		$response = $this->submitForm("ElasticSearchForm_SearchForm", null, array(
606
+			'q' => 'New Zealand'
607
+		));
608 608
 
609 609
 		$url = rtrim($url,'/');
610
-        $this->assertEquals(302, $response->getStatusCode());
611
-        $this->assertEquals($url.'?q=New Zealand&sfid=testwithagg', $response->getHeader('Location'));
610
+		$this->assertEquals(302, $response->getStatusCode());
611
+		$this->assertEquals($url.'?q=New Zealand&sfid=testwithagg', $response->getHeader('Location'));
612 612
 	}
613 613
 
614 614
 
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
 		$extraFields = array('Searchable' => 1, 'SimilarSearchable' => 1, 'Active' => 1,
41 41
 			'Weight' => 1);
42 42
 		$esfs2 = $esp2->ElasticaSearchableFields();
43
-		foreach ($esfs2 as $sf) {
44
-			if ($sf->Name == 'Title' || $sf->Name == 'Description') {
43
+		foreach($esfs2 as $sf) {
44
+			if($sf->Name == 'Title' || $sf->Name == 'Description') {
45 45
 				$esfs2->remove($sf);
46 46
 				$esfs2->add($sf, $extraFields);
47 47
 			}
48 48
 		}
49 49
 		$esp2->write();
50 50
 
51
-		$esfs= $esp->ElasticaSearchableFields();
51
+		$esfs = $esp->ElasticaSearchableFields();
52 52
 
53
-		foreach ($esfs as $sf) {
54
-			if ($sf->Name == 'Title' || $sf->Name == 'Description') {
53
+		foreach($esfs as $sf) {
54
+			if($sf->Name == 'Title' || $sf->Name == 'Description') {
55 55
 				$esfs->remove($sf);
56 56
 				$esfs->add($sf, $extraFields);
57 57
 			}
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 		$esp->ElasticaSearchableFields()->add($espf2);
81 81
 		$esp2->ElasticaSearchableFields()->add($espf2);
82 82
 */
83
-		$esp->publish('Stage','Live');
84
-		$esp2->publish('Stage','Live');
83
+		$esp->publish('Stage', 'Live');
84
+		$esp2->publish('Stage', 'Live');
85 85
 		$this->ElasticSearchPage = $esp;
86
-		$this->ElasticSearchPage2= $esp2;
86
+		$this->ElasticSearchPage2 = $esp2;
87 87
 
88 88
 
89 89
 		echo "CHECK MYSQL";
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		$url = $searchPageObj->Link();
114 114
 		$searchPage = $this->get($searchPageObj->URLSegment);
115 115
 		$this->assertEquals(200, $searchPage->getStatusCode());
116
-		$url = rtrim($url,'/');
116
+		$url = rtrim($url, '/');
117 117
 
118 118
         $response = $this->get($url);
119 119
         $this->assertEquals(200, $response->getStatusCode());
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		$url = $searchPageObj->Link();
166 166
 		$searchPage = $this->get($searchPageObj->URLSegment);
167 167
 		$this->assertEquals(200, $searchPage->getStatusCode());
168
-		$url = rtrim($url,'/');
168
+		$url = rtrim($url, '/');
169 169
 		$url .= '?ISO=400';
170 170
 
171 171
         $response = $this->get($url);
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		$url = $searchPageObj->Link();
213 213
 		$searchPage = $this->get($searchPageObj->URLSegment);
214 214
 		$this->assertEquals(200, $searchPage->getStatusCode());
215
-		$url = rtrim($url,'/');
215
+		$url = rtrim($url, '/');
216 216
 		$url .= '?ISO=400&ShutterSpeed=2%2F250';
217 217
 
218 218
         $response = $this->get($url);
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		$url = $searchPageObj->Link();
247 247
 		$searchPage = $this->get($searchPageObj->URLSegment);
248 248
 		$this->assertEquals(200, $searchPage->getStatusCode());
249
-		$url = rtrim($url,'/');
249
+		$url = rtrim($url, '/');
250 250
 		$url .= '?ISO=400&ShutterSpeed=2%2F250&Aspect=Vertical';
251 251
 
252 252
         $response = $this->get($url);
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 	public function testQueryInSearchBoxForOneFormOnly() {
291 291
 		$searchPageObj = $this->ElasticSearchPage2;
292 292
 		$url = rtrim($searchPageObj->Link(), '/');
293
-		$url .= "?q=Auckland&sfid=".$searchPageObj->Identifier;
293
+		$url .= "?q=Auckland&sfid=" . $searchPageObj->Identifier;
294 294
 
295
-		echo "URL:".$url;
295
+		echo "URL:" . $url;
296 296
 		$response = $this->get($url);
297 297
 
298 298
 		print_r($response);
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		$pageLength = 10; // the default
320 320
 		$searchPageObj->ResultsPerPage = $pageLength;
321 321
 		$searchPageObj->write();
322
-		$searchPageObj->publish('Stage','Live');
322
+		$searchPageObj->publish('Stage', 'Live');
323 323
 
324 324
 		$url = rtrim($searchPageObj->Link(), '/');
325 325
 		$response = $this->get($url);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 		//Note pages need to be published, by default fixtures only reside in Stage
559 559
 		$searchPageObj = $this->ElasticSearchPage2;
560 560
 		$url = rtrim($searchPageObj->Link(), '/');
561
-		$url = $url.'?q='.$searchTerm;
561
+		$url = $url . '?q=' . $searchTerm;
562 562
 		echo "URL:$url\n";
563 563
 		$response = $this->get($url);
564 564
 		$this->assertEquals(200, $response->getStatusCode());
@@ -606,9 +606,9 @@  discard block
 block discarded – undo
606 606
             'q' => 'New Zealand'
607 607
         ));
608 608
 
609
-		$url = rtrim($url,'/');
609
+		$url = rtrim($url, '/');
610 610
         $this->assertEquals(302, $response->getStatusCode());
611
-        $this->assertEquals($url.'?q=New Zealand&sfid=testwithagg', $response->getHeader('Location'));
611
+        $this->assertEquals($url . '?q=New Zealand&sfid=testwithagg', $response->getHeader('Location'));
612 612
 	}
613 613
 
614 614
 
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 		//Note pages need to be published, by default fixtures only reside in Stage
629 629
 		$searchPageObj = $this->ElasticSearchPage;
630 630
 		$url = rtrim($searchPageObj->Link(), '/');
631
-		$url = $url.'?q='.$searchTerm;
631
+		$url = $url . '?q=' . $searchTerm;
632 632
 		echo "URL:$url\n";
633 633
 		$response = $this->get($url);
634 634
 		$this->assertEquals(200, $response->getStatusCode());
@@ -673,13 +673,13 @@  discard block
 block discarded – undo
673 673
 		$searchPageObj = $this->ElasticSearchPage;
674 674
 		$searchPageObj->SiteTreeOnly = true;
675 675
 		$searchPageObj->write();
676
-		$searchPageObj->publish('Stage','Live');
676
+		$searchPageObj->publish('Stage', 'Live');
677 677
 
678 678
 
679 679
 		$pageLength = 10; // the default
680 680
 		$searchPageObj->ResultsPerPage = $pageLength;
681 681
 		$url = rtrim($searchPageObj->Link(), '/');
682
-		$url = $url.'?q='.$searchTerm;
682
+		$url = $url . '?q=' . $searchTerm;
683 683
 		$firstPageURL = $url;
684 684
 		$response = $this->get($url);
685 685
 		$this->assertEquals(200, $response->getStatusCode());
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		$pageLength = 10; // the default
715 715
 		$searchPageObj->ResultsPerPage = $pageLength;
716 716
 		$url = rtrim($searchPageObj->Link(), '/');
717
-		$url = $url.'?q='.$searchTerm;
717
+		$url = $url . '?q=' . $searchTerm;
718 718
 		$firstPageURL = $url;
719 719
 		$response = $this->get($url);
720 720
 		$this->assertEquals(200, $response->getStatusCode());
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 
740 740
 		$resultsP1 = $this->collateSearchResults();
741 741
 
742
-		$page2url = $url . '&start='.$pageLength;
742
+		$page2url = $url . '&start=' . $pageLength;
743 743
 
744 744
 		//Check pagination on page 2
745 745
 		$response2 = $this->get($page2url);
@@ -766,19 +766,19 @@  discard block
 block discarded – undo
766 766
 		//increase the number of results and assert that they are the same as per pages 1,2 joined
767 767
 		$searchPageObj->ResultsPerPage = 20;
768 768
 		$searchPageObj->write();
769
-		$searchPageObj->publish('Stage','Live');
769
+		$searchPageObj->publish('Stage', 'Live');
770 770
 		$response3 = $this->get($firstPageURL);
771 771
 	}
772 772
 
773 773
 
774 774
 	private function enableHighlights() {
775
-		foreach (SearchableField::get()->filter('Name', 'Title') as $sf) {
775
+		foreach(SearchableField::get()->filter('Name', 'Title') as $sf) {
776 776
 			echo "Highlighting {$sf->ClazzName} {$sf->Name}\n";
777 777
 			$sf->ShowHighlights = true;
778 778
 			$sf->write();
779 779
 		}
780 780
 
781
-		foreach (SearchableField::get()->filter('Name', 'Content') as $sf) {
781
+		foreach(SearchableField::get()->filter('Name', 'Content') as $sf) {
782 782
 			echo "Highlighting {$sf->ClazzName} {$sf->Name}\n";
783 783
 
784 784
 			$sf->ShowHighlights = true;
Please login to merge, or discard this patch.
tests/TermVectorTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
tests/QueryGeneratorTest.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
tests/ElasticaServiceTest.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
tests/FindElasticaSearchPageExtensionTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
src/SilverStripe/Elastica/ElasticaSearcher.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 
435 435
 
436 436
 
437
-        $query = new Query();
438
-        $query->setParams(array('query' => array('more_like_this' => $mlt)));
437
+		$query = new Query();
438
+		$query->setParams(array('query' => array('more_like_this' => $mlt)));
439 439
 
440 440
 
441
-        $elasticService = \Injector::inst()->create('SilverStripe\Elastica\ElasticaService');
441
+		$elasticService = \Injector::inst()->create('SilverStripe\Elastica\ElasticaService');
442 442
 		$elasticService->setLocale($this->locale);
443 443
 		if ($testMode) {
444 444
 			$elasticService->setTestMode(true);
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 		$query->setFrom($this->start);
451 451
 
452 452
 		$resultList = new ResultList($elasticService, $query, null);
453
-        // at this point ResultList object, not yet executed search query
453
+		// at this point ResultList object, not yet executed search query
454 454
 		$paginated = new \PaginatedList(
455 455
 			$resultList
456 456
 		);
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 	 *                              e.g. array('Title' => array('Weight' => 2, 'Type' => 'string'))
245 245
 	 * @return ArrayList    SilverStripe DataObjects returned from the search against ElasticSearch
246 246
 	 */
247
-	public function search($queryText, $fieldsToSearch = null,  $testMode = false) {
248
-		if ($this->locale == null) {
249
-			if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
247
+	public function search($queryText, $fieldsToSearch = null, $testMode = false) {
248
+		if($this->locale == null) {
249
+			if(class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
250 250
 				$this->locale = \Translatable::get_current_locale();
251 251
 			} else {
252 252
 				// if no translatable we only have the default locale
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		$elasticService = \Injector::inst()->create('SilverStripe\Elastica\ElasticaService');
274 274
 		$elasticService->setLocale($this->locale);
275 275
 		$elasticService->setHighlightedFields($this->highlightedFields);
276
-		if ($testMode) {
276
+		if($testMode) {
277 277
 			$elasticService->setTestMode(true);
278 278
 		}
279 279
 		$resultList = new ResultList($elasticService, $query, $queryText, $this->filters);
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 
299 299
 		$this->aggregations = $resultList->getAggregations();
300 300
 
301
-		if ($resultList->SuggestedQuery) {
301
+		if($resultList->SuggestedQuery) {
302 302
 			$this->SuggestedQuery = $resultList->SuggestedQuery;
303 303
 			$this->SuggestedQueryHighlighted = $resultList->SuggestedQueryHighlighted;
304 304
 		}
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 
309 309
 	/* Perform an autocomplete search */
310 310
 	public function autocomplete_search($queryText, $field) {
311
-		if ($this->locale == null) {
312
-			if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
311
+		if($this->locale == null) {
312
+			if(class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
313 313
 				$this->locale = \Translatable::get_current_locale();
314 314
 			} else {
315 315
 				// if no translatable we only have the default locale
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 		echo "FIELD\n";
325 325
 		print_r($field);
326 326
 		$qg->setFields(array($field => 1));
327
-		if ($this->classes) {
327
+		if($this->classes) {
328 328
 			$qg->setClasses($this->classes);
329 329
 		}
330 330
 
331
-		if (!empty($this->filters)) {
331
+		if(!empty($this->filters)) {
332 332
 			$qg->setSelectedFilters($this->filters);
333 333
 		}
334 334
 
@@ -365,22 +365,22 @@  discard block
 block discarded – undo
365 365
 	 * @return resultList  List of results
366 366
 	 */
367 367
 	public function moreLikeThis($indexedItem, $fieldsToSearch, $testMode = false) {
368
-		echo "INDEXED ITEM:".$indexedItem;
368
+		echo "INDEXED ITEM:" . $indexedItem;
369 369
 
370
-		if ($indexedItem == null) {
370
+		if($indexedItem == null) {
371 371
 			throw new \InvalidArgumentException('A searchable item cannot be null');
372 372
 		}
373 373
 
374
-		if (!$indexedItem->hasExtension('SilverStripe\Elastica\Searchable')) {
375
-			throw new \InvalidArgumentException('Objects of class '.$indexedItem->ClassName.' are not searchable');
374
+		if(!$indexedItem->hasExtension('SilverStripe\Elastica\Searchable')) {
375
+			throw new \InvalidArgumentException('Objects of class ' . $indexedItem->ClassName . ' are not searchable');
376 376
 		}
377 377
 
378
-		if ($fieldsToSearch == null) {
378
+		if($fieldsToSearch == null) {
379 379
 			throw new \InvalidArgumentException('Fields cannot be null');
380 380
 		}
381 381
 
382
-		if ($this->locale == null) {
383
-			if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
382
+		if($this->locale == null) {
383
+			if(class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
384 384
 				$this->locale = \Translatable::get_current_locale();
385 385
 			} else {
386 386
 				// if no translatable we only have the default locale
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
 		}
390 390
 
391 391
 		$weightedFieldsArray = array();
392
-		foreach ($fieldsToSearch as $field => $weighting) {
393
-			if (!is_string($field)) {
392
+		foreach($fieldsToSearch as $field => $weighting) {
393
+			if(!is_string($field)) {
394 394
 				throw new \InvalidArgumentException('Fields must be of the form fieldname => weight');
395 395
 			}
396
-			if (!is_numeric($weighting)) {
396
+			if(!is_numeric($weighting)) {
397 397
 				throw new \InvalidArgumentException('Fields must be of the form fieldname => weight');
398 398
 			}
399
-			$weightedField = $field.'^'.$weighting;
399
+			$weightedField = $field . '^' . $weighting;
400 400
 			$weightedField = str_replace('^1', '', $weightedField);
401 401
 			array_push($weightedFieldsArray, $weightedField);
402 402
 		}
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 			'stop_words' => explode(',', $this->similarityStopWords)
429 429
 		);
430 430
 
431
-		if ($this->maxDocFreq > 0) {
431
+		if($this->maxDocFreq > 0) {
432 432
 			$mlt['max_doc_freq'] = $this->maxDocFreq;
433 433
 		}
434 434
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 
441 441
         $elasticService = \Injector::inst()->create('SilverStripe\Elastica\ElasticaService');
442 442
 		$elasticService->setLocale($this->locale);
443
-		if ($testMode) {
443
+		if($testMode) {
444 444
 			$elasticService->setTestMode(true);
445 445
 		}
446 446
 
Please login to merge, or discard this patch.
Doc Comments   +13 added lines, -4 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 	/**
126 126
 	 * Set the manipulator, mainly used for aggregation
127
-	 * @param ElasticaSearchHelper $newManipulator manipulator used for aggregation
127
+	 * @param string $newManipulator manipulator used for aggregation
128 128
 	 */
129 129
 	public function setQueryResultManipulator($newManipulator) {
130 130
 		$this->manipulator = $newManipulator;
@@ -196,6 +196,7 @@  discard block
 block discarded – undo
196 196
 	/**
197 197
 	 * Set the maximum number of documents a term can reside in for consideration as
198 198
 	 * part of the input query
199
+	 * @param integer $newMaxDocFreq
199 200
 	 */
200 201
 	public function setMaxDocFreq($newMaxDocFreq) {
201 202
 		$this->maxDocFreq = $newMaxDocFreq;
@@ -230,6 +231,10 @@  discard block
 block discarded – undo
230 231
 	/*
231 232
 	Set the highlight fields for subsequent searches
232 233
 	 */
234
+
235
+	/**
236
+	 * @param string[] $newHighlightedFields
237
+	 */
233 238
 	public function setHighlightedFields($newHighlightedFields) {
234 239
 		$this->highlightedFields = $newHighlightedFields;
235 240
 	}
@@ -242,7 +247,7 @@  discard block
 block discarded – undo
242 247
 	 * @param  string $queryText query string, e.g. 'New Zealand'
243 248
 	 * @param array $fieldsToSearch Mapping of name to an array of mapping Weight and Elastic mapping,
244 249
 	 *                              e.g. array('Title' => array('Weight' => 2, 'Type' => 'string'))
245
-	 * @return ArrayList    SilverStripe DataObjects returned from the search against ElasticSearch
250
+	 * @return \PaginatedList    SilverStripe DataObjects returned from the search against ElasticSearch
246 251
 	 */
247 252
 	public function search($queryText, $fieldsToSearch = null,  $testMode = false) {
248 253
 		if ($this->locale == null) {
@@ -307,6 +312,10 @@  discard block
 block discarded – undo
307 312
 
308 313
 
309 314
 	/* Perform an autocomplete search */
315
+
316
+	/**
317
+	 * @param string $queryText
318
+	 */
310 319
 	public function autocomplete_search($queryText, $field) {
311 320
 		if ($this->locale == null) {
312 321
 			if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
@@ -358,11 +367,11 @@  discard block
 block discarded – undo
358 367
 
359 368
 	/**
360 369
 	 * Perform a 'More Like This' search, aka relevance feedback, using the provided indexed DataObject
361
-	 * @param  DataObject $indexedItem A DataObject that has been indexed in Elasticsearch
370
+	 * @param  \DataObject|null $indexedItem A DataObject that has been indexed in Elasticsearch
362 371
 	 * @param  array $fieldsToSearch  array of fieldnames to search, mapped to weighting
363 372
 	 * @param  $$testMode Use all shards, not just one, for consistent results during unit testing. See
364 373
 	 *         https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-is-broken.html#relevance-is-broken
365
-	 * @return resultList  List of results
374
+	 * @return \PaginatedList  List of results
366 375
 	 */
367 376
 	public function moreLikeThis($indexedItem, $fieldsToSearch, $testMode = false) {
368 377
 		echo "INDEXED ITEM:".$indexedItem;
Please login to merge, or discard this patch.
src/SilverStripe/Elastica/RangedAggregation.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@
 block discarded – undo
38 38
 					$to = $range['to'];
39 39
 				}
40 40
 				$rangeFilter = array('gte' => (string)$from, 'lt' => (string)$to);
41
-		        $filter = new \Elastica\Filter\Range('AspectRatio', $rangeFilter);
42
-		        $result = $filter;
41
+				$filter = new \Elastica\Filter\Range('AspectRatio', $rangeFilter);
42
+				$result = $filter;
43 43
 			}
44 44
 		}
45 45
 
Please login to merge, or discard this patch.
src/SilverStripe/Elastica/indexing/GermanIndexSettings.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 		$germanWithURLs = array(
29 29
 			'tokenizer' => 'uax_url_email',
30 30
 			//'filter' => array('english_possessive_stemmer', 'lowercase', 'english_stop', /*'english_keywords',*/ 'english_stemmer' ),
31
-			'filter' => array('no_single_chars', 'german_snowball', 'lowercase', 'german_stop' ),
31
+			'filter' => array('no_single_chars', 'german_snowball', 'lowercase', 'german_stop'),
32 32
 			'type' => 'custom'
33 33
 		);
34 34
 
Please login to merge, or discard this patch.
src/SilverStripe/Elastica/indexing/BaseIndexSettings.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@
 block discarded – undo
214 214
 			$analyzers['folded'] = $analyzerFolded;
215 215
 		}
216 216
 
217
-        //Store bigrams in the index, namely pairs of words
217
+		//Store bigrams in the index, namely pairs of words
218 218
 		$this->addFilter('filter_shingle', array(
219 219
 			'type' => 'shingle',
220 220
 			'min_shingle_size' => 2,
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 	 * @param array or string $newStopWords An array of stopwords or a CSV string of stopwords
87 87
 	 */
88 88
 	public function setStopwords($newStopWords) {
89
-		if (is_array($newStopWords)) {
89
+		if(is_array($newStopWords)) {
90 90
 			$this->stopWords = $newStopWords;
91
-		} else if (is_string($newStopWords)) {
91
+		} else if(is_string($newStopWords)) {
92 92
 			$this->stopWords = explode(',', $newStopWords);
93 93
 		} else {
94 94
 			throw new Exception("ERROR: Stopwords must be a string or an array");
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 			'type' => 'nGram',
178 178
 			'min_gram' => 2,
179 179
 			'max_gram' => 20,
180
-			'token_chars' => array('letter', 'digit','punctuation', 'symbol')
180
+			'token_chars' => array('letter', 'digit', 'punctuation', 'symbol')
181 181
 		));
182 182
 
183
-		$this->addAnalyzer('autocomplete_index_analyzer',array(
183
+		$this->addAnalyzer('autocomplete_index_analyzer', array(
184 184
 			'type' => 'custom',
185 185
 			'tokenizer' => 'whitespace',
186 186
 			'filter' => array(
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 			)
191 191
 		));
192 192
 
193
-		$this->addAnalyzer('autocomplete_search_analyzer',array(
193
+		$this->addAnalyzer('autocomplete_search_analyzer', array(
194 194
 			'type' => 'custom',
195 195
 			'tokenizer' => 'whitespace',
196 196
 			'filter' => array(
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		$this->analyzers['unstemmed'] = $analyzerNotStemmed;
211 211
 
212 212
 
213
-		if ($this->foldedAscii) {
213
+		if($this->foldedAscii) {
214 214
 			$analyzers['folded'] = $analyzerFolded;
215 215
 		}
216 216
 
Please login to merge, or discard this patch.