@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $aggregations = $resultList->getAggregations(); |
34 | 34 | |
35 | 35 | error_log('AGGS'); |
36 | - error_log(print_r($aggregations,1)); |
|
36 | + error_log(print_r($aggregations, 1)); |
|
37 | 37 | |
38 | 38 | //Asserting name of aggregate as ISO |
39 | 39 | $agg = $aggregations[0]; |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $resultList = $this->search(''); |
425 | 425 | |
426 | 426 | //assert there are actually some results |
427 | - $this->assertGreaterThan(0,$resultList->getTotalItems()); |
|
427 | + $this->assertGreaterThan(0, $resultList->getTotalItems()); |
|
428 | 428 | $aggregations = $resultList->getAggregations()->toArray(); |
429 | 429 | |
430 | 430 | /* |
@@ -443,49 +443,49 @@ discard block |
||
443 | 443 | //Asserting aggregate of ISO, 64 has count 5 |
444 | 444 | $this->assertEquals("64", $buckets[0]->Key); |
445 | 445 | $this->assertEquals(5, $buckets[0]->DocumentCount); |
446 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',64)->count(),5); |
|
446 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 64)->count(), 5); |
|
447 | 447 | $bucketSum += $buckets[0]->DocumentCount; |
448 | 448 | |
449 | 449 | //Asserting aggregate of ISO, 100 has count 11 |
450 | 450 | $this->assertEquals("100", $buckets[1]->Key); |
451 | 451 | $this->assertEquals(11, $buckets[1]->DocumentCount); |
452 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',100)->count(),11); |
|
452 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 100)->count(), 11); |
|
453 | 453 | $bucketSum += $buckets[1]->DocumentCount; |
454 | 454 | |
455 | 455 | //Asserting aggregate of ISO, 200 has count 12 |
456 | 456 | $this->assertEquals("200", $buckets[2]->Key); |
457 | 457 | $this->assertEquals(12, $buckets[2]->DocumentCount); |
458 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',200)->count(),12); |
|
458 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 200)->count(), 12); |
|
459 | 459 | $bucketSum += $buckets[2]->DocumentCount; |
460 | 460 | |
461 | 461 | //Asserting aggregate of ISO, 400 has count 13 |
462 | 462 | $this->assertEquals("400", $buckets[3]->Key); |
463 | 463 | $this->assertEquals(13, $buckets[3]->DocumentCount); |
464 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',400)->count(),13); |
|
464 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 400)->count(), 13); |
|
465 | 465 | $bucketSum += $buckets[3]->DocumentCount; |
466 | 466 | |
467 | 467 | //Asserting aggregate of ISO, 800 has count 16 |
468 | 468 | $this->assertEquals("800", $buckets[4]->Key); |
469 | 469 | $this->assertEquals(16, $buckets[4]->DocumentCount); |
470 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',800)->count(),16); |
|
470 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 800)->count(), 16); |
|
471 | 471 | $bucketSum += $buckets[4]->DocumentCount; |
472 | 472 | |
473 | 473 | //Asserting aggregate of ISO, 1600 has count 13 |
474 | 474 | $this->assertEquals("1600", $buckets[5]->Key); |
475 | 475 | $this->assertEquals(13, $buckets[5]->DocumentCount); |
476 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',1600)->count(),13); |
|
476 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 1600)->count(), 13); |
|
477 | 477 | $bucketSum += $buckets[5]->DocumentCount; |
478 | 478 | |
479 | 479 | //Asserting aggregate of ISO, 2000 has count 11 |
480 | 480 | $this->assertEquals("2000", $buckets[6]->Key); |
481 | 481 | $this->assertEquals(11, $buckets[6]->DocumentCount); |
482 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',2000)->count(),11); |
|
482 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 2000)->count(), 11); |
|
483 | 483 | $bucketSum += $buckets[6]->DocumentCount; |
484 | 484 | |
485 | 485 | //Asserting aggregate of ISO, 3200 has count 19 |
486 | 486 | $this->assertEquals("3200", $buckets[7]->Key); |
487 | 487 | $this->assertEquals(19, $buckets[7]->DocumentCount); |
488 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',3200)->count(),19); |
|
488 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 3200)->count(), 19); |
|
489 | 489 | $bucketSum += $buckets[7]->DocumentCount; |
490 | 490 | $this->assertEquals(100, $bucketSum); |
491 | 491 | |
@@ -498,43 +498,43 @@ discard block |
||
498 | 498 | //Asserting aggregate of Focal Length, 24 has count 12 |
499 | 499 | $this->assertEquals("24", $buckets[0]->Key); |
500 | 500 | $this->assertEquals(12, $buckets[0]->DocumentCount); |
501 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',24)->count(),12); |
|
501 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 24)->count(), 12); |
|
502 | 502 | $bucketSum += $buckets[0]->DocumentCount; |
503 | 503 | |
504 | 504 | //Asserting aggregate of Focal Length, 50 has count 11 |
505 | 505 | $this->assertEquals("50", $buckets[1]->Key); |
506 | 506 | $this->assertEquals(11, $buckets[1]->DocumentCount); |
507 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',50)->count(),11); |
|
507 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 50)->count(), 11); |
|
508 | 508 | $bucketSum += $buckets[1]->DocumentCount; |
509 | 509 | |
510 | 510 | //Asserting aggregate of Focal Length, 80 has count 11 |
511 | 511 | $this->assertEquals("80", $buckets[2]->Key); |
512 | 512 | $this->assertEquals(11, $buckets[2]->DocumentCount); |
513 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',80)->count(),11); |
|
513 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 80)->count(), 11); |
|
514 | 514 | $bucketSum += $buckets[2]->DocumentCount; |
515 | 515 | |
516 | 516 | //Asserting aggregate of Focal Length, 90 has count 20 |
517 | 517 | $this->assertEquals("90", $buckets[3]->Key); |
518 | 518 | $this->assertEquals(20, $buckets[3]->DocumentCount); |
519 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',90)->count(),20); |
|
519 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 90)->count(), 20); |
|
520 | 520 | $bucketSum += $buckets[3]->DocumentCount; |
521 | 521 | |
522 | 522 | //Asserting aggregate of Focal Length, 120 has count 12 |
523 | 523 | $this->assertEquals("120", $buckets[4]->Key); |
524 | 524 | $this->assertEquals(12, $buckets[4]->DocumentCount); |
525 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',120)->count(),12); |
|
525 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 120)->count(), 12); |
|
526 | 526 | $bucketSum += $buckets[4]->DocumentCount; |
527 | 527 | |
528 | 528 | //Asserting aggregate of Focal Length, 150 has count 17 |
529 | 529 | $this->assertEquals("150", $buckets[5]->Key); |
530 | 530 | $this->assertEquals(17, $buckets[5]->DocumentCount); |
531 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',150)->count(),17); |
|
531 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 150)->count(), 17); |
|
532 | 532 | $bucketSum += $buckets[5]->DocumentCount; |
533 | 533 | |
534 | 534 | //Asserting aggregate of Focal Length, 200 has count 17 |
535 | 535 | $this->assertEquals("200", $buckets[6]->Key); |
536 | 536 | $this->assertEquals(17, $buckets[6]->DocumentCount); |
537 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',200)->count(),17); |
|
537 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 200)->count(), 17); |
|
538 | 538 | $bucketSum += $buckets[6]->DocumentCount; |
539 | 539 | $this->assertEquals(100, $bucketSum); |
540 | 540 | |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | $originalAggregations = $resultList->getAggregations()->toArray(); |
823 | 823 | |
824 | 824 | $filters = array('ISO' => 3200); |
825 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
825 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
826 | 826 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
827 | 827 | |
828 | 828 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -834,8 +834,8 @@ discard block |
||
834 | 834 | $resultList = $this->search('New Zealand', $fields, array('ISO' => 400)); |
835 | 835 | $originalAggregations = $resultList->getAggregations()->toArray(); |
836 | 836 | |
837 | - $filters = array('ISO' => 400, 'Aspect' => 'Vertical' ); |
|
838 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
837 | + $filters = array('ISO' => 400, 'Aspect' => 'Vertical'); |
|
838 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
839 | 839 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
840 | 840 | |
841 | 841 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | 'Aspect' => 'Vertical')); |
851 | 851 | $originalAggregations = $resultList->getAggregations()->toArray(); |
852 | 852 | |
853 | - $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5 ); |
|
854 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
853 | + $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5); |
|
854 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
855 | 855 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
856 | 856 | |
857 | 857 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | private function checkDrillingDownHasHappened($filteredAggregations, $originalAggregations) { |
892 | 892 | $aggCtr = 0; |
893 | 893 | |
894 | - foreach ($filteredAggregations as $filteredAgg) { |
|
894 | + foreach($filteredAggregations as $filteredAgg) { |
|
895 | 895 | $origAgg = $originalAggregations[$aggCtr]; |
896 | 896 | $bucketCtr = 0; |
897 | 897 | $origBuckets = $origAgg->Buckets->toArray(); |
@@ -900,17 +900,17 @@ discard block |
||
900 | 900 | $origCounts = array(); |
901 | 901 | $filteredCounts = array(); |
902 | 902 | |
903 | - foreach ($origBuckets as $bucket) { |
|
903 | + foreach($origBuckets as $bucket) { |
|
904 | 904 | $origCounts[$bucket->Key] = $bucket->DocumentCount; |
905 | 905 | } |
906 | 906 | |
907 | - foreach ($filteredBuckets as $bucket) { |
|
907 | + foreach($filteredBuckets as $bucket) { |
|
908 | 908 | $filteredCounts[$bucket->Key] = $bucket->DocumentCount; |
909 | 909 | } |
910 | 910 | |
911 | 911 | $akf = array_keys($filteredCounts); |
912 | 912 | |
913 | - foreach ($akf as $aggregateKey) { |
|
913 | + foreach($akf as $aggregateKey) { |
|
914 | 914 | $this->assertGreaterThanOrEqual( |
915 | 915 | $filteredCounts[$aggregateKey], $origCounts[$aggregateKey] |
916 | 916 | ); |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | $es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); |
947 | 947 | |
948 | 948 | //Add filters |
949 | - foreach ($filters as $key => $value) { |
|
950 | - $es->addFilter($key,$value); |
|
949 | + foreach($filters as $key => $value) { |
|
950 | + $es->addFilter($key, $value); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | $es->showResultsForEmptySearch(); |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | * Test searching |
967 | 967 | * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming |
968 | 968 | */ |
969 | - private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), |
|
969 | + private function search($queryText, $fields = array('Title' => 1, 'Description' => 1), |
|
970 | 970 | $filters = array()) { |
971 | 971 | $es = new ElasticSearcher(); |
972 | 972 | $es->setStart(0); |
@@ -975,8 +975,8 @@ discard block |
||
975 | 975 | $es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); |
976 | 976 | |
977 | 977 | //Add filters |
978 | - foreach ($filters as $key => $value) { |
|
979 | - $es->addFilter($key,$value); |
|
978 | + foreach($filters as $key => $value) { |
|
979 | + $es->addFilter($key, $value); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | $es->showResultsForEmptySearch(); |