From 85135ca8c09241eee2e11c578c7ef07ca5c666ba Mon Sep 17 00:00:00 2001 From: Martynas Sudintas <martynas.sudintas@nfq.lt> Date: Mon, 10 Nov 2014 14:39:54 +0200 Subject: [PATCH] Updated unit tests to use new ongr/testing-bundle includes strict psr2 fixes --- Aggregation/FilterAggregationTest.php | 18 +++++----- Aggregation/GlobalAggregationTest.php | 10 ++++-- Aggregation/RangeAggregationTest.php | 40 +++++++++++++++++----- Aggregation/StatsAggregationTest.php | 4 +-- Aggregation/TermsAggregationTest.php | 47 +++++++++++++++++--------- Aggregation/TopHitsAggregationTest.php | 6 ++-- Suggester/CompletionTest.php | 21 ++++++++---- Suggester/PhraseTest.php | 14 +++++--- Suggester/TermTest.php | 14 +++++--- 9 files changed, 116 insertions(+), 58 deletions(-) diff --git a/Aggregation/FilterAggregationTest.php b/Aggregation/FilterAggregationTest.php index 8b3d863..ac05f99 100644 --- a/Aggregation/FilterAggregationTest.php +++ b/Aggregation/FilterAggregationTest.php @@ -43,15 +43,16 @@ class FilterAggregationTest extends \PHPUnit_Framework_TestCase 'agg_test_agg' => [ 'filter' => [ 'test_filter' => [ - 'test_field' => [ - 'test_value' => 'test', - ], + 'test_field' => ['test_value' => 'test'], ], ], ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #1 nested filter aggregation. $aggregation = new FilterAggregation('test_agg'); @@ -74,9 +75,7 @@ class FilterAggregationTest extends \PHPUnit_Framework_TestCase 'agg_test_agg' => [ 'filter' => [ 'test_filter' => [ - 'test_field' => [ - 'test_value' => 'test', - ], + 'test_field' => ['test_value' => 'test'], ], ], 'aggregations' => [ @@ -87,7 +86,10 @@ class FilterAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; return $out; } diff --git a/Aggregation/GlobalAggregationTest.php b/Aggregation/GlobalAggregationTest.php index 7aa2d5c..255d74d 100644 --- a/Aggregation/GlobalAggregationTest.php +++ b/Aggregation/GlobalAggregationTest.php @@ -33,7 +33,10 @@ class GlobalAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #1 nested global aggregation. $aggregation = new GlobalAggregation('test_agg'); @@ -51,7 +54,10 @@ class GlobalAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; return $out; } diff --git a/Aggregation/RangeAggregationTest.php b/Aggregation/RangeAggregationTest.php index c9d2f1f..339552f 100644 --- a/Aggregation/RangeAggregationTest.php +++ b/Aggregation/RangeAggregationTest.php @@ -34,14 +34,20 @@ class RangeAggregationTest extends \PHPUnit_Framework_TestCase 'range' => [ 'field' => 'test_field', 'ranges' => [ - ['from' => '10', 'to' => 20], + [ + 'from' => '10', + 'to' => 20, + ], ], 'keyed' => false, ], ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #1 multiple keyed ranges. $aggregation = new RangeAggregation('test_agg'); @@ -55,15 +61,24 @@ class RangeAggregationTest extends \PHPUnit_Framework_TestCase 'range' => [ 'field' => 'test_field', 'ranges' => [ - ['from' => '10', 'key' => 'range_1'], - ['to' => '20', 'key' => 'range_2'], + [ + 'from' => '10', + 'key' => 'range_1', + ], + [ + 'to' => '20', + 'key' => 'range_2', + ], ], 'keyed' => true, ], ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #2 nested aggregation. $aggregation = new RangeAggregation('test_agg'); @@ -80,7 +95,10 @@ class RangeAggregationTest extends \PHPUnit_Framework_TestCase 'range' => [ 'field' => 'test_field', 'ranges' => [ - ['from' => '10', 'to' => '10'], + [ + 'from' => '10', + 'to' => '10', + ], ], 'keyed' => false, ], @@ -88,7 +106,10 @@ class RangeAggregationTest extends \PHPUnit_Framework_TestCase 'agg_test_agg_2' => [ 'range' => [ 'ranges' => [ - ['from' => '20', 'to' => '20'], + [ + 'from' => '20', + 'to' => '20', + ], ], 'keyed' => false, ], @@ -97,7 +118,10 @@ class RangeAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; return $out; } diff --git a/Aggregation/StatsAggregationTest.php b/Aggregation/StatsAggregationTest.php index 7064849..bbf0e56 100644 --- a/Aggregation/StatsAggregationTest.php +++ b/Aggregation/StatsAggregationTest.php @@ -25,9 +25,7 @@ class StatsAggregationTest extends \PHPUnit_Framework_TestCase $expectedResult = [ 'agg_test_agg' => [ - 'stats' => [ - 'field' => 'test_field', - ], + 'stats' => ['field' => 'test_field'], ], ]; diff --git a/Aggregation/TermsAggregationTest.php b/Aggregation/TermsAggregationTest.php index 3de8137..4d3b341 100644 --- a/Aggregation/TermsAggregationTest.php +++ b/Aggregation/TermsAggregationTest.php @@ -30,13 +30,14 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase $result = [ 'agg_test_agg' => [ - 'terms' => [ - 'field' => 'test_field', - ], + 'terms' => ['field' => 'test_field'], ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #1 terms aggregation with size. $aggregation = new TermsAggregation('test_agg'); @@ -52,7 +53,10 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #2 terms aggregation with size and min document count. $aggregation = new TermsAggregation('test_agg'); @@ -70,7 +74,10 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #3 terms aggregation with simple include, exclude. $aggregation = new TermsAggregation('test_agg'); @@ -88,7 +95,10 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #4 terms aggregation with include, exclude and flags. $aggregation = new TermsAggregation('test_agg'); @@ -112,7 +122,10 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #5 terms aggregation with order default direction. $aggregation = new TermsAggregation('test_agg'); @@ -123,14 +136,15 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase 'agg_test_agg' => [ 'terms' => [ 'field' => 'test_field', - 'order' => [ - '_count' => 'asc', - ], + 'order' => ['_count' => 'asc'], ], ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; // Case #6 terms aggregation with order term mode, desc direction. $aggregation = new TermsAggregation('test_agg'); @@ -141,14 +155,15 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase 'agg_test_agg' => [ 'terms' => [ 'field' => 'test_field', - 'order' => [ - '_term' => 'desc', - ], + 'order' => ['_term' => 'desc'], ], ], ]; - $out[] = [$aggregation, $result]; + $out[] = [ + $aggregation, + $result, + ]; return $out; } diff --git a/Aggregation/TopHitsAggregationTest.php b/Aggregation/TopHitsAggregationTest.php index 2e97298..cdb12cb 100644 --- a/Aggregation/TopHitsAggregationTest.php +++ b/Aggregation/TopHitsAggregationTest.php @@ -15,7 +15,7 @@ use ONGR\ElasticsearchBundle\DSL\Aggregation\TopHitsAggregation; use ONGR\ElasticsearchBundle\DSL\Sort\Sorts; /** - * Unit tests for top hits aggregation + * Unit tests for top hits aggregation. */ class TopHitsAggregationTest extends \PHPUnit_Framework_TestCase { @@ -32,9 +32,7 @@ class TopHitsAggregationTest extends \PHPUnit_Framework_TestCase $expectedAgg->from = 1; $expectedAgg->sort = $sorts->toArray(); $expected = [ - 'agg_test' => [ - 'top_hits' => $expectedAgg, - ] + 'agg_test' => ['top_hits' => $expectedAgg] ]; $this->assertEquals($expected, $aggregation->toArray()); diff --git a/Suggester/CompletionTest.php b/Suggester/CompletionTest.php index eaaa21d..cbe6e4d 100644 --- a/Suggester/CompletionTest.php +++ b/Suggester/CompletionTest.php @@ -26,14 +26,15 @@ class CompletionTest extends \PHPUnit_Framework_TestCase $completion0 = new Completion('my-field', 'lorem ipsum'); $expected0 = [ 'my-field-completion' => [ - 'text' => 'lorem ipsum', - 'completion' => [ - 'field' => 'my-field', - ], + 'text' => 'lorem ipsum', + 'completion' => ['field' => 'my-field'], ], ]; - $out[] = [$expected0, $completion0]; + $out[] = [ + $expected0, + $completion0, + ]; // Case #1: using fuzzy. $completion1 = new Completion('my-other-field', 'super awesome cat', 'my-completion1'); @@ -48,7 +49,10 @@ class CompletionTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$expected1, $completion1]; + $out[] = [ + $expected1, + $completion1, + ]; // Case #2: providing all data. $completion2 = new Completion('body', 'even more super awesome cat', 'my-completion2'); @@ -74,7 +78,10 @@ class CompletionTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$expected2, $completion2]; + $out[] = [ + $expected2, + $completion2, + ]; return $out; } diff --git a/Suggester/PhraseTest.php b/Suggester/PhraseTest.php index 7dbf1fa..eac16ae 100644 --- a/Suggester/PhraseTest.php +++ b/Suggester/PhraseTest.php @@ -27,13 +27,14 @@ class PhraseTest extends \PHPUnit_Framework_TestCase $expected0 = [ 'body-phrase' => [ 'text' => 'lorem ipsum', - 'phrase' => [ - 'field' => 'body', - ], + 'phrase' => ['field' => 'body'], ], ]; - $out[] = [$expected0, $phrase0]; + $out[] = [ + $expected0, + $phrase0, + ]; // Case #1: using all fields. $phrase1 = new Phrase('description', 'awesome cat'); @@ -64,7 +65,10 @@ class PhraseTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$expected1, $phrase1]; + $out[] = [ + $expected1, + $phrase1, + ]; return $out; } diff --git a/Suggester/TermTest.php b/Suggester/TermTest.php index dd7a503..4851cde 100644 --- a/Suggester/TermTest.php +++ b/Suggester/TermTest.php @@ -27,12 +27,13 @@ class TermTest extends \PHPUnit_Framework_TestCase $expected0 = [ 'body-term' => [ 'text' => 'lorem ipsum', - 'term' => [ - 'field' => 'body', - ], + 'term' => ['field' => 'body'], ], ]; - $out[] = [$expected0, $term0]; + $out[] = [ + $expected0, + $term0, + ]; // Case #1: full suggester. $term1 = new Term('body', 'lorem ipsum'); @@ -55,7 +56,10 @@ class TermTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [$expected1, $term1]; + $out[] = [ + $expected1, + $term1, + ]; return $out; } -- GitLab