Completed
Push — dev2 ( 7e05a9...7c5a8d )
by Gordon
23:11 queued 08:20
created
tests/AggregationUnitTest.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		$aggregations = $resultList->getAggregations();
34 34
 
35 35
 		error_log('AGGS');
36
-		foreach ($aggregations as $agg) {
36
+		foreach($aggregations as $agg) {
37 37
 			error_log($agg->Name);
38 38
 		}
39 39
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 		$resultList = $this->search('');
427 427
 
428 428
 		//assert there are actually some results
429
-		$this->assertGreaterThan(0,$resultList->getTotalItems());
429
+		$this->assertGreaterThan(0, $resultList->getTotalItems());
430 430
 		$aggregations = $resultList->getAggregations()->toArray();
431 431
 
432 432
 		/*
@@ -445,49 +445,49 @@  discard block
 block discarded – undo
445 445
 		//Asserting aggregate of ISO, 64 has count 5
446 446
 		$this->assertEquals("64", $buckets[0]->Key);
447 447
 		$this->assertEquals(5, $buckets[0]->DocumentCount);
448
-		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',64)->count(),5);
448
+		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 64)->count(), 5);
449 449
 		$bucketSum += $buckets[0]->DocumentCount;
450 450
 
451 451
 		//Asserting aggregate of ISO, 100 has count 11
452 452
 		$this->assertEquals("100", $buckets[1]->Key);
453 453
 		$this->assertEquals(11, $buckets[1]->DocumentCount);
454
-		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',100)->count(),11);
454
+		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 100)->count(), 11);
455 455
 		$bucketSum += $buckets[1]->DocumentCount;
456 456
 
457 457
 		//Asserting aggregate of ISO, 200 has count 12
458 458
 		$this->assertEquals("200", $buckets[2]->Key);
459 459
 		$this->assertEquals(12, $buckets[2]->DocumentCount);
460
-		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',200)->count(),12);
460
+		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 200)->count(), 12);
461 461
 		$bucketSum += $buckets[2]->DocumentCount;
462 462
 
463 463
 		//Asserting aggregate of ISO, 400 has count 13
464 464
 		$this->assertEquals("400", $buckets[3]->Key);
465 465
 		$this->assertEquals(13, $buckets[3]->DocumentCount);
466
-		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',400)->count(),13);
466
+		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 400)->count(), 13);
467 467
 		$bucketSum += $buckets[3]->DocumentCount;
468 468
 
469 469
 		//Asserting aggregate of ISO, 800 has count 16
470 470
 		$this->assertEquals("800", $buckets[4]->Key);
471 471
 		$this->assertEquals(16, $buckets[4]->DocumentCount);
472
-		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',800)->count(),16);
472
+		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 800)->count(), 16);
473 473
 		$bucketSum += $buckets[4]->DocumentCount;
474 474
 
475 475
 		//Asserting aggregate of ISO, 1600 has count 13
476 476
 		$this->assertEquals("1600", $buckets[5]->Key);
477 477
 		$this->assertEquals(13, $buckets[5]->DocumentCount);
478
-		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',1600)->count(),13);
478
+		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 1600)->count(), 13);
479 479
 		$bucketSum += $buckets[5]->DocumentCount;
480 480
 
481 481
 		//Asserting aggregate of ISO, 2000 has count 11
482 482
 		$this->assertEquals("2000", $buckets[6]->Key);
483 483
 		$this->assertEquals(11, $buckets[6]->DocumentCount);
484
-		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',2000)->count(),11);
484
+		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 2000)->count(), 11);
485 485
 		$bucketSum += $buckets[6]->DocumentCount;
486 486
 
487 487
 		//Asserting aggregate of ISO, 3200 has count 19
488 488
 		$this->assertEquals("3200", $buckets[7]->Key);
489 489
 		$this->assertEquals(19, $buckets[7]->DocumentCount);
490
-		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',3200)->count(),19);
490
+		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 3200)->count(), 19);
491 491
 		$bucketSum += $buckets[7]->DocumentCount;
492 492
 		$this->assertEquals(100, $bucketSum);
493 493
 
@@ -500,43 +500,43 @@  discard block
 block discarded – undo
500 500
 		//Asserting aggregate of Focal Length, 24 has count 12
501 501
 		$this->assertEquals("24", $buckets[0]->Key);
502 502
 		$this->assertEquals(12, $buckets[0]->DocumentCount);
503
-		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',24)->count(),12);
503
+		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 24)->count(), 12);
504 504
 		$bucketSum += $buckets[0]->DocumentCount;
505 505
 
506 506
 		//Asserting aggregate of Focal Length, 50 has count 11
507 507
 		$this->assertEquals("50", $buckets[1]->Key);
508 508
 		$this->assertEquals(11, $buckets[1]->DocumentCount);
509
-		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',50)->count(),11);
509
+		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 50)->count(), 11);
510 510
 		$bucketSum += $buckets[1]->DocumentCount;
511 511
 
512 512
 		//Asserting aggregate of Focal Length, 80 has count 11
513 513
 		$this->assertEquals("80", $buckets[2]->Key);
514 514
 		$this->assertEquals(11, $buckets[2]->DocumentCount);
515
-		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',80)->count(),11);
515
+		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 80)->count(), 11);
516 516
 		$bucketSum += $buckets[2]->DocumentCount;
517 517
 
518 518
 		//Asserting aggregate of Focal Length, 90 has count 20
519 519
 		$this->assertEquals("90", $buckets[3]->Key);
520 520
 		$this->assertEquals(20, $buckets[3]->DocumentCount);
521
-		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',90)->count(),20);
521
+		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 90)->count(), 20);
522 522
 		$bucketSum += $buckets[3]->DocumentCount;
523 523
 
524 524
 		//Asserting aggregate of Focal Length, 120 has count 12
525 525
 		$this->assertEquals("120", $buckets[4]->Key);
526 526
 		$this->assertEquals(12, $buckets[4]->DocumentCount);
527
-		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',120)->count(),12);
527
+		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 120)->count(), 12);
528 528
 		$bucketSum += $buckets[4]->DocumentCount;
529 529
 
530 530
 		//Asserting aggregate of Focal Length, 150 has count 17
531 531
 		$this->assertEquals("150", $buckets[5]->Key);
532 532
 		$this->assertEquals(17, $buckets[5]->DocumentCount);
533
-		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',150)->count(),17);
533
+		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 150)->count(), 17);
534 534
 		$bucketSum += $buckets[5]->DocumentCount;
535 535
 
536 536
 		//Asserting aggregate of Focal Length, 200 has count 17
537 537
 		$this->assertEquals("200", $buckets[6]->Key);
538 538
 		$this->assertEquals(17, $buckets[6]->DocumentCount);
539
-		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',200)->count(),17);
539
+		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 200)->count(), 17);
540 540
 		$bucketSum += $buckets[6]->DocumentCount;
541 541
 		$this->assertEquals(100, $bucketSum);
542 542
 
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		$originalAggregations = $resultList->getAggregations()->toArray();
825 825
 
826 826
 		$filters = array('ISO' => 3200);
827
-		$resultListFiltered = $this->search('New Zealand', $fields,$filters);
827
+		$resultListFiltered = $this->search('New Zealand', $fields, $filters);
828 828
 		$filteredAggregations = $resultListFiltered->getAggregations()->toArray();
829 829
 
830 830
 		$this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations);
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 		$resultList = $this->search('New Zealand', $fields, array('ISO' => 400));
837 837
 		$originalAggregations = $resultList->getAggregations()->toArray();
838 838
 
839
-		$filters = array('ISO' => 400, 'Aspect' => 'Vertical' );
840
-		$resultListFiltered = $this->search('New Zealand', $fields,$filters);
839
+		$filters = array('ISO' => 400, 'Aspect' => 'Vertical');
840
+		$resultListFiltered = $this->search('New Zealand', $fields, $filters);
841 841
 		$filteredAggregations = $resultListFiltered->getAggregations()->toArray();
842 842
 
843 843
 		$this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations);
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 										'Aspect' => 'Vertical'));
853 853
 		$originalAggregations = $resultList->getAggregations()->toArray();
854 854
 
855
-		$filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5 );
856
-		$resultListFiltered = $this->search('New Zealand', $fields,$filters);
855
+		$filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5);
856
+		$resultListFiltered = $this->search('New Zealand', $fields, $filters);
857 857
 		$filteredAggregations = $resultListFiltered->getAggregations()->toArray();
858 858
 
859 859
 		$this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations);
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 	private function checkDrillingDownHasHappened($filteredAggregations, $originalAggregations) {
894 894
 		$aggCtr = 0;
895 895
 
896
-		foreach ($filteredAggregations as $filteredAgg) {
896
+		foreach($filteredAggregations as $filteredAgg) {
897 897
 			$origAgg = $originalAggregations[$aggCtr];
898 898
 			$bucketCtr = 0;
899 899
 			$origBuckets = $origAgg->Buckets->toArray();
@@ -902,17 +902,17 @@  discard block
 block discarded – undo
902 902
 			$origCounts = array();
903 903
 			$filteredCounts = array();
904 904
 
905
-			foreach ($origBuckets as $bucket) {
905
+			foreach($origBuckets as $bucket) {
906 906
 				$origCounts[$bucket->Key] = $bucket->DocumentCount;
907 907
 			}
908 908
 
909
-			foreach ($filteredBuckets as $bucket) {
909
+			foreach($filteredBuckets as $bucket) {
910 910
 				$filteredCounts[$bucket->Key] = $bucket->DocumentCount;
911 911
 			}
912 912
 
913 913
 			$akf = array_keys($filteredCounts);
914 914
 
915
-			foreach ($akf as $aggregateKey) {
915
+			foreach($akf as $aggregateKey) {
916 916
 				$this->assertGreaterThanOrEqual(
917 917
 					$filteredCounts[$aggregateKey], $origCounts[$aggregateKey]
918 918
 				);
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 		$es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper');
949 949
 
950 950
 		//Add filters
951
-		foreach ($filters as $key => $value) {
952
-			$es->addFilter($key,$value);
951
+		foreach($filters as $key => $value) {
952
+			$es->addFilter($key, $value);
953 953
 		}
954 954
 
955 955
 		$es->showResultsForEmptySearch();
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 	 * Test searching
969 969
 	 * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming
970 970
 	 */
971
-	private function search($queryText,$fields = array('Title' => 1, 'Description' => 1),
971
+	private function search($queryText, $fields = array('Title' => 1, 'Description' => 1),
972 972
 		$filters = array()) {
973 973
 		$es = new ElasticSearcher();
974 974
 		$es->setStart(0);
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
 		$es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper');
978 978
 
979 979
 		//Add filters
980
-		foreach ($filters as $key => $value) {
981
-			$es->addFilter($key,$value);
980
+		foreach($filters as $key => $value) {
981
+			$es->addFilter($key, $value);
982 982
 		}
983 983
 
984 984
 		$es->showResultsForEmptySearch();
Please login to merge, or discard this patch.