From 55feba9b5235e9c6e4c638dc8e2a2a547e5a6b3f Mon Sep 17 00:00:00 2001 From: Oleg Zhulnev Date: Sun, 21 Jul 2024 22:17:43 +0300 Subject: [PATCH] Upgrade PHPUnit from 9.5 to 10.5 --- .php-cs-fixer.dist.php | 2 +- composer.json | 3 +- phpunit.xml.dist | 37 +++-- ... => AbstractSimpleAggregationTestCase.php} | 2 +- ...ixTest.php => AdjacencyMatrixTestCase.php} | 15 +- ...st.php => AggregationMetadataTestCase.php} | 11 +- ...Test.php => AutoDateHistogramTestCase.php} | 7 +- ...vgBucketTest.php => AvgBucketTestCase.php} | 11 +- .../{AvgTest.php => AvgTestCase.php} | 11 +- ...onTest.php => BaseAggregationTestCase.php} | 2 +- ...criptTest.php => BucketScriptTestCase.php} | 11 +- ...torTest.php => BucketSelectorTestCase.php} | 11 +- ...nalityTest.php => CardinalityTestCase.php} | 30 ++-- ...{ChildrenTest.php => ChildrenTestCase.php} | 11 +- ...ompositeTest.php => CompositeTestCase.php} | 31 ++-- ...eSumTest.php => CumulativeSumTestCase.php} | 11 +- ...gramTest.php => DateHistogramTestCase.php} | 35 ++--- ...ateRangeTest.php => DateRangeTestCase.php} | 27 +--- ...ivativeTest.php => DerivativeTestCase.php} | 11 +- ...est.php => DiversifiedSamplerTestCase.php} | 17 +-- ...st.php => ExtendedStatsBucketTestCase.php} | 11 +- ...tatsTest.php => ExtendedStatsTestCase.php} | 11 +- .../{FilterTest.php => FilterTestCase.php} | 23 +-- .../{FiltersTest.php => FiltersTestCase.php} | 35 ++--- ...eoBoundsTest.php => GeoBoundsTestCase.php} | 7 +- ...ntroidTest.php => GeoCentroidTestCase.php} | 7 +- ...stanceTest.php => GeoDistanceTestCase.php} | 11 +- ...shGridTest.php => GeohashGridTestCase.php} | 15 +- ...php => GeotileGridAggregationTestCase.php} | 7 +- ...Test.php => GlobalAggregationTestCase.php} | 7 +- ...istogramTest.php => HistogramTestCase.php} | 15 +- .../{IpRangeTest.php => IpRangeTestCase.php} | 11 +- .../{MaxTest.php => MaxTestCase.php} | 15 +- .../{MinTest.php => MinTestCase.php} | 11 +- .../{MissingTest.php => MissingTestCase.php} | 7 +- .../{NestedTest.php => NestedTestCase.php} | 7 +- ...t.php => NormalizeAggregationTestCase.php} | 11 +- ...Test.php => ParentAggregationTestCase.php} | 11 +- ...Test.php => PercentilesBucketTestCase.php} | 11 +- ...ntilesTest.php => PercentilesTestCase.php} | 43 ++---- .../{RangeTest.php => RangeTestCase.php} | 15 +- ...stedTest.php => ReverseNestedTestCase.php} | 15 +- .../{SamplerTest.php => SamplerTestCase.php} | 17 +-- .../{ScriptTest.php => ScriptTestCase.php} | 15 +- ...ricTest.php => ScriptedMetricTestCase.php} | 7 +- ...ialDiffTest.php => SerialDiffTestCase.php} | 11 +- ...sTest.php => SignificantTermsTestCase.php} | 15 +- ...BucketTest.php => StatsBucketTestCase.php} | 11 +- .../{StatsTest.php => StatsTestCase.php} | 11 +- ...umBucketTest.php => SumBucketTestCase.php} | 11 +- .../{SumTest.php => SumTestCase.php} | 11 +- .../{TermsTest.php => TermsTestCase.php} | 53 ++----- .../{TopHitsTest.php => TopHitsTestCase.php} | 89 ++++------- ...ueCountTest.php => ValueCountTestCase.php} | 7 +- ...tedAvgTest.php => WeightedAvgTestCase.php} | 23 +-- tests/Base.php | 24 +-- tests/Bulk/Action/AbstractDocumentTest.php | 9 +- tests/Bulk/Action/UpdateDocumentTest.php | 9 +- tests/Bulk/ActionTest.php | 8 +- tests/Bulk/ResponseSetTest.php | 39 ++--- tests/BulkTest.php | 79 +++------- tests/ClientConfigurationTest.php | 4 +- tests/ClientFunctionalTest.php | 20 +-- tests/ClientTest.php | 4 +- tests/Cluster/Health/IndexTest.php | 41 ++--- tests/Cluster/Health/ShardTest.php | 29 +--- tests/Cluster/HealthTest.php | 67 +++------ tests/Cluster/SettingsTest.php | 5 +- tests/ClusterTest.php | 4 +- tests/Collapse/CollapseTest.php | 41 ++--- tests/DeprecatedClassBase.php | 25 ---- tests/DocumentTest.php | 53 ++----- tests/ExampleTest.php | 9 +- ...Test.php => AbstractExceptionTestCase.php} | 2 +- .../Bulk/Response/ActionExceptionTest.php | 4 +- .../Exception/Bulk/ResponseExceptionTest.php | 4 +- tests/Exception/BulkExceptionTest.php | 2 +- tests/Exception/ClientExceptionTest.php | 2 +- tests/Exception/InvalidExceptionTest.php | 2 +- tests/Exception/NotFoundExceptionTest.php | 2 +- .../Exception/NotImplementedExceptionTest.php | 2 +- tests/Exception/QueryBuilderExceptionTest.php | 2 +- tests/Exception/RuntimeExceptionTest.php | 2 +- tests/Index/RecoveryTest.php | 5 +- tests/Index/SettingsTest.php | 77 +++------- tests/Index/StatsTest.php | 5 +- tests/IndexTemplateTest.php | 17 +-- tests/IndexTest.php | 141 +++++------------- tests/MappingTest.php | 33 ++-- tests/Multi/MultiBuilderTest.php | 16 +- tests/Multi/SearchTest.php | 37 ++--- tests/Node/InfoTest.php | 21 +-- tests/NodeTest.php | 17 +-- tests/ParamTest.php | 29 +--- tests/PipelineTest.php | 17 +-- tests/PointInTimeTest.php | 5 +- tests/Processor/AppendProcessorTest.php | 13 +- tests/Processor/AttachmentProcessorTest.php | 25 +--- tests/Processor/BytesProcessorTest.php | 13 +- tests/Processor/ConvertProcessorTest.php | 13 +- .../Processor/DateIndexNameProcessorTest.php | 9 +- tests/Processor/DateProcessorTest.php | 13 +- tests/Processor/DotExpanderProcessorTest.php | 13 +- tests/Processor/FailProcessorTest.php | 13 +- tests/Processor/ForeachProcessorTest.php | 17 +-- tests/Processor/JoinProcessorTest.php | 13 +- tests/Processor/JsonProcessorTest.php | 13 +- tests/Processor/KvProcessorTest.php | 13 +- tests/Processor/LowercaseProcessorTest.php | 13 +- tests/Processor/RemoveProcessorTest.php | 17 +-- tests/Processor/RenameProcessorTest.php | 13 +- tests/Processor/SetProcessorTest.php | 13 +- tests/Processor/SortProcessorTest.php | 13 +- tests/Processor/SplitProcessorTest.php | 13 +- tests/Processor/TrimProcessorTest.php | 13 +- tests/Processor/UppercaseProcessorTest.php | 13 +- tests/Query/BoolQueryTest.php | 16 +- tests/Query/BoostingTest.php | 9 +- tests/Query/CombinedFieldsQueryTest.php | 17 +-- tests/Query/ConstantScoreTest.php | 13 +- tests/Query/DisMaxTest.php | 13 +- tests/Query/DistanceFeatureTest.php | 13 +- tests/Query/EscapeStringTest.php | 5 +- tests/Query/ExistsTest.php | 9 +- tests/Query/FunctionScoreTest.php | 69 +++------ tests/Query/FuzzyTest.php | 25 +--- tests/Query/GeoBoundingBoxTest.php | 13 +- tests/Query/GeoDistanceTest.php | 17 +-- tests/Query/GeoPolygonTest.php | 5 +- tests/Query/GeoShapePreIndexedTest.php | 13 +- tests/Query/GeoShapeProvidedTest.php | 17 +-- tests/Query/HasChildTest.php | 13 +- tests/Query/HasParentTest.php | 13 +- tests/Query/HighlightTest.php | 5 +- tests/Query/IdsTest.php | 33 ++-- tests/Query/InnerHitsTest.php | 81 +++------- tests/Query/LimitTest.php | 9 +- tests/Query/MatchAllTest.php | 9 +- tests/Query/MatchNoneTest.php | 9 +- tests/Query/MatchPhrasePrefixTest.php | 9 +- tests/Query/MatchPhraseTest.php | 9 +- tests/Query/MatchQueryTest.php | 27 +--- tests/Query/MoreLikeThisTest.php | 65 +++----- tests/Query/MultiMatchTest.php | 37 ++--- tests/Query/NestedTest.php | 5 +- tests/Query/ParentIdTest.php | 13 +- tests/Query/PercolateTest.php | 37 ++--- tests/Query/PostFilterTest.php | 9 +- tests/Query/PrefixTest.php | 5 +- tests/Query/QueryStringTest.php | 67 +++------ tests/Query/RangeTest.php | 13 +- tests/Query/RegexpTest.php | 5 +- tests/Query/RescoreTest.php | 21 +-- tests/Query/ScriptTest.php | 9 +- tests/Query/SimpleQueryStringTest.php | 17 +-- tests/Query/SimpleTest.php | 5 +- tests/Query/SpanContainingTest.php | 9 +- tests/Query/SpanFirstTest.php | 9 +- tests/Query/SpanMultiTest.php | 9 +- tests/Query/SpanNearTest.php | 13 +- tests/Query/SpanNotTest.php | 9 +- tests/Query/SpanOrTest.php | 13 +- tests/Query/SpanTermTest.php | 9 +- tests/Query/SpanWithinTest.php | 9 +- tests/Query/TermTest.php | 9 +- tests/Query/TermsSetTest.php | 21 +-- tests/Query/TermsTest.php | 41 ++--- tests/Query/WildcardTest.php | 23 +-- ...actDSLTest.php => AbstractDSLTestCase.php} | 2 +- ...gationTest.php => AggregationTestCase.php} | 11 +- ...{CollapseTest.php => CollapseTestCase.php} | 11 +- .../DSL/{QueryTest.php => QueryTestCase.php} | 18 +-- .../{SuggestTest.php => SuggestTestCase.php} | 11 +- tests/QueryBuilder/VersionTest.php | 4 +- tests/QueryBuilderTest.php | 9 +- tests/QueryTest.php | 127 +++++----------- tests/ReindexTest.php | 41 ++--- tests/ResponseFunctionalTest.php | 4 +- tests/ResponseTest.php | 4 +- tests/ResultSet/BuilderTest.php | 4 +- tests/ResultSet/ChainProcessorTest.php | 4 +- tests/ResultSet/ProcessingBuilderTest.php | 4 +- tests/ResultSetTest.php | 21 +-- tests/ResultTest.php | 25 +--- tests/Script/ScriptFieldsTest.php | 17 +-- tests/Script/ScriptIdTest.php | 35 ++--- tests/Script/ScriptTest.php | 35 ++--- tests/ScrollTest.php | 13 +- tests/SearchTest.php | 92 +++--------- tests/SnapshotTest.php | 12 +- tests/StatusTest.php | 17 +-- tests/Suggest/CompletionTest.php | 25 +--- tests/Suggest/PhraseTest.php | 12 +- tests/Suggest/TermTest.php | 17 +-- tests/SuggestTest.php | 10 +- tests/TaskTest.php | 25 +--- tests/UtilTest.php | 66 +++----- tests/WithConsecutive.php | 76 ++++++++++ 198 files changed, 1203 insertions(+), 2575 deletions(-) rename tests/Aggregation/{AbstractSimpleAggregationTest.php => AbstractSimpleAggregationTestCase.php} (91%) rename tests/Aggregation/{AdjacencyMatrixTest.php => AdjacencyMatrixTestCase.php} (95%) rename tests/Aggregation/{AggregationMetadataTest.php => AggregationMetadataTestCase.php} (89%) rename tests/Aggregation/{AutoDateHistogramTest.php => AutoDateHistogramTestCase.php} (93%) rename tests/Aggregation/{AvgBucketTest.php => AvgBucketTestCase.php} (93%) rename tests/Aggregation/{AvgTest.php => AvgTestCase.php} (91%) rename tests/Aggregation/{BaseAggregationTest.php => BaseAggregationTestCase.php} (65%) rename tests/Aggregation/{BucketScriptTest.php => BucketScriptTestCase.php} (94%) rename tests/Aggregation/{BucketSelectorTest.php => BucketSelectorTestCase.php} (95%) rename tests/Aggregation/{CardinalityTest.php => CardinalityTestCase.php} (84%) rename tests/Aggregation/{ChildrenTest.php => ChildrenTestCase.php} (96%) rename tests/Aggregation/{CompositeTest.php => CompositeTestCase.php} (94%) rename tests/Aggregation/{CumulativeSumTest.php => CumulativeSumTestCase.php} (94%) rename tests/Aggregation/{DateHistogramTest.php => DateHistogramTestCase.php} (93%) rename tests/Aggregation/{DateRangeTest.php => DateRangeTestCase.php} (94%) rename tests/Aggregation/{DerivativeTest.php => DerivativeTestCase.php} (94%) rename tests/Aggregation/{DiversifiedSamplerTest.php => DiversifiedSamplerTestCase.php} (91%) rename tests/Aggregation/{ExtendedStatsBucketTest.php => ExtendedStatsBucketTestCase.php} (94%) rename tests/Aggregation/{ExtendedStatsTest.php => ExtendedStatsTestCase.php} (92%) rename tests/Aggregation/{FilterTest.php => FilterTestCase.php} (91%) rename tests/Aggregation/{FiltersTest.php => FiltersTestCase.php} (95%) rename tests/Aggregation/{GeoBoundsTest.php => GeoBoundsTestCase.php} (92%) rename tests/Aggregation/{GeoCentroidTest.php => GeoCentroidTestCase.php} (90%) rename tests/Aggregation/{GeoDistanceTest.php => GeoDistanceTestCase.php} (92%) rename tests/Aggregation/{GeohashGridTest.php => GeohashGridTestCase.php} (91%) rename tests/Aggregation/{GeotileGridAggregationTest.php => GeotileGridAggregationTestCase.php} (90%) rename tests/Aggregation/{GlobalAggregationTest.php => GlobalAggregationTestCase.php} (86%) rename tests/Aggregation/{HistogramTest.php => HistogramTestCase.php} (93%) rename tests/Aggregation/{IpRangeTest.php => IpRangeTestCase.php} (93%) rename tests/Aggregation/{MaxTest.php => MaxTestCase.php} (94%) rename tests/Aggregation/{MinTest.php => MinTestCase.php} (91%) rename tests/Aggregation/{MissingTest.php => MissingTestCase.php} (90%) rename tests/Aggregation/{NestedTest.php => NestedTestCase.php} (92%) rename tests/Aggregation/{NormalizeAggregationTest.php => NormalizeAggregationTestCase.php} (95%) rename tests/Aggregation/{ParentAggregationTest.php => ParentAggregationTestCase.php} (96%) rename tests/Aggregation/{PercentilesBucketTest.php => PercentilesBucketTestCase.php} (94%) rename tests/Aggregation/{PercentilesTest.php => PercentilesTestCase.php} (93%) rename tests/Aggregation/{RangeTest.php => RangeTestCase.php} (93%) rename tests/Aggregation/{ReverseNestedTest.php => ReverseNestedTestCase.php} (95%) rename tests/Aggregation/{SamplerTest.php => SamplerTestCase.php} (88%) rename tests/Aggregation/{ScriptTest.php => ScriptTestCase.php} (92%) rename tests/Aggregation/{ScriptedMetricTest.php => ScriptedMetricTestCase.php} (91%) rename tests/Aggregation/{SerialDiffTest.php => SerialDiffTestCase.php} (94%) rename tests/Aggregation/{SignificantTermsTest.php => SignificantTermsTestCase.php} (94%) rename tests/Aggregation/{StatsBucketTest.php => StatsBucketTestCase.php} (93%) rename tests/Aggregation/{StatsTest.php => StatsTestCase.php} (92%) rename tests/Aggregation/{SumBucketTest.php => SumBucketTestCase.php} (93%) rename tests/Aggregation/{SumTest.php => SumTestCase.php} (90%) rename tests/Aggregation/{TermsTest.php => TermsTestCase.php} (90%) rename tests/Aggregation/{TopHitsTest.php => TopHitsTestCase.php} (92%) rename tests/Aggregation/{ValueCountTest.php => ValueCountTestCase.php} (88%) rename tests/Aggregation/{WeightedAvgTest.php => WeightedAvgTestCase.php} (92%) delete mode 100644 tests/DeprecatedClassBase.php rename tests/Exception/{AbstractExceptionTest.php => AbstractExceptionTestCase.php} (94%) rename tests/QueryBuilder/DSL/{AbstractDSLTest.php => AbstractDSLTestCase.php} (98%) rename tests/QueryBuilder/DSL/{AggregationTest.php => AggregationTestCase.php} (97%) rename tests/QueryBuilder/DSL/{CollapseTest.php => CollapseTestCase.php} (81%) rename tests/QueryBuilder/DSL/{QueryTest.php => QueryTestCase.php} (94%) rename tests/QueryBuilder/DSL/{SuggestTest.php => SuggestTestCase.php} (85%) create mode 100644 tests/WithConsecutive.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index a93e33514..9b9363636 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -14,7 +14,7 @@ '@PHP80Migration' => true, '@PHP80Migration:risky' => true, '@PhpCsFixer' => true, - '@PHPUnit75Migration:risky' => true, + '@PHPUnit100Migration:risky' => true, '@PSR2' => true, '@Symfony' => true, 'is_null' => true, diff --git a/composer.json b/composer.json index 8e4975636..e051519c0 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,7 @@ "guzzlehttp/guzzle": "^7.2", "phpstan/phpstan": "^1.5", "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^9.5", - "symfony/phpunit-bridge": "^6.0" + "phpunit/phpunit": "^10.5" }, "conflict": { "guzzlehttp/psr7": "<2.0.0" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 002bdca58..c19b4df13 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,26 @@ - - - - src/ - - - src/Query/Match.php - - - - - - - - tests/ - - + + + src + + + + + + tests/ + + + diff --git a/tests/Aggregation/AbstractSimpleAggregationTest.php b/tests/Aggregation/AbstractSimpleAggregationTestCase.php similarity index 91% rename from tests/Aggregation/AbstractSimpleAggregationTest.php rename to tests/Aggregation/AbstractSimpleAggregationTestCase.php index 2e2740917..bd93efdc2 100644 --- a/tests/Aggregation/AbstractSimpleAggregationTest.php +++ b/tests/Aggregation/AbstractSimpleAggregationTestCase.php @@ -11,7 +11,7 @@ /** * @internal */ -class AbstractSimpleAggregationTest extends BaseAggregationTest +class AbstractSimpleAggregationTestCase extends BaseAggregationTestCase { /** * @var AbstractSimpleAggregation&MockObject diff --git a/tests/Aggregation/AdjacencyMatrixTest.php b/tests/Aggregation/AdjacencyMatrixTestCase.php similarity index 95% rename from tests/Aggregation/AdjacencyMatrixTest.php rename to tests/Aggregation/AdjacencyMatrixTestCase.php index af9f28960..a5da28959 100644 --- a/tests/Aggregation/AdjacencyMatrixTest.php +++ b/tests/Aggregation/AdjacencyMatrixTestCase.php @@ -11,15 +11,14 @@ use Elastica\Query; use Elastica\Query\Term; use Elastica\Query\Terms; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class AdjacencyMatrixTest extends BaseAggregationTest +class AdjacencyMatrixTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ @@ -58,9 +57,7 @@ public function testToArray(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testToArraySeparator(): void { $expected = [ @@ -83,9 +80,7 @@ public function testToArraySeparator(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testAdjacencyMatrixAggregation(): void { $agg = new AdjacencyMatrix('interactions'); diff --git a/tests/Aggregation/AggregationMetadataTest.php b/tests/Aggregation/AggregationMetadataTestCase.php similarity index 89% rename from tests/Aggregation/AggregationMetadataTest.php rename to tests/Aggregation/AggregationMetadataTestCase.php index 771c1a34e..9c01a8285 100644 --- a/tests/Aggregation/AggregationMetadataTest.php +++ b/tests/Aggregation/AggregationMetadataTestCase.php @@ -7,15 +7,14 @@ use Elastica\Aggregation\Cardinality; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class AggregationMetadataTest extends BaseAggregationTest +class AggregationMetadataTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testAggregationSimpleMetadata(): void { $aggName = 'mock'; @@ -32,9 +31,7 @@ public function testAggregationSimpleMetadata(): void $this->assertEquals($metadata, $results['meta']); } - /** - * @group functional - */ + #[Group('functional')] public function testAggregationComplexMetadata(): void { $aggName = 'mock'; diff --git a/tests/Aggregation/AutoDateHistogramTest.php b/tests/Aggregation/AutoDateHistogramTestCase.php similarity index 93% rename from tests/Aggregation/AutoDateHistogramTest.php rename to tests/Aggregation/AutoDateHistogramTestCase.php index 7e4927b04..b4cefeb69 100644 --- a/tests/Aggregation/AutoDateHistogramTest.php +++ b/tests/Aggregation/AutoDateHistogramTestCase.php @@ -6,15 +6,14 @@ use Elastica\Aggregation\AutoDateHistogram; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class AutoDateHistogramTest extends BaseAggregationTest +class AutoDateHistogramTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testAvgBucketAggregation(): void { $aggregationKey = 'aggs'; diff --git a/tests/Aggregation/AvgBucketTest.php b/tests/Aggregation/AvgBucketTestCase.php similarity index 93% rename from tests/Aggregation/AvgBucketTest.php rename to tests/Aggregation/AvgBucketTestCase.php index 48f8d34f3..6e04674c3 100644 --- a/tests/Aggregation/AvgBucketTest.php +++ b/tests/Aggregation/AvgBucketTestCase.php @@ -11,15 +11,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class AvgBucketTest extends BaseAggregationTest +class AvgBucketTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testAvgBucketAggregation(): void { $query = Query::create([]) @@ -44,9 +43,7 @@ public function testAvgBucketAggregation(): void $this->assertEquals(161.5, $results['avg_likes_by_page']['value']); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructThroughSetters(): void { $aggregation = (new AvgBucket('avg_bucket', 'pages>avg_likes_by_page')) diff --git a/tests/Aggregation/AvgTest.php b/tests/Aggregation/AvgTestCase.php similarity index 91% rename from tests/Aggregation/AvgTest.php rename to tests/Aggregation/AvgTestCase.php index 73aae6fb4..6e0d1e40e 100644 --- a/tests/Aggregation/AvgTest.php +++ b/tests/Aggregation/AvgTestCase.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class AvgTest extends BaseAggregationTest +class AvgTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testAvgAggregation(): void { $agg = new Avg('avg'); @@ -32,9 +31,7 @@ public function testAvgAggregation(): void $this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results['avg']['value']); } - /** - * @group functional - */ + #[Group('functional')] public function testAvgAggregationWithMissingValue(): void { $agg = new Avg('avg'); diff --git a/tests/Aggregation/BaseAggregationTest.php b/tests/Aggregation/BaseAggregationTestCase.php similarity index 65% rename from tests/Aggregation/BaseAggregationTest.php rename to tests/Aggregation/BaseAggregationTestCase.php index 3aa73d3a6..544cb8b7d 100644 --- a/tests/Aggregation/BaseAggregationTest.php +++ b/tests/Aggregation/BaseAggregationTestCase.php @@ -6,6 +6,6 @@ use Elastica\Test\Base; -abstract class BaseAggregationTest extends Base +abstract class BaseAggregationTestCase extends Base { } diff --git a/tests/Aggregation/BucketScriptTest.php b/tests/Aggregation/BucketScriptTestCase.php similarity index 94% rename from tests/Aggregation/BucketScriptTest.php rename to tests/Aggregation/BucketScriptTestCase.php index 58dad1130..af9d9af7e 100644 --- a/tests/Aggregation/BucketScriptTest.php +++ b/tests/Aggregation/BucketScriptTestCase.php @@ -11,15 +11,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class BucketScriptTest extends BaseAggregationTest +class BucketScriptTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testBucketScriptAggregation(): void { $bucketScriptAggregation = new BucketScript( @@ -48,9 +47,7 @@ public function testBucketScriptAggregation(): void $this->assertEquals(3.1, $results['buckets'][2]['result']['value']); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructThroughSetters(): void { $serialDiffAgg = new BucketScript('bucket_scripted', [ diff --git a/tests/Aggregation/BucketSelectorTest.php b/tests/Aggregation/BucketSelectorTestCase.php similarity index 95% rename from tests/Aggregation/BucketSelectorTest.php rename to tests/Aggregation/BucketSelectorTestCase.php index 50d822402..d5ec3676f 100644 --- a/tests/Aggregation/BucketSelectorTest.php +++ b/tests/Aggregation/BucketSelectorTestCase.php @@ -10,15 +10,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class BucketSelectorTest extends BaseAggregationTest +class BucketSelectorTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ @@ -44,9 +43,7 @@ public function testToArray(): void $this->assertEquals($expected, $maxAgg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testMaxAggregation(): void { $index = $this->_getIndexForTest(); diff --git a/tests/Aggregation/CardinalityTest.php b/tests/Aggregation/CardinalityTestCase.php similarity index 84% rename from tests/Aggregation/CardinalityTest.php rename to tests/Aggregation/CardinalityTestCase.php index 997467be4..a4f3912cb 100644 --- a/tests/Aggregation/CardinalityTest.php +++ b/tests/Aggregation/CardinalityTestCase.php @@ -9,15 +9,15 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class CardinalityTest extends BaseAggregationTest +class CardinalityTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testCardinalityAggregation(): void { $agg = new Cardinality('cardinality'); @@ -30,9 +30,7 @@ public function testCardinalityAggregation(): void $this->assertEquals(3, $results['value']); } - /** - * @group functional - */ + #[Group('functional')] public function testCardinalityAggregationWithMissing(): void { $agg = new Cardinality('cardinality'); @@ -46,7 +44,7 @@ public function testCardinalityAggregationWithMissing(): void $this->assertEquals(4, $results['value']); } - public function validPrecisionThresholdProvider(): array + public static function validPrecisionThresholdProvider(): array { return [ 'negative-int' => [-140], @@ -56,11 +54,8 @@ public function validPrecisionThresholdProvider(): array ]; } - /** - * @dataProvider validPrecisionThresholdProvider - * - * @group unit - */ + #[Group('unit')] + #[DataProvider('validPrecisionThresholdProvider')] public function testPrecisionThreshold(int $threshold): void { $agg = new Cardinality('threshold'); @@ -70,11 +65,8 @@ public function testPrecisionThreshold(int $threshold): void $this->assertIsInt($agg->getParam('precision_threshold')); } - /** - * @dataProvider validRehashProvider - * - * @group unit - */ + #[Group('unit')] + #[DataProvider('validRehashProvider')] public function testRehash(bool $rehash): void { $agg = new Cardinality('rehash'); @@ -84,7 +76,7 @@ public function testRehash(bool $rehash): void $this->assertIsBool($agg->getParam('rehash')); } - public function validRehashProvider(): array + public static function validRehashProvider(): array { return [ 'true' => [true], diff --git a/tests/Aggregation/ChildrenTest.php b/tests/Aggregation/ChildrenTestCase.php similarity index 96% rename from tests/Aggregation/ChildrenTest.php rename to tests/Aggregation/ChildrenTestCase.php index 4687e0db7..6d6073087 100644 --- a/tests/Aggregation/ChildrenTest.php +++ b/tests/Aggregation/ChildrenTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class ChildrenTest extends BaseAggregationTest +class ChildrenTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testChildrenAggregation(): void { $agg = new Children('answer'); @@ -43,9 +42,7 @@ public function testChildrenAggregation(): void $this->assertArrayHasKey('name', $childrenAggregations); } - /** - * @group functional - */ + #[Group('functional')] public function testChildrenAggregationCount(): void { $agg = new Children('answer'); diff --git a/tests/Aggregation/CompositeTest.php b/tests/Aggregation/CompositeTestCase.php similarity index 94% rename from tests/Aggregation/CompositeTest.php rename to tests/Aggregation/CompositeTestCase.php index de750576d..7131af4d3 100644 --- a/tests/Aggregation/CompositeTest.php +++ b/tests/Aggregation/CompositeTestCase.php @@ -9,15 +9,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class CompositeTest extends BaseAggregationTest +class CompositeTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testSize(): void { $composite = new Composite('products'); @@ -32,9 +31,7 @@ public function testSize(): void $this->assertEquals($expected, $composite->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddSource(): void { $expected = [ @@ -56,9 +53,7 @@ public function testAddSource(): void $this->assertEquals($expected, $composite->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddAfter(): void { $checkpoint = ['checkpointproduct' => 'checkpoint']; @@ -73,9 +68,7 @@ public function testAddAfter(): void $this->assertEquals($expected, $composite->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testCompositeNoAfterAggregation(): void { $composite = new Composite('products'); @@ -114,9 +107,7 @@ public function testCompositeNoAfterAggregation(): void $this->assertEquals($expected, $results); } - /** - * @group functional - */ + #[Group('functional')] public function testCompositeWithSizeAggregation(): void { $composite = new Composite('products'); @@ -150,9 +141,7 @@ public function testCompositeWithSizeAggregation(): void $this->assertEquals($expected, $results); } - /** - * @group functional - */ + #[Group('functional')] public function testCompositeWithAfterAggregation(): void { $composite = new Composite('products'); @@ -180,9 +169,7 @@ public function testCompositeWithAfterAggregation(): void $this->assertEquals($expected, $results); } - /** - * @group functional - */ + #[Group('functional')] public function testCompositeWithNullAfter(): void { $composite = new Composite('products'); diff --git a/tests/Aggregation/CumulativeSumTest.php b/tests/Aggregation/CumulativeSumTestCase.php similarity index 94% rename from tests/Aggregation/CumulativeSumTest.php rename to tests/Aggregation/CumulativeSumTestCase.php index 61892cb09..d308dc5f0 100644 --- a/tests/Aggregation/CumulativeSumTest.php +++ b/tests/Aggregation/CumulativeSumTestCase.php @@ -10,15 +10,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class CumulativeSumTest extends BaseAggregationTest +class CumulativeSumTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testCumulativeSumAggregation(): void { $query = Query::create([]) @@ -44,9 +43,7 @@ public function testCumulativeSumAggregation(): void $this->assertEquals(58, $results['sales_per_month']['buckets'][2]['cumulative_sales']['value']); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructThroughSetters(): void { $aggregation = (new CumulativeSum('cumulative_sum', 'sales')) diff --git a/tests/Aggregation/DateHistogramTest.php b/tests/Aggregation/DateHistogramTestCase.php similarity index 93% rename from tests/Aggregation/DateHistogramTest.php rename to tests/Aggregation/DateHistogramTestCase.php index af93c6d23..61a1e1717 100644 --- a/tests/Aggregation/DateHistogramTest.php +++ b/tests/Aggregation/DateHistogramTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class DateHistogramTest extends BaseAggregationTest +class DateHistogramTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testConstructForCalendarInterval(): void { $agg = new DateHistogram('hist', 'created', '1h'); @@ -32,9 +31,7 @@ public function testConstructForCalendarInterval(): void $this->assertSame($expected, $agg->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructForFixedInterval(): void { $agg = new DateHistogram('hist', 'created', '2h'); @@ -49,9 +46,7 @@ public function testConstructForFixedInterval(): void $this->assertSame($expected, $agg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testDateHistogramAggregation(): void { $agg = new DateHistogram('hist', 'created', '1h'); @@ -75,9 +70,7 @@ public function testDateHistogramAggregation(): void $this->assertEquals(1, $nonDocCount); } - /** - * @group functional - */ + #[Group('functional')] public function testDateHistogramAggregationWithMissing(): void { $agg = new DateHistogram('hist', 'created', '1h'); @@ -102,9 +95,7 @@ public function testDateHistogramAggregationWithMissing(): void $this->assertEquals(1, $nonDocCount); } - /** - * @group functional - */ + #[Group('functional')] public function testDateHistogramKeyedAggregation(): void { $agg = new DateHistogram('hist', 'created', '1h'); @@ -123,9 +114,7 @@ public function testDateHistogramKeyedAggregation(): void $this->assertSame($expected, \array_keys($results['buckets'])); } - /** - * @group unit - */ + #[Group('unit')] public function testSetOffset(): void { $agg = (new DateHistogram('hist', 'created', '1h')) @@ -143,9 +132,7 @@ public function testSetOffset(): void $this->assertSame($expected, $agg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetOffsetWorks(): void { $agg = new DateHistogram('hist', 'created', '1m'); @@ -158,9 +145,7 @@ public function testSetOffsetWorks(): void $this->assertEquals('2014-01-29T00:19:40.000Z', $results['buckets'][0]['key_as_string']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetTimezone(): void { $agg = (new DateHistogram('hist', 'created', '1h')) diff --git a/tests/Aggregation/DateRangeTest.php b/tests/Aggregation/DateRangeTestCase.php similarity index 94% rename from tests/Aggregation/DateRangeTest.php rename to tests/Aggregation/DateRangeTestCase.php index c81c16ba2..5ece4f7c3 100644 --- a/tests/Aggregation/DateRangeTest.php +++ b/tests/Aggregation/DateRangeTestCase.php @@ -10,15 +10,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class DateRangeTest extends BaseAggregationTest +class DateRangeTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testSetTimezone(): void { $agg = (new DateRange('name')) @@ -36,9 +35,7 @@ public function testSetTimezone(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testDateRangeAggregation(): void { $agg = new DateRange('date'); @@ -58,9 +55,7 @@ public function testDateRangeAggregation(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testDateRangeAggregationWithMissing(): void { $agg = new DateRange('date'); @@ -81,9 +76,7 @@ public function testDateRangeAggregationWithMissing(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testDateRangeKeyedAggregation(): void { $agg = new DateRange('date'); @@ -102,9 +95,7 @@ public function testDateRangeKeyedAggregation(): void $this->assertSame($expected, \array_keys($results['buckets'])); } - /** - * @group functional - */ + #[Group('functional')] public function testDateRangeSetFormat(): void { $agg = new DateRange('date'); @@ -119,9 +110,7 @@ public function testDateRangeSetFormat(): void $this->assertEquals('1390958535000', $results['buckets'][0]['to_as_string']); } - /** - * @group functional - */ + #[Group('functional')] public function testDateRangeSetFormatAccordingToFormatTargetField(): void { $agg = new DateRange('date'); diff --git a/tests/Aggregation/DerivativeTest.php b/tests/Aggregation/DerivativeTestCase.php similarity index 94% rename from tests/Aggregation/DerivativeTest.php rename to tests/Aggregation/DerivativeTestCase.php index a0859a729..27328e603 100644 --- a/tests/Aggregation/DerivativeTest.php +++ b/tests/Aggregation/DerivativeTestCase.php @@ -10,15 +10,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class DerivativeTest extends BaseAggregationTest +class DerivativeTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ @@ -44,9 +43,7 @@ public function testToArray(): void $this->assertEquals($expected, $maxAgg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testMaxAggregation(): void { $index = $this->getIndexForTest(); diff --git a/tests/Aggregation/DiversifiedSamplerTest.php b/tests/Aggregation/DiversifiedSamplerTestCase.php similarity index 91% rename from tests/Aggregation/DiversifiedSamplerTest.php rename to tests/Aggregation/DiversifiedSamplerTestCase.php index 8dd4cf793..4a493cb8c 100755 --- a/tests/Aggregation/DiversifiedSamplerTest.php +++ b/tests/Aggregation/DiversifiedSamplerTestCase.php @@ -10,15 +10,15 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class DiversifiedSamplerTest extends BaseAggregationTest +class DiversifiedSamplerTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ @@ -52,11 +52,8 @@ public function testToArray(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @dataProvider shardSizeAndMaxDocPerValueProvider - * - * @group functional - */ + #[Group('functional')] + #[DataProvider('shardSizeAndMaxDocPerValueProvider')] public function testSamplerAggregation(int $shardSize, int $maxDocPerValue, int $docCount): void { $agg = new DiversifiedSampler('price_diversified_sampler'); @@ -77,7 +74,7 @@ public function testSamplerAggregation(int $shardSize, int $maxDocPerValue, int $this->assertEquals($docCount, $results['doc_count']); } - public function shardSizeAndMaxDocPerValueProvider(): array + public static function shardSizeAndMaxDocPerValueProvider(): array { return [ [1, 1, 2], diff --git a/tests/Aggregation/ExtendedStatsBucketTest.php b/tests/Aggregation/ExtendedStatsBucketTestCase.php similarity index 94% rename from tests/Aggregation/ExtendedStatsBucketTest.php rename to tests/Aggregation/ExtendedStatsBucketTestCase.php index 5f726b7b1..d10f8701a 100644 --- a/tests/Aggregation/ExtendedStatsBucketTest.php +++ b/tests/Aggregation/ExtendedStatsBucketTestCase.php @@ -11,15 +11,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class ExtendedStatsBucketTest extends BaseAggregationTest +class ExtendedStatsBucketTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testExtendedStatBucketAggregation(): void { $bucketScriptAggregation = new ExtendedStatsBucket('result', 'age_groups>max_weight'); @@ -53,9 +52,7 @@ public function testExtendedStatBucketAggregation(): void ], $results['std_deviation_bounds']); } - /** - * @group unit - */ + #[Group('unit')] public function testOverrideBucketsPathThroughSetters(): void { $serialDiffAgg = new ExtendedStatsBucket('bucket_part', 'foobar'); diff --git a/tests/Aggregation/ExtendedStatsTest.php b/tests/Aggregation/ExtendedStatsTestCase.php similarity index 92% rename from tests/Aggregation/ExtendedStatsTest.php rename to tests/Aggregation/ExtendedStatsTestCase.php index a189d93e5..980091cbf 100644 --- a/tests/Aggregation/ExtendedStatsTest.php +++ b/tests/Aggregation/ExtendedStatsTestCase.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class ExtendedStatsTest extends BaseAggregationTest +class ExtendedStatsTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testExtendedStatsAggregation(): void { $agg = new ExtendedStats('stats'); @@ -34,9 +33,7 @@ public function testExtendedStatsAggregation(): void $this->assertArrayHasKey('sum_of_squares', $results); } - /** - * @group functional - */ + #[Group('functional')] public function testExtendedStatsAggregationWithMissing(): void { $agg = new ExtendedStats('stats'); diff --git a/tests/Aggregation/FilterTest.php b/tests/Aggregation/FilterTestCase.php similarity index 91% rename from tests/Aggregation/FilterTest.php rename to tests/Aggregation/FilterTestCase.php index 2a692845e..1e0bf1d8d 100644 --- a/tests/Aggregation/FilterTest.php +++ b/tests/Aggregation/FilterTestCase.php @@ -11,15 +11,14 @@ use Elastica\Query; use Elastica\Query\Range; use Elastica\Query\Term; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class FilterTest extends BaseAggregationTest +class FilterTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ @@ -38,9 +37,7 @@ public function testToArray(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testFilterAggregation(): void { $agg = new Filter('filter'); @@ -58,9 +55,7 @@ public function testFilterAggregation(): void $this->assertEquals((5 + 8) / 2.0, $results); } - /** - * @group functional - */ + #[Group('functional')] public function testFilterNoSubAggregation(): void { $agg = new Avg('price'); @@ -75,9 +70,7 @@ public function testFilterNoSubAggregation(): void $this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results); } - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $agg = new Filter('foo', new Term(['color' => 'blue'])); @@ -93,9 +86,7 @@ public function testConstruct(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructWithoutFilter(): void { $agg = new Filter('foo'); diff --git a/tests/Aggregation/FiltersTest.php b/tests/Aggregation/FiltersTestCase.php similarity index 95% rename from tests/Aggregation/FiltersTest.php rename to tests/Aggregation/FiltersTestCase.php index c102194e8..5965c6d7f 100644 --- a/tests/Aggregation/FiltersTest.php +++ b/tests/Aggregation/FiltersTestCase.php @@ -11,15 +11,14 @@ use Elastica\Index; use Elastica\Query; use Elastica\Query\Term; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class FiltersTest extends BaseAggregationTest +class FiltersTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArrayUsingNamedFilters(): void { $expected = [ @@ -58,9 +57,7 @@ public function testToArrayUsingNamedFilters(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testMixNamedAndAnonymousFilters(): void { $this->expectException(InvalidException::class); @@ -71,9 +68,7 @@ public function testMixNamedAndAnonymousFilters(): void $agg->addFilter(new Term(['color' => '0'])); } - /** - * @group unit - */ + #[Group('unit')] public function testMixAnonymousAndNamedFilters(): void { $this->expectException(InvalidException::class); @@ -85,9 +80,7 @@ public function testMixAnonymousAndNamedFilters(): void $agg->addFilter(new Term(['color' => '0']), '0'); } - /** - * @group unit - */ + #[Group('unit')] public function testToArrayUsingAnonymousFilters(): void { $expected = [ @@ -118,9 +111,7 @@ public function testToArrayUsingAnonymousFilters(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testToArrayUsingOtherBucket(): void { $expected = [ @@ -145,9 +136,7 @@ public function testToArrayUsingOtherBucket(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testFilterAggregation(): void { $agg = new Filters('by_color'); @@ -173,9 +162,7 @@ public function testFilterAggregation(): void $this->assertEquals(1, $resultsForRed['avg_price']['value']); } - /** - * @group functional - */ + #[Group('functional')] public function testSetOtherBucket(): void { $agg = new Filters('by_color'); @@ -201,9 +188,7 @@ public function testSetOtherBucket(): void $this->assertEquals((5 + 8 + 3) / 3, $resultsForOtherBucket['avg_price']['value']); } - /** - * @group functional - */ + #[Group('functional')] public function testSetOtherBucketKey(): void { $agg = new Filters('by_color'); diff --git a/tests/Aggregation/GeoBoundsTest.php b/tests/Aggregation/GeoBoundsTestCase.php similarity index 92% rename from tests/Aggregation/GeoBoundsTest.php rename to tests/Aggregation/GeoBoundsTestCase.php index e67fabd83..559524502 100644 --- a/tests/Aggregation/GeoBoundsTest.php +++ b/tests/Aggregation/GeoBoundsTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class GeoBoundsTest extends BaseAggregationTest +class GeoBoundsTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testGeoBoundsAggregation(): void { $agg = new GeoBounds('viewport', 'location'); diff --git a/tests/Aggregation/GeoCentroidTest.php b/tests/Aggregation/GeoCentroidTestCase.php similarity index 90% rename from tests/Aggregation/GeoCentroidTest.php rename to tests/Aggregation/GeoCentroidTestCase.php index 075e925f3..178863e6c 100644 --- a/tests/Aggregation/GeoCentroidTest.php +++ b/tests/Aggregation/GeoCentroidTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class GeoCentroidTest extends BaseAggregationTest +class GeoCentroidTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testGeoCentroidGridAggregation(): void { $agg = new GeoCentroid('centroid', 'location'); diff --git a/tests/Aggregation/GeoDistanceTest.php b/tests/Aggregation/GeoDistanceTestCase.php similarity index 92% rename from tests/Aggregation/GeoDistanceTest.php rename to tests/Aggregation/GeoDistanceTestCase.php index d4246cc06..a86b7e807 100644 --- a/tests/Aggregation/GeoDistanceTest.php +++ b/tests/Aggregation/GeoDistanceTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class GeoDistanceTest extends BaseAggregationTest +class GeoDistanceTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testGeoDistanceAggregation(): void { $agg = new GeoDistance('geo', 'location', ['lat' => 32.804654, 'lon' => -117.242594]); @@ -31,9 +30,7 @@ public function testGeoDistanceAggregation(): void $this->assertEquals(2, $results['buckets'][0]['doc_count']); } - /** - * @group functional - */ + #[Group('functional')] public function testGeoDistanceKeyedAggregation(): void { $agg = new GeoDistance('geo', 'location', ['lat' => 32.804654, 'lon' => -117.242594]); diff --git a/tests/Aggregation/GeohashGridTest.php b/tests/Aggregation/GeohashGridTestCase.php similarity index 91% rename from tests/Aggregation/GeohashGridTest.php rename to tests/Aggregation/GeohashGridTestCase.php index 0d516a5c3..2be643c68 100644 --- a/tests/Aggregation/GeohashGridTest.php +++ b/tests/Aggregation/GeohashGridTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class GeohashGridTest extends BaseAggregationTest +class GeohashGridTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testGeohashGridAggregationWithNumericalPrecision(): void { $agg = new GeohashGrid('hash', 'location'); @@ -31,9 +30,7 @@ public function testGeohashGridAggregationWithNumericalPrecision(): void $this->assertEquals(1, $results['buckets'][1]['doc_count']); } - /** - * @group functional - */ + #[Group('functional')] public function testGeohashGridAggregationWithDistancePrecision(): void { $agg = new GeohashGrid('hash', 'location'); @@ -47,9 +44,7 @@ public function testGeohashGridAggregationWithDistancePrecision(): void $this->assertEquals(1, $results['buckets'][1]['doc_count']); } - /** - * @group unit - */ + #[Group('unit')] public function testGeohashGridAggregationWithNotAllowedPrecision(): void { $this->expectException(\TypeError::class); diff --git a/tests/Aggregation/GeotileGridAggregationTest.php b/tests/Aggregation/GeotileGridAggregationTestCase.php similarity index 90% rename from tests/Aggregation/GeotileGridAggregationTest.php rename to tests/Aggregation/GeotileGridAggregationTestCase.php index 58927b95e..a3b90c8e0 100644 --- a/tests/Aggregation/GeotileGridAggregationTest.php +++ b/tests/Aggregation/GeotileGridAggregationTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class GeotileGridAggregationTest extends BaseAggregationTest +class GeotileGridAggregationTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testGeotileGridAggregation(): void { $agg = new GeotileGridAggregation('tile', 'location'); diff --git a/tests/Aggregation/GlobalAggregationTest.php b/tests/Aggregation/GlobalAggregationTestCase.php similarity index 86% rename from tests/Aggregation/GlobalAggregationTest.php rename to tests/Aggregation/GlobalAggregationTestCase.php index 8e2c08ccf..422049326 100644 --- a/tests/Aggregation/GlobalAggregationTest.php +++ b/tests/Aggregation/GlobalAggregationTestCase.php @@ -6,15 +6,14 @@ use Elastica\Aggregation\Avg; use Elastica\Aggregation\GlobalAggregation; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class GlobalAggregationTest extends BaseAggregationTest +class GlobalAggregationTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ diff --git a/tests/Aggregation/HistogramTest.php b/tests/Aggregation/HistogramTestCase.php similarity index 93% rename from tests/Aggregation/HistogramTest.php rename to tests/Aggregation/HistogramTestCase.php index 3fb4d7f4a..42422e1b3 100644 --- a/tests/Aggregation/HistogramTest.php +++ b/tests/Aggregation/HistogramTestCase.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class HistogramTest extends BaseAggregationTest +class HistogramTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testHistogramAggregation(): void { $agg = new Histogram('hist', 'price', 10); @@ -32,9 +31,7 @@ public function testHistogramAggregation(): void $this->assertEquals(2, $buckets[3]['doc_count']); } - /** - * @group functional - */ + #[Group('functional')] public function testHistogramAggregationWithMissing(): void { $agg = new Histogram('hist', 'price', 10); @@ -51,9 +48,7 @@ public function testHistogramAggregationWithMissing(): void $this->assertEquals(3, $buckets[3]['doc_count']); } - /** - * @group functional - */ + #[Group('functional')] public function testHistogramKeyedAggregation(): void { $agg = new Histogram('hist', 'price', 10); diff --git a/tests/Aggregation/IpRangeTest.php b/tests/Aggregation/IpRangeTestCase.php similarity index 93% rename from tests/Aggregation/IpRangeTest.php rename to tests/Aggregation/IpRangeTestCase.php index 2d989267b..76b7260a1 100644 --- a/tests/Aggregation/IpRangeTest.php +++ b/tests/Aggregation/IpRangeTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class IpRangeTest extends BaseAggregationTest +class IpRangeTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testIpRangeAggregation(): void { $agg = new IpRange('ip', 'address'); @@ -42,9 +41,7 @@ public function testIpRangeAggregation(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testIpRangeKeyedAggregation(): void { $agg = new IpRange('ip', 'address'); diff --git a/tests/Aggregation/MaxTest.php b/tests/Aggregation/MaxTestCase.php similarity index 94% rename from tests/Aggregation/MaxTest.php rename to tests/Aggregation/MaxTestCase.php index b2482800f..624c418b2 100644 --- a/tests/Aggregation/MaxTest.php +++ b/tests/Aggregation/MaxTestCase.php @@ -9,17 +9,16 @@ use Elastica\Index; use Elastica\Query; use Elastica\Script\Script; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class MaxTest extends BaseAggregationTest +class MaxTestCase extends BaseAggregationTestCase { private const MAX_PRICE = 8; - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ @@ -47,9 +46,7 @@ public function testToArray(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testMaxAggregation(): void { $index = $this->_getIndexForTest(); @@ -72,9 +69,7 @@ public function testMaxAggregation(): void $this->assertEquals(self::MAX_PRICE * 1.2, $results['value']); } - /** - * @group functional - */ + #[Group('functional')] public function testMaxAggregationWithMissing(): void { // feature is buggy on version prior 7.5; diff --git a/tests/Aggregation/MinTest.php b/tests/Aggregation/MinTestCase.php similarity index 91% rename from tests/Aggregation/MinTest.php rename to tests/Aggregation/MinTestCase.php index dfcca34c8..2c3d4d962 100644 --- a/tests/Aggregation/MinTest.php +++ b/tests/Aggregation/MinTestCase.php @@ -8,17 +8,16 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class MinTest extends BaseAggregationTest +class MinTestCase extends BaseAggregationTestCase { private const MIN_PRICE = 1; - /** - * @group functional - */ + #[Group('functional')] public function testMinAggregation(): void { $agg = new Min('min_price'); @@ -31,9 +30,7 @@ public function testMinAggregation(): void $this->assertEquals(self::MIN_PRICE, $results['value']); } - /** - * @group functional - */ + #[Group('functional')] public function testMinAggregationWithMissing(): void { // feature is buggy on version prior 7.5; diff --git a/tests/Aggregation/MissingTest.php b/tests/Aggregation/MissingTestCase.php similarity index 90% rename from tests/Aggregation/MissingTest.php rename to tests/Aggregation/MissingTestCase.php index 53ecfb061..d6dc65c60 100644 --- a/tests/Aggregation/MissingTest.php +++ b/tests/Aggregation/MissingTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class MissingTest extends BaseAggregationTest +class MissingTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testMissingAggregation(): void { $agg = new Missing('missing', 'color'); diff --git a/tests/Aggregation/NestedTest.php b/tests/Aggregation/NestedTestCase.php similarity index 92% rename from tests/Aggregation/NestedTest.php rename to tests/Aggregation/NestedTestCase.php index a134d992c..2f8eddc7d 100644 --- a/tests/Aggregation/NestedTest.php +++ b/tests/Aggregation/NestedTestCase.php @@ -10,15 +10,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class NestedTest extends BaseAggregationTest +class NestedTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testNestedAggregation(): void { $agg = new Nested('resellers', 'resellers'); diff --git a/tests/Aggregation/NormalizeAggregationTest.php b/tests/Aggregation/NormalizeAggregationTestCase.php similarity index 95% rename from tests/Aggregation/NormalizeAggregationTest.php rename to tests/Aggregation/NormalizeAggregationTestCase.php index 3f873a20e..6a1e5edee 100644 --- a/tests/Aggregation/NormalizeAggregationTest.php +++ b/tests/Aggregation/NormalizeAggregationTestCase.php @@ -10,15 +10,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class NormalizeAggregationTest extends BaseAggregationTest +class NormalizeAggregationTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ @@ -58,9 +57,7 @@ public function testToArray(): void $this->assertEquals($expected, $dateHistogramAgg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testNormalizeAggregation(): void { $this->_checkVersion('7.9'); diff --git a/tests/Aggregation/ParentAggregationTest.php b/tests/Aggregation/ParentAggregationTestCase.php similarity index 96% rename from tests/Aggregation/ParentAggregationTest.php rename to tests/Aggregation/ParentAggregationTestCase.php index aff738376..bb5c3ac4f 100644 --- a/tests/Aggregation/ParentAggregationTest.php +++ b/tests/Aggregation/ParentAggregationTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class ParentAggregationTest extends BaseAggregationTest +class ParentAggregationTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testParentAggregation(): void { $agg = new ParentAggregation('question'); @@ -43,9 +42,7 @@ public function testParentAggregation(): void $this->assertArrayHasKey('tags', $parentAggregations); } - /** - * @group functional - */ + #[Group('functional')] public function testParentAggregationCount(): void { $topNames = new Terms('top-names'); diff --git a/tests/Aggregation/PercentilesBucketTest.php b/tests/Aggregation/PercentilesBucketTestCase.php similarity index 94% rename from tests/Aggregation/PercentilesBucketTest.php rename to tests/Aggregation/PercentilesBucketTestCase.php index 73b249e83..ee8fe7cf4 100644 --- a/tests/Aggregation/PercentilesBucketTest.php +++ b/tests/Aggregation/PercentilesBucketTestCase.php @@ -11,15 +11,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class PercentilesBucketTest extends BaseAggregationTest +class PercentilesBucketTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testPercentilesBucketAggregation(): void { $query = Query::create([]) @@ -49,9 +48,7 @@ public function testPercentilesBucketAggregation(): void ); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructThroughSetters(): void { $aggregation = (new PercentilesBucket('percentiles_bucket', 'pages>avg_likes_by_page')) diff --git a/tests/Aggregation/PercentilesTest.php b/tests/Aggregation/PercentilesTestCase.php similarity index 93% rename from tests/Aggregation/PercentilesTest.php rename to tests/Aggregation/PercentilesTestCase.php index 6733b2a5e..b7ba2ad26 100644 --- a/tests/Aggregation/PercentilesTest.php +++ b/tests/Aggregation/PercentilesTestCase.php @@ -7,15 +7,14 @@ use Elastica\Aggregation\Percentiles; use Elastica\Document; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class PercentilesTest extends BaseAggregationTest +class PercentilesTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testConstruct(): void { $agg = new Percentiles('price_percentile'); @@ -25,9 +24,7 @@ public function testConstruct(): void $this->assertSame('price', $agg->getParam('field')); } - /** - * @group functional - */ + #[Group('functional')] public function testSetField(): void { $agg = (new Percentiles('price_percentile')) @@ -37,9 +34,7 @@ public function testSetField(): void $this->assertSame('price', $agg->getParam('field')); } - /** - * @group unit - */ + #[Group('unit')] public function testCompression(): void { $expected = [ @@ -60,9 +55,7 @@ public function testCompression(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testHdr(): void { $expected = [ @@ -83,9 +76,7 @@ public function testHdr(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetPercents(): void { $percents = [1, 2, 3]; @@ -96,9 +87,7 @@ public function testSetPercents(): void $this->assertSame($percents, $agg->getParam('percents')); } - /** - * @group functional - */ + #[Group('functional')] public function testAddPercent(): void { $percents = [1, 2, 3]; @@ -112,9 +101,7 @@ public function testAddPercent(): void $this->assertEquals($percents, $agg->getParam('percents')); } - /** - * @group functional - */ + #[Group('functional')] public function testSetScript(): void { $script = 'doc["load_time"].value / 20'; @@ -125,9 +112,7 @@ public function testSetScript(): void $this->assertEquals($script, $agg->getParam('script')); } - /** - * @group functional - */ + #[Group('functional')] public function testActualWork(): void { // prepare @@ -169,9 +154,7 @@ public function testActualWork(): void $this->assertEquals(1000.0, $aggResult['values']['99.0']); } - /** - * @group functional - */ + #[Group('functional')] public function testKeyed(): void { $expected = [ @@ -241,9 +224,7 @@ public function testKeyed(): void $this->assertEquals($expected, $aggResult); } - /** - * @group unit - */ + #[Group('unit')] public function testMissing(): void { $expected = [ diff --git a/tests/Aggregation/RangeTest.php b/tests/Aggregation/RangeTestCase.php similarity index 93% rename from tests/Aggregation/RangeTest.php rename to tests/Aggregation/RangeTestCase.php index 7c49223b7..6992f50ec 100644 --- a/tests/Aggregation/RangeTest.php +++ b/tests/Aggregation/RangeTestCase.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class RangeTest extends BaseAggregationTest +class RangeTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testRangeAggregation(): void { $agg = new Range('range'); @@ -30,9 +29,7 @@ public function testRangeAggregation(): void $this->assertEquals(3, $results['buckets'][0]['doc_count']); } - /** - * @group functional - */ + #[Group('functional')] public function testRangeKeyedAggregation(): void { $agg = new Range('range'); @@ -50,9 +47,7 @@ public function testRangeKeyedAggregation(): void $this->assertSame($expected, \array_keys($results['buckets'])); } - /** - * @group unit - */ + #[Group('unit')] public function testRangeAggregationWithKey(): void { $agg = new Range('range'); diff --git a/tests/Aggregation/ReverseNestedTest.php b/tests/Aggregation/ReverseNestedTestCase.php similarity index 95% rename from tests/Aggregation/ReverseNestedTest.php rename to tests/Aggregation/ReverseNestedTestCase.php index 1f5984835..84e89c49e 100644 --- a/tests/Aggregation/ReverseNestedTest.php +++ b/tests/Aggregation/ReverseNestedTestCase.php @@ -11,33 +11,28 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class ReverseNestedTest extends BaseAggregationTest +class ReverseNestedTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testPathNotSetIfNull(): void { $agg = new ReverseNested('nested'); $this->assertFalse($agg->hasParam('path')); } - /** - * @group unit - */ + #[Group('unit')] public function testPathSetIfNotNull(): void { $agg = new ReverseNested('nested', 'some_field'); $this->assertEquals('some_field', $agg->getParam('path')); } - /** - * @group functional - */ + #[Group('functional')] public function testReverseNestedAggregation(): void { $agg = new Nested('comments', 'comments'); diff --git a/tests/Aggregation/SamplerTest.php b/tests/Aggregation/SamplerTestCase.php similarity index 88% rename from tests/Aggregation/SamplerTest.php rename to tests/Aggregation/SamplerTestCase.php index 6e2e0d160..446102fc3 100644 --- a/tests/Aggregation/SamplerTest.php +++ b/tests/Aggregation/SamplerTestCase.php @@ -9,15 +9,15 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class SamplerTest extends BaseAggregationTest +class SamplerTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $expected = [ @@ -44,11 +44,8 @@ public function testToArray(): void $this->assertEquals($expected, $agg->toArray()); } - /** - * @dataProvider shardSizeProvider - * - * @group functional - */ + #[Group('functional')] + #[DataProvider('shardSizeProvider')] public function testSamplerAggregation(int $shardSize, int $docCount): void { $agg = new Sampler('price_sampler'); @@ -66,7 +63,7 @@ public function testSamplerAggregation(int $shardSize, int $docCount): void $this->assertEquals($docCount, $results['doc_count']); } - public function shardSizeProvider(): array + public static function shardSizeProvider(): array { return [ [1, 2], diff --git a/tests/Aggregation/ScriptTest.php b/tests/Aggregation/ScriptTestCase.php similarity index 92% rename from tests/Aggregation/ScriptTest.php rename to tests/Aggregation/ScriptTestCase.php index 94d2bde6e..6f43a8d53 100644 --- a/tests/Aggregation/ScriptTest.php +++ b/tests/Aggregation/ScriptTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Query; use Elastica\Script\Script; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class ScriptTest extends BaseAggregationTest +class ScriptTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testAggregationScript(): void { $agg = new Sum('sum'); @@ -31,9 +30,7 @@ public function testAggregationScript(): void $this->assertEquals(5 + 8 + 1 + 3, $results['value']); } - /** - * @group functional - */ + #[Group('functional')] public function testAggregationScriptAsString(): void { $agg = new Sum('sum'); @@ -46,9 +43,7 @@ public function testAggregationScriptAsString(): void $this->assertEquals(5 + 8 + 1 + 3, $results['value']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScript(): void { $aggregation = 'sum'; diff --git a/tests/Aggregation/ScriptedMetricTest.php b/tests/Aggregation/ScriptedMetricTestCase.php similarity index 91% rename from tests/Aggregation/ScriptedMetricTest.php rename to tests/Aggregation/ScriptedMetricTestCase.php index 31b579f99..c76f7f175 100644 --- a/tests/Aggregation/ScriptedMetricTest.php +++ b/tests/Aggregation/ScriptedMetricTestCase.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class ScriptedMetricTest extends BaseAggregationTest +class ScriptedMetricTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testScriptedMetricAggregation(): void { $agg = new ScriptedMetric( diff --git a/tests/Aggregation/SerialDiffTest.php b/tests/Aggregation/SerialDiffTestCase.php similarity index 94% rename from tests/Aggregation/SerialDiffTest.php rename to tests/Aggregation/SerialDiffTestCase.php index 89923172d..51777106a 100644 --- a/tests/Aggregation/SerialDiffTest.php +++ b/tests/Aggregation/SerialDiffTestCase.php @@ -12,15 +12,14 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class SerialDiffTest extends BaseAggregationTest +class SerialDiffTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testSerialDiffAggregation(): void { $dateHistogramAggregation = new DateHistogram('measurements', 'measured_at', 'hour'); @@ -40,9 +39,7 @@ public function testSerialDiffAggregation(): void $this->assertEquals(121, $results['buckets'][3]['result']['value']); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructThroughSetters(): void { $aggregation = (new SerialDiff('difference', 'nested_agg')) diff --git a/tests/Aggregation/SignificantTermsTest.php b/tests/Aggregation/SignificantTermsTestCase.php similarity index 94% rename from tests/Aggregation/SignificantTermsTest.php rename to tests/Aggregation/SignificantTermsTestCase.php index ad210eff5..21bfd09e0 100644 --- a/tests/Aggregation/SignificantTermsTest.php +++ b/tests/Aggregation/SignificantTermsTestCase.php @@ -10,15 +10,14 @@ use Elastica\Mapping; use Elastica\Query; use Elastica\Query\Terms; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class SignificantTermsTest extends BaseAggregationTest +class SignificantTermsTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testSignificantTermsAggregation(): void { $agg = new SignificantTerms('significantTerms'); @@ -37,9 +36,7 @@ public function testSignificantTermsAggregation(): void $this->assertEquals('1500', $results['buckets'][0]['key']); } - /** - * @group functional - */ + #[Group('functional')] public function testSignificantTermsAggregationWithBackgroundFilter(): void { $agg = new SignificantTerms('significantTerms'); @@ -59,9 +56,7 @@ public function testSignificantTermsAggregationWithBackgroundFilter(): void $this->assertEquals('4500', $results['buckets'][0]['key']); } - /** - * @group functional - */ + #[Group('functional')] public function testSignificantTermsAggregationWithBackgroundFilterWithLegacyFilter(): void { $agg = new SignificantTerms('significantTerms'); diff --git a/tests/Aggregation/StatsBucketTest.php b/tests/Aggregation/StatsBucketTestCase.php similarity index 93% rename from tests/Aggregation/StatsBucketTest.php rename to tests/Aggregation/StatsBucketTestCase.php index be72d1f54..5c9f92d07 100644 --- a/tests/Aggregation/StatsBucketTest.php +++ b/tests/Aggregation/StatsBucketTestCase.php @@ -11,15 +11,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class StatsBucketTest extends BaseAggregationTest +class StatsBucketTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testStatBucketAggregation(): void { $bucketScriptAggregation = new StatsBucket('result', 'age_groups>max_weight'); @@ -44,9 +43,7 @@ public function testStatBucketAggregation(): void $this->assertEquals(180, $results['sum']); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructThroughSetters(): void { $aggregation = (new StatsBucket('bucket_part', 'age_groups>max_weight')) diff --git a/tests/Aggregation/StatsTest.php b/tests/Aggregation/StatsTestCase.php similarity index 92% rename from tests/Aggregation/StatsTest.php rename to tests/Aggregation/StatsTestCase.php index 352576625..0503511d1 100644 --- a/tests/Aggregation/StatsTest.php +++ b/tests/Aggregation/StatsTestCase.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class StatsTest extends BaseAggregationTest +class StatsTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testStatsAggregation(): void { $agg = new Stats('stats'); @@ -33,9 +32,7 @@ public function testStatsAggregation(): void $this->assertEquals(5 + 8 + 1 + 3, $results['sum']); } - /** - * @group functional - */ + #[Group('functional')] public function testStatsAggregationWithMissing(): void { $agg = new Stats('stats'); diff --git a/tests/Aggregation/SumBucketTest.php b/tests/Aggregation/SumBucketTestCase.php similarity index 93% rename from tests/Aggregation/SumBucketTest.php rename to tests/Aggregation/SumBucketTestCase.php index b622da616..1074c630f 100644 --- a/tests/Aggregation/SumBucketTest.php +++ b/tests/Aggregation/SumBucketTestCase.php @@ -11,15 +11,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class SumBucketTest extends BaseAggregationTest +class SumBucketTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testSumBucketAggregation(): void { $query = Query::create([]) @@ -44,9 +43,7 @@ public function testSumBucketAggregation(): void $this->assertEquals(491, $results['sum_likes_by_page']['value']); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructThroughSetters(): void { $aggregation = (new SumBucket('sum_bucket', 'pages>sum_likes_by_page')) diff --git a/tests/Aggregation/SumTest.php b/tests/Aggregation/SumTestCase.php similarity index 90% rename from tests/Aggregation/SumTest.php rename to tests/Aggregation/SumTestCase.php index 5fef5daaa..c5ab0aab6 100644 --- a/tests/Aggregation/SumTest.php +++ b/tests/Aggregation/SumTestCase.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class SumTest extends BaseAggregationTest +class SumTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testSumAggregation(): void { $agg = new Sum('sum'); @@ -29,9 +28,7 @@ public function testSumAggregation(): void $this->assertEquals(5 + 8 + 1 + 3, $results['value']); } - /** - * @group functional - */ + #[Group('functional')] public function testSumAggregationWithMissing(): void { $agg = new Sum('sum'); diff --git a/tests/Aggregation/TermsTest.php b/tests/Aggregation/TermsTestCase.php similarity index 90% rename from tests/Aggregation/TermsTest.php rename to tests/Aggregation/TermsTestCase.php index befeb274d..40db4ffc9 100644 --- a/tests/Aggregation/TermsTest.php +++ b/tests/Aggregation/TermsTestCase.php @@ -10,15 +10,15 @@ use Elastica\Index; use Elastica\Mapping; use Elastica\Query; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class TermsTest extends BaseAggregationTest +class TermsTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testIncludePattern(): void { $agg = new Terms('terms'); @@ -27,9 +27,7 @@ public function testIncludePattern(): void $this->assertSame('pattern*', $agg->getParam('include')); } - /** - * @group unit - */ + #[Group('unit')] public function testIncludeExactMatch(): void { $agg = new Terms('terms'); @@ -38,9 +36,7 @@ public function testIncludeExactMatch(): void $this->assertSame(['first', 'second'], $agg->getParam('include')); } - /** - * @group unit - */ + #[Group('unit')] public function testIncludeWithPartitions(): void { $agg = new Terms('terms'); @@ -52,9 +48,7 @@ public function testIncludeWithPartitions(): void ], $agg->getParam('include')); } - /** - * @group unit - */ + #[Group('unit')] public function testExcludePattern(): void { $agg = new Terms('terms'); @@ -63,9 +57,7 @@ public function testExcludePattern(): void $this->assertSame('pattern*', $agg->getParam('exclude')); } - /** - * @group unit - */ + #[Group('unit')] public function testExcludeExactMatch(): void { $agg = new Terms('terms'); @@ -74,9 +66,7 @@ public function testExcludeExactMatch(): void $this->assertSame(['first', 'second'], $agg->getParam('exclude')); } - /** - * @group functional - */ + #[Group('functional')] public function testTermsAggregation(): void { $agg = new Terms('terms'); @@ -90,9 +80,7 @@ public function testTermsAggregation(): void $this->assertEquals('blue', $results['buckets'][0]['key']); } - /** - * @group functional - */ + #[Group('functional')] public function testTermsSetOrder(): void { $agg = new Terms('terms'); @@ -106,9 +94,7 @@ public function testTermsSetOrder(): void $this->assertEquals('blue', $results['buckets'][2]['key']); } - /** - * @group functional - */ + #[Group('functional')] public function testTermsWithMissingAggregation(): void { $agg = new Terms('terms'); @@ -123,9 +109,7 @@ public function testTermsWithMissingAggregation(): void $this->assertEquals('blue', $results['buckets'][0]['key']); } - /** - * @group functional - */ + #[Group('functional')] public function testTermsSetOrders(): void { $agg = new Terms('terms'); @@ -144,9 +128,7 @@ public function testTermsSetOrders(): void $this->assertSame('blue', $results['buckets'][2]['key']); } - /** - * @group unit - */ + #[Group('unit')] public function testTermsSetMissingBucketUnit(): void { $agg = new Terms('terms'); @@ -155,11 +137,8 @@ public function testTermsSetMissingBucketUnit(): void $this->assertTrue($agg->getParam('missing_bucket')); } - /** - * @dataProvider termsSetMissingBucketProvider - * - * @group functional - */ + #[Group('functional')] + #[DataProvider('termsSetMissingBucketProvider')] public function testTermsSetMissingBucketFunctional( string $field, int $expectedCountValues, @@ -181,7 +160,7 @@ public function testTermsSetMissingBucketFunctional( $this->assertCount($expectedCountValues, $results['buckets']); } - public function termsSetMissingBucketProvider(): \Traversable + public static function termsSetMissingBucketProvider(): \Generator { yield [ 'field' => 'color', diff --git a/tests/Aggregation/TopHitsTest.php b/tests/Aggregation/TopHitsTestCase.php similarity index 92% rename from tests/Aggregation/TopHitsTest.php rename to tests/Aggregation/TopHitsTestCase.php index 8c79e6581..44c3679e5 100644 --- a/tests/Aggregation/TopHitsTest.php +++ b/tests/Aggregation/TopHitsTestCase.php @@ -15,15 +15,15 @@ use Elastica\Query\SimpleQueryString; use Elastica\Script\Script; use Elastica\Script\ScriptFields; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class TopHitsTest extends BaseAggregationTest +class TopHitsTestCase extends BaseAggregationTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testSetSize(): void { $agg = (new TopHits('agg_name')) @@ -33,9 +33,7 @@ public function testSetSize(): void $this->assertSame(12, $agg->getParam('size')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetFrom(): void { $agg = (new TopHits('agg_name')) @@ -45,9 +43,7 @@ public function testSetFrom(): void $this->assertEquals(12, $agg->getParam('from')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetSort(): void { $sort = ['last_activity_date' => ['order' => 'desc']]; @@ -58,9 +54,7 @@ public function testSetSort(): void $this->assertSame($sort, $agg->getParam('sort')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetSource(): void { $fields = ['title', 'tags']; @@ -71,9 +65,7 @@ public function testSetSource(): void $this->assertSame($fields, $agg->getParam('_source')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetVersion(): void { $agg = (new TopHits('agg_name')) @@ -86,9 +78,7 @@ public function testSetVersion(): void $this->assertFalse($agg->getParam('version')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetExplain(): void { $agg = (new TopHits('agg_name')) @@ -101,9 +91,7 @@ public function testSetExplain(): void $this->assertFalse($agg->getParam('explain')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetHighlight(): void { $highlight = [ @@ -118,9 +106,7 @@ public function testSetHighlight(): void $this->assertSame($highlight, $agg->getParam('highlight')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetFieldDataFields(): void { $fields = ['title', 'tags']; @@ -131,9 +117,7 @@ public function testSetFieldDataFields(): void $this->assertSame($fields, $agg->getParam('docvalue_fields')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScriptFields(): void { $script = new Script('1 + 2'); @@ -146,9 +130,7 @@ public function testSetScriptFields(): void $this->assertSame($scriptFields, $agg->getParam('script_fields')); } - /** - * @group unit - */ + #[Group('unit')] public function testAddScriptField(): void { $script = new Script('2+3'); @@ -159,9 +141,7 @@ public function testAddScriptField(): void $this->assertEquals(['five' => $script->toArray()], $agg->getParam('script_fields')->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateUpdatedRecently(): void { $agg = (new TopHits('top_tag_hits')) @@ -180,9 +160,7 @@ public function testAggregateUpdatedRecently(): void $this->assertEquals([1, 3], $resultDocs); } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateUpdatedFarAgo(): void { $agg = (new TopHits('top_tag_hits')) @@ -201,9 +179,7 @@ public function testAggregateUpdatedFarAgo(): void $this->assertEquals([2, 4], $resultDocs); } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateTwoDocumentPerTag(): void { $agg = (new TopHits('top_tag_hits')) @@ -221,9 +197,7 @@ public function testAggregateTwoDocumentPerTag(): void $this->assertEquals([1, 2, 3, 4], $resultDocs); } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateTwoDocumentPerTagWithOffset(): void { $agg = (new TopHits('top_tag_hits')) @@ -243,7 +217,7 @@ public function testAggregateTwoDocumentPerTagWithOffset(): void $this->assertEquals([2, 4], $resultDocs); } - public function limitedSourceProvider(): array + public static function limitedSourceProvider(): array { return [ 'string source' => ['title'], @@ -251,11 +225,8 @@ public function limitedSourceProvider(): array ]; } - /** - * @group functional - * - * @dataProvider limitedSourceProvider - */ + #[Group('functional')] + #[DataProvider('limitedSourceProvider')] public function testAggregateWithLimitedSource($source): void { $agg = (new TopHits('top_tag_hits')) @@ -272,9 +243,7 @@ public function testAggregateWithLimitedSource($source): void } } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateWithVersion(): void { $agg = (new TopHits('top_tag_hits')) @@ -289,9 +258,7 @@ public function testAggregateWithVersion(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateWithExplain(): void { $agg = (new TopHits('top_tag_hits')) @@ -306,9 +273,7 @@ public function testAggregateWithExplain(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateWithScriptFields(): void { $agg = (new TopHits('top_tag_hits')) @@ -326,9 +291,7 @@ public function testAggregateWithScriptFields(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateWithHighlight(): void { $queryString = new SimpleQueryString('linux', ['title']); @@ -349,9 +312,7 @@ public function testAggregateWithHighlight(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testAggregateWithFieldData(): void { $agg = (new TopHits('top_tag_hits')) diff --git a/tests/Aggregation/ValueCountTest.php b/tests/Aggregation/ValueCountTestCase.php similarity index 88% rename from tests/Aggregation/ValueCountTest.php rename to tests/Aggregation/ValueCountTestCase.php index 7ec62c91c..f39c6ae4e 100644 --- a/tests/Aggregation/ValueCountTest.php +++ b/tests/Aggregation/ValueCountTestCase.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class ValueCountTest extends BaseAggregationTest +class ValueCountTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testValueCountAggregation(): void { $agg = new ValueCount('count', 'price'); diff --git a/tests/Aggregation/WeightedAvgTest.php b/tests/Aggregation/WeightedAvgTestCase.php similarity index 92% rename from tests/Aggregation/WeightedAvgTest.php rename to tests/Aggregation/WeightedAvgTestCase.php index 090026486..503ce9d4d 100644 --- a/tests/Aggregation/WeightedAvgTest.php +++ b/tests/Aggregation/WeightedAvgTestCase.php @@ -9,15 +9,14 @@ use Elastica\Exception\InvalidException; use Elastica\Index; use Elastica\Query; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class WeightedAvgTest extends BaseAggregationTest +class WeightedAvgTestCase extends BaseAggregationTestCase { - /** - * @group functional - */ + #[Group('functional')] public function testWeightedAvgAggregation(): void { $agg = new WeightedAvg('weighted'); @@ -35,9 +34,7 @@ public function testWeightedAvgAggregation(): void $this->assertEquals((5 * 3 + 8 + 1 + 3 * $weightWhenMissing) / 7.0, $results['weighted']['value']); } - /** - * @group unit - */ + #[Group('unit')] public function testItsNotPossibleToMixValueFieldAndScript(): void { $agg = new WeightedAvg('weighted'); @@ -47,9 +44,7 @@ public function testItsNotPossibleToMixValueFieldAndScript(): void $agg->setValueScript('doc.price.value + 1'); } - /** - * @group unit - */ + #[Group('unit')] public function testItsNotPossibleToMixValueScriptAndField(): void { $agg = new WeightedAvg('weighted'); @@ -59,9 +54,7 @@ public function testItsNotPossibleToMixValueScriptAndField(): void $agg->setValue('price'); } - /** - * @group unit - */ + #[Group('unit')] public function testItsNotPossibleToMixWeightFieldAndScript(): void { $agg = new WeightedAvg('weighted'); @@ -71,9 +64,7 @@ public function testItsNotPossibleToMixWeightFieldAndScript(): void $agg->setWeightScript('doc.weight.value + 1'); } - /** - * @group unit - */ + #[Group('unit')] public function testItsNotPossibleToMixWeightScriptAndField(): void { $agg = new WeightedAvg('weighted'); diff --git a/tests/Base.php b/tests/Base.php index 2fceea4fa..bbc8cc71d 100644 --- a/tests/Base.php +++ b/tests/Base.php @@ -10,7 +10,6 @@ use Elastica\Index; use Elastica\Test\Transport\NodePool\TraceableSimpleNodePool; use PHPUnit\Framework\TestCase; -use PHPUnit\Util\Test as TestUtil; use Psr\Log\LoggerInterface; /** @@ -24,7 +23,6 @@ protected function setUp(): void $hasGroup = $this->_isUnitGroup() || $this->_isFunctionalGroup() || $this->_isBenchmarkGroup(); $this->assertTrue($hasGroup, 'Every test must have one of "unit", "functional", "benchmark" group'); - $this->showDeprecated(); } protected function tearDown(): void @@ -37,16 +35,6 @@ protected function tearDown(): void parent::tearDown(); } - protected static function hideDeprecated(): void - { - \error_reporting(\error_reporting() & ~\E_USER_DEPRECATED); - } - - protected static function showDeprecated(): void - { - \error_reporting(\error_reporting() | \E_USER_DEPRECATED); - } - /** * @param array $config Additional configuration params. Host and Port are already set */ @@ -168,22 +156,16 @@ protected function _waitForAllocation(Index $index): void protected function _isUnitGroup(): bool { - $groups = TestUtil::getGroups(\get_class($this), $this->getName(false)); - - return \in_array('unit', $groups, true); + return \in_array('unit', $this->groups(), true); } protected function _isFunctionalGroup(): bool { - $groups = TestUtil::getGroups(\get_class($this), $this->getName(false)); - - return \in_array('functional', $groups, true); + return \in_array('functional', $this->groups(), true); } protected function _isBenchmarkGroup(): bool { - $groups = TestUtil::getGroups(\get_class($this), $this->getName(false)); - - return \in_array('benchmark', $groups, true); + return \in_array('benchmark', $this->groups(), true); } } diff --git a/tests/Bulk/Action/AbstractDocumentTest.php b/tests/Bulk/Action/AbstractDocumentTest.php index 2f68771cd..0d464eea8 100644 --- a/tests/Bulk/Action/AbstractDocumentTest.php +++ b/tests/Bulk/Action/AbstractDocumentTest.php @@ -7,15 +7,14 @@ use Elastica\Bulk\Action\AbstractDocument; use Elastica\Script\Script; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class AbstractDocumentTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testCreateAbstractDocumentWithInvalidParameter(): void { $this->expectException(\InvalidArgumentException::class); @@ -24,9 +23,7 @@ public function testCreateAbstractDocumentWithInvalidParameter(): void AbstractDocument::create(new \stdClass()); } - /** - * @group unit - */ + #[Group('unit')] public function testCreateAbstractDocumentWithScript(): void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Bulk/Action/UpdateDocumentTest.php b/tests/Bulk/Action/UpdateDocumentTest.php index 7565d819e..7caadf539 100644 --- a/tests/Bulk/Action/UpdateDocumentTest.php +++ b/tests/Bulk/Action/UpdateDocumentTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class UpdateDocumentTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testUpdateDocument(): void { $document = new Document(null, ['foo' => 'bar']); @@ -55,9 +54,7 @@ public function testUpdateDocument(): void $this->assertEquals($expected, (string) $action); } - /** - * @group unit - */ + #[Group('unit')] public function testUpdateDocumentAsUpsert(): void { $document = (new Document('1', ['foo' => 'bar'], 'index')) diff --git a/tests/Bulk/ActionTest.php b/tests/Bulk/ActionTest.php index c4200f856..8480db91b 100644 --- a/tests/Bulk/ActionTest.php +++ b/tests/Bulk/ActionTest.php @@ -7,18 +7,14 @@ use Elastica\Bulk\Action; use Elastica\Index; use Elastica\Test\Base as BaseTest; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ActionTest extends BaseTest { - use ExpectDeprecationTrait; - - /** - * @group unit - */ + #[Group('unit')] public function testAction(): void { $action = new Action(); diff --git a/tests/Bulk/ResponseSetTest.php b/tests/Bulk/ResponseSetTest.php index ebf7ba8a2..505c93a6a 100644 --- a/tests/Bulk/ResponseSetTest.php +++ b/tests/Bulk/ResponseSetTest.php @@ -12,41 +12,36 @@ use Elastica\Exception\Bulk\ResponseException; use Elastica\Response; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ResponseSetTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testConstructor(): void { - [$responseData, $actions] = $this->_getFixture(); + [$responseData, $actions] = self::_getFixture(); $responseSet = $this->_createResponseSet($responseData, $actions); $this->assertEquals(200, $responseSet->getStatus()); } - /** - * @group unit - * - * @dataProvider isOkDataProvider - */ + #[Group('unit')] + #[DataProvider('isOkDataProvider')] public function testIsOk(array $responseData, array $actions, bool $expected): void { $responseSet = $this->_createResponseSet($responseData, $actions); $this->assertEquals($expected, $responseSet->isOk()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetError(): void { - [$responseData, $actions] = $this->_getFixture(); + [$responseData, $actions] = self::_getFixture(); $responseData['items'][1]['index']['ok'] = false; $responseData['items'][1]['index']['error'] = 'SomeExceptionMessage'; $responseData['items'][2]['index']['ok'] = false; @@ -77,12 +72,10 @@ public function testGetError(): void } } - /** - * @group unit - */ + #[Group('unit')] public function testGetBulkResponses(): void { - [$responseData, $actions] = $this->_getFixture(); + [$responseData, $actions] = self::_getFixture(); $responseSet = $this->_createResponseSet($responseData, $actions); @@ -101,12 +94,10 @@ public function testGetBulkResponses(): void } } - /** - * @group unit - */ + #[Group('unit')] public function testIterator(): void { - [$responseData, $actions] = $this->_getFixture(); + [$responseData, $actions] = self::_getFixture(); $responseSet = $this->_createResponseSet($responseData, $actions); @@ -130,9 +121,9 @@ public function testIterator(): void $this->assertTrue($responseSet->valid()); } - public function isOkDataProvider(): \Generator + public static function isOkDataProvider(): \Generator { - [$responseData, $actions] = $this->_getFixture(); + [$responseData, $actions] = self::_getFixture(); yield [$responseData, $actions, true]; $responseData['items'][2]['index']['ok'] = false; @@ -157,7 +148,7 @@ protected function _createResponseSet(array $responseData, array $actions): Resp return $bulk->send(); } - protected function _getFixture(): array + protected static function _getFixture(): array { $responseData = [ 'took' => 5, diff --git a/tests/BulkTest.php b/tests/BulkTest.php index fa6e0cad4..b3797cbf6 100644 --- a/tests/BulkTest.php +++ b/tests/BulkTest.php @@ -20,6 +20,8 @@ use Elastica\Response as ElasticaResponse; use Elastica\Script\Script; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; /** @@ -27,9 +29,7 @@ */ class BulkTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testSend(): void { $index = $this->_createIndex(); @@ -139,9 +139,7 @@ public function testSend(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testUnicodeBulkSend(): void { $index = $this->_createIndex(); @@ -168,9 +166,7 @@ public function testUnicodeBulkSend(): void $this->assertSame($newDocument3, $actions[2]->getDocument()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetIndex(): void { $client = $this->_getClient(); @@ -195,9 +191,7 @@ public function testSetIndex(): void $this->assertEquals('index', $bulk->getIndex()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddActions(): void { $client = $this->_getClient(); @@ -225,9 +219,7 @@ public function testAddActions(): void $this->assertSame($action2, $getActions[1]); } - /** - * @group unit - */ + #[Group('unit')] public function testAddRawData(): void { $bulk = new Bulk($this->_getClient()); @@ -277,11 +269,8 @@ public function testAddRawData(): void $this->assertFalse($actions[4]->hasSource()); } - /** - * @group unit - * - * @dataProvider invalidRawDataProvider - */ + #[Group('unit')] + #[DataProvider('invalidRawDataProvider')] public function testInvalidRawData($rawData, $failMessage): void { $this->expectException(InvalidException::class); @@ -293,7 +282,7 @@ public function testInvalidRawData($rawData, $failMessage): void $this->fail($failMessage); } - public function invalidRawDataProvider(): array + public static function invalidRawDataProvider(): array { return [ [ @@ -333,9 +322,7 @@ public function invalidRawDataProvider(): array ]; } - /** - * @group functional - */ + #[Group('functional')] public function testErrorRequest(): void { $index = $this->_createIndex(); @@ -364,9 +351,7 @@ public function testErrorRequest(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testRawDocumentDataRequest(): void { $index = $this->_createIndex(); @@ -409,9 +394,7 @@ public function testRawDocumentDataRequest(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testUpdate(): void { $index = $this->_createIndex(); @@ -542,9 +525,7 @@ public function testUpdate(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testUpsert(): void { $index = $this->_createIndex(); @@ -590,9 +571,7 @@ public function testUpsert(): void $this->assertEquals('Maradona', $docData['name']); } - /** - * @group functional - */ + #[Group('functional')] public function testScriptUpsert(): void { $index = $this->_createIndex(); @@ -656,9 +635,7 @@ public function testScriptUpsert(): void $this->assertEquals($subField2['field_2'], $doc->getData()['sub_field_2'][0]['field_2']); } - /** - * @group unit - */ + #[Group('unit')] public function testGetPath(): void { $client = $this->_getClient(); @@ -672,9 +649,7 @@ public function testGetPath(): void $this->assertEquals($indexName.'/_bulk', $bulk->getPath()); } - /** - * @group functional - */ + #[Group('functional')] public function testRetry(): void { $index = $this->_createIndex(); @@ -727,9 +702,7 @@ public function testRetry(): void $this->assertEquals(5, $metadata['retry_on_conflict']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetShardTimeout(): void { $bulk = new Bulk($this->_getClient()); @@ -737,9 +710,7 @@ public function testSetShardTimeout(): void $this->assertSame($bulk, $bulk->setShardTimeout('10s')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetRequestParam(): void { $bulk = new Bulk($this->_getClient()); @@ -747,9 +718,7 @@ public function testSetRequestParam(): void $this->assertSame($bulk, $bulk->setRequestParam('key', 'value')); } - /** - * @group benchmark - */ + #[Group('benchmark')] public function testMemoryUsage(): void { $index = $this->_createIndex(); @@ -780,9 +749,7 @@ public function testMemoryUsage(): void $this->assertLessThan(1.41, $endMemory / $startMemory); } - /** - * @group unit - */ + #[Group('unit')] public function testHasIndex(): void { $client = $this->_getClient(); @@ -793,9 +760,7 @@ public function testHasIndex(): void $this->assertTrue($bulk->hasIndex()); } - /** - * @group unit - */ + #[Group('unit')] public function testSendRequestEntityTooLargeExceptionIf413Response(): void { $response = new ElasticaResponse('', 413); diff --git a/tests/ClientConfigurationTest.php b/tests/ClientConfigurationTest.php index 0e32eb522..82b03b4ad 100644 --- a/tests/ClientConfigurationTest.php +++ b/tests/ClientConfigurationTest.php @@ -6,13 +6,13 @@ use Elastica\ClientConfiguration; use Elastica\Exception\InvalidException; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; /** - * @group unit - * * @internal */ +#[Group('unit')] class ClientConfigurationTest extends TestCase { public function testFromEmptyArray(): void diff --git a/tests/ClientFunctionalTest.php b/tests/ClientFunctionalTest.php index b779c8b46..06651ab0b 100644 --- a/tests/ClientFunctionalTest.php +++ b/tests/ClientFunctionalTest.php @@ -15,14 +15,15 @@ use Elastica\Test\Base as BaseTest; use Elastica\Test\Transport\NodePool\TraceableSimpleNodePool; use GuzzleHttp\RequestOptions; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Psr\Http\Client\ClientInterface as HttpClientInterface; use Psr\Http\Message\RequestInterface; /** - * @group functional - * * @internal */ +#[Group('functional')] class ClientFunctionalTest extends BaseTest { public function testConnectionErrors(): void @@ -144,9 +145,8 @@ public function testForcemergeAll(): void /** * Test bulk operations on Index. - * - * @group functional */ + #[Group('functional')] public function testBulkIndex(): void { $index = $this->_getClient()->getIndex('cryptocurrencies'); @@ -248,9 +248,8 @@ public function testGetDocumentWithVersion(): void * It will add a document, search for it, then delete it * using the parameter types we are interested in, and then * re-search to verify that they have been deleted - * - * @group functional */ + #[Group('functional')] public function testDeleteIdsIdxString(): void { $data = ['username' => 'hans']; @@ -309,9 +308,8 @@ public function testDeleteIdsIdxString(): void * It will add a document, search for it, then delete it * using the parameter types we are interested in, and then * re-search to verify that they have been deleted - * - * @group functional */ + #[Group('functional')] public function testDeleteIdsIdxObjectTypeObject(): void { $data = ['username' => 'hans']; @@ -883,9 +881,7 @@ public function testEndpointParamsRequest(): void ); } - /** - * @dataProvider endpointQueryRequestDataProvider - */ + #[DataProvider('endpointQueryRequestDataProvider')] public function testEndpointQueryRequest($query, $totalHits): void { $client = $this->_getClient(); @@ -912,7 +908,7 @@ public function testEndpointQueryRequest($query, $totalHits): void $this->assertEquals($totalHits, $responseArray['hits']['total']['value']); } - public function endpointQueryRequestDataProvider(): array + public static function endpointQueryRequestDataProvider(): array { return [ ['ruflin', 1], diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 83e832cc4..27bba47d7 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -8,12 +8,12 @@ use Elastica\ClientConfiguration; use Elastica\Exception\InvalidException; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** - * @group unit - * * @internal */ +#[Group('unit')] class ClientTest extends BaseTest { public function testItConstruct(): void diff --git a/tests/Cluster/Health/IndexTest.php b/tests/Cluster/Health/IndexTest.php index fc8fa42ad..d4383f31e 100644 --- a/tests/Cluster/Health/IndexTest.php +++ b/tests/Cluster/Health/IndexTest.php @@ -7,6 +7,7 @@ use Elastica\Cluster\Health\Index; use Elastica\Cluster\Health\Shard; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -62,81 +63,61 @@ protected function setUp(): void $this->_index = new Index('test', $data); } - /** - * @group unit - */ + #[Group('unit')] public function testGetName(): void { $this->assertEquals('test', $this->_index->getName()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetStatus(): void { $this->assertEquals('yellow', $this->_index->getStatus()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetNumberOfShards(): void { $this->assertEquals(1, $this->_index->getNumberOfShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetNumberOfReplicas(): void { $this->assertEquals(2, $this->_index->getNumberOfReplicas()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetActivePrimaryShards(): void { $this->assertEquals(3, $this->_index->getActivePrimaryShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetActiveShards(): void { $this->assertEquals(4, $this->_index->getActiveShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetRelocatingShards(): void { $this->assertEquals(5, $this->_index->getRelocatingShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetInitializingShards(): void { $this->assertEquals(6, $this->_index->getInitializingShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetUnassignedShards(): void { $this->assertEquals(7, $this->_index->getUnassignedShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetShards(): void { $shards = $this->_index->getShards(); diff --git a/tests/Cluster/Health/ShardTest.php b/tests/Cluster/Health/ShardTest.php index 56fb04e92..600d740d4 100644 --- a/tests/Cluster/Health/ShardTest.php +++ b/tests/Cluster/Health/ShardTest.php @@ -6,6 +6,7 @@ use Elastica\Cluster\Health\Shard; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -33,57 +34,43 @@ protected function setUp(): void $this->_shard = new Shard(2, $shardData); } - /** - * @group unit - */ + #[Group('unit')] public function testGetShardNumber(): void { $this->assertEquals(2, $this->_shard->getShardNumber()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetStatus(): void { $this->assertEquals('red', $this->_shard->getStatus()); } - /** - * @group unit - */ + #[Group('unit')] public function testisPrimaryActive(): void { $this->assertTrue($this->_shard->isPrimaryActive()); } - /** - * @group unit - */ + #[Group('unit')] public function testIsActive(): void { $this->assertTrue($this->_shard->isActive()); } - /** - * @group unit - */ + #[Group('unit')] public function testIsRelocating(): void { $this->assertFalse($this->_shard->isRelocating()); } - /** - * @group unit - */ + #[Group('unit')] public function testIsInitialized(): void { $this->assertFalse($this->_shard->isInitialized()); } - /** - * @group unit - */ + #[Group('unit')] public function testIsUnassigned(): void { $this->assertTrue($this->_shard->isUnassigned()); diff --git a/tests/Cluster/HealthTest.php b/tests/Cluster/HealthTest.php index 2dc050afa..fd90ff1a4 100644 --- a/tests/Cluster/HealthTest.php +++ b/tests/Cluster/HealthTest.php @@ -7,6 +7,7 @@ use Elastica\Cluster\Health; use Elastica\Cluster\Health\Index; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -50,7 +51,7 @@ protected function setUp(): void $health = $this ->getMockBuilder(Health::class) ->setConstructorArgs([$this->_getClient()]) - ->setMethods(['_retrieveHealthData']) + ->onlyMethods(['_retrieveHealthData']) ->getMock() ; @@ -65,129 +66,97 @@ protected function setUp(): void $this->_health = $health; } - /** - * @group unit - */ + #[Group('unit')] public function testGetClusterName(): void { $this->assertEquals('test_cluster', $this->_health->getClusterName()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetStatus(): void { $this->assertEquals('green', $this->_health->getStatus()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetTimedOut(): void { $this->assertFalse($this->_health->getTimedOut()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetNumberOfNodes(): void { $this->assertEquals(10, $this->_health->getNumberOfNodes()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetNumberOfDataNodes(): void { $this->assertEquals(8, $this->_health->getNumberOfDataNodes()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetActivePrimaryShards(): void { $this->assertEquals(3, $this->_health->getActivePrimaryShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetActiveShards(): void { $this->assertEquals(4, $this->_health->getActiveShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetRelocatingShards(): void { $this->assertEquals(2, $this->_health->getRelocatingShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetInitializingShards(): void { $this->assertEquals(7, $this->_health->getInitializingShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetUnassignedShards(): void { $this->assertEquals(5, $this->_health->getUnassignedShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetDelayedUnassignedShards(): void { $this->assertEquals(4, $this->_health->getDelayedUnassignedShards()); } - /** - * @group unit - */ + #[Group('unit')] public function testNumberOfPendingTasks(): void { $this->assertEquals(1, $this->_health->getNumberOfPendingTasks()); } - /** - * @group unit - */ + #[Group('unit')] public function testNumberOfInFlightFetch(): void { $this->assertEquals(2, $this->_health->getNumberOfInFlightFetch()); } - /** - * @group unit - */ + #[Group('unit')] public function testTaskMaxWaitingInQueueMillis(): void { $this->assertEquals(634, $this->_health->getTaskMaxWaitingInQueueMillis()); } - /** - * @group unit - */ + #[Group('unit')] public function testActiveShardsPercentAsNumber(): void { $this->assertEquals(50.0, $this->_health->getActiveShardsPercentAsNumber()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetIndices(): void { $indices = $this->_health->getIndices(); diff --git a/tests/Cluster/SettingsTest.php b/tests/Cluster/SettingsTest.php index 657f0a4c2..1c53565fe 100644 --- a/tests/Cluster/SettingsTest.php +++ b/tests/Cluster/SettingsTest.php @@ -8,15 +8,14 @@ use Elastica\Cluster\Settings; use Elastica\Document; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SettingsTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testSetReadOnly(): void { // Create two indices to check that the complete cluster is read only diff --git a/tests/ClusterTest.php b/tests/ClusterTest.php index feaba72ee..897b75b18 100644 --- a/tests/ClusterTest.php +++ b/tests/ClusterTest.php @@ -7,12 +7,12 @@ use Elastica\Cluster; use Elastica\Node; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** - * @group functional - * * @internal */ +#[Group('functional')] class ClusterTest extends BaseTest { public function testGetNodeNames(): void diff --git a/tests/Collapse/CollapseTest.php b/tests/Collapse/CollapseTest.php index 9213b967f..ecb1066c2 100644 --- a/tests/Collapse/CollapseTest.php +++ b/tests/Collapse/CollapseTest.php @@ -12,15 +12,14 @@ use Elastica\Query; use Elastica\ResultSet; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class CollapseTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testSetFieldName(): void { $collapse = (new Collapse()) @@ -30,9 +29,7 @@ public function testSetFieldName(): void $this->assertSame('some_name', $collapse->getParam('field')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetInnerHits(): void { $collapse = (new Collapse()) @@ -42,9 +39,7 @@ public function testSetInnerHits(): void $this->assertSame($innerHits, $collapse->getParam('inner_hits')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetMaxConcurrentGroupSearches(): void { $collapse = (new Collapse()) @@ -54,9 +49,7 @@ public function testSetMaxConcurrentGroupSearches(): void $this->assertSame(5, $collapse->getParam('max_concurrent_group_searches')); } - /** - * @group unit - */ + #[Group('unit')] public function testAddInnerHits(): void { $collapse = new Collapse(); @@ -76,9 +69,7 @@ public function testAddInnerHits(): void $this->assertEquals($innerHits2, $collapse->getParam('inner_hits')[1]); } - /** - * @group unit - */ + #[Group('unit')] public function testSetThenAddInnerHits(): void { $collapse = new Collapse(); @@ -98,9 +89,7 @@ public function testSetThenAddInnerHits(): void $this->assertEquals($innerHits2, $collapse->getParam('inner_hits')[1]); } - /** - * @group unit - */ + #[Group('unit')] public function testSetInnerHitsOverridesExistingValue(): void { $collapse = new Collapse(); @@ -130,9 +119,7 @@ public function testSetInnerHitsOverridesExistingValue(): void $this->assertEquals($innerHitsOverride, $collapse->getParam('inner_hits')); } - /** - * @group functional - */ + #[Group('functional')] public function testCollapseField(): void { $query = new Query(); @@ -161,9 +148,7 @@ public function testCollapseField(): void $this->assertEquals('Keith', $results->getResults()[3]->getData()['user'][0]); } - /** - * @group functional - */ + #[Group('functional')] public function testCollapseWithInnerHits(): void { $query = new Query(); @@ -197,9 +182,7 @@ public function testCollapseWithInnerHits(): void ); } - /** - * @group functional - */ + #[Group('functional')] public function testCollapseWithMultipleInnerHits(): void { $query = new Query(); @@ -250,9 +233,7 @@ public function testCollapseWithMultipleInnerHits(): void ); } - /** - * @group functional - */ + #[Group('functional')] public function testSecondLevelCollapsing(): void { $query = new Query(); diff --git a/tests/DeprecatedClassBase.php b/tests/DeprecatedClassBase.php deleted file mode 100644 index 042fda3a7..000000000 --- a/tests/DeprecatedClassBase.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class DeprecatedClassBase extends Base -{ - protected function setUp(): void - { - parent::setUp(); - $this->hideDeprecated(); - } - - protected function tearDown(): void - { - $this->showDeprecated(); - parent::tearDown(); - } -} diff --git a/tests/DocumentTest.php b/tests/DocumentTest.php index cefc2a5c6..085d17a15 100644 --- a/tests/DocumentTest.php +++ b/tests/DocumentTest.php @@ -9,15 +9,14 @@ use Elastica\Index; use Elastica\Reindex; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class DocumentTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testAddFile(): void { $fileName = '/dev/null'; @@ -30,9 +29,7 @@ public function testAddFile(): void $this->assertSame($doc, $returnValue); } - /** - * @group unit - */ + #[Group('unit')] public function testAddGeoPoint(): void { $doc = new Document(); @@ -41,9 +38,7 @@ public function testAddGeoPoint(): void $this->assertSame($doc, $returnValue); } - /** - * @group unit - */ + #[Group('unit')] public function testSetData(): void { $doc = new Document(); @@ -52,9 +47,7 @@ public function testSetData(): void $this->assertSame($doc, $returnValue); } - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $id = '17'; @@ -71,9 +64,7 @@ public function testToArray(): void $this->assertEquals($result, $doc->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetIndex(): void { $document = new Document(); @@ -87,9 +78,7 @@ public function testSetIndex(): void $this->assertEquals('index', $document->getIndex()); } - /** - * @group unit - */ + #[Group('unit')] public function testHasId(): void { $document = new Document(); @@ -102,9 +91,7 @@ public function testHasId(): void $this->assertTrue($document->hasId()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetSetHasRefresh(): void { $document = new Document(); @@ -130,9 +117,7 @@ public function testGetSetHasRefresh(): void $this->assertEquals(Reindex::REFRESH_WAIT_FOR, $document->getRefresh()); } - /** - * @group unit - */ + #[Group('unit')] public function testGetOptions(): void { $document = new Document(); @@ -156,9 +141,7 @@ public function testGetOptions(): void $this->assertArrayNotHasKey('parent', $options); } - /** - * @group unit - */ + #[Group('unit')] public function testGetSetHasRemove(): void { $document = new Document('1', ['field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null]); @@ -210,9 +193,7 @@ public function testGetSetHasRemove(): void $this->assertNotEquals($data, $newData); } - /** - * @group unit - */ + #[Group('unit')] public function testDataPropertiesOverloading(): void { $document = new Document('1', ['field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null]); @@ -262,9 +243,7 @@ public function testDataPropertiesOverloading(): void $this->assertNotEquals($data, $newData); } - /** - * @group unit - */ + #[Group('unit')] public function testSerializedData(): void { $data = '{"user":"rolf"}'; @@ -294,9 +273,7 @@ public function testSerializedData(): void } } - /** - * @group unit - */ + #[Group('unit')] public function testUpsert(): void { $document = new Document(); @@ -312,9 +289,7 @@ public function testUpsert(): void $this->assertSame($upsert, $document->getUpsert()); } - /** - * @group unit - */ + #[Group('unit')] public function testDocAsUpsert(): void { $document = new Document(); diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php index 303dcfa55..457f273ea 100644 --- a/tests/ExampleTest.php +++ b/tests/ExampleTest.php @@ -6,6 +6,7 @@ use Elastica\Document; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * Tests the example code. @@ -14,9 +15,7 @@ */ class ExampleTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testBasicGettingStarted(): void { $client = $this->_getClient(); @@ -29,9 +28,7 @@ public function testBasicGettingStarted(): void $index->addDocument($doc); } - /** - * @group functional - */ + #[Group('functional')] public function testExample(): void { // Creates a new index 'xodoa' and a type 'user' inside this index diff --git a/tests/Exception/AbstractExceptionTest.php b/tests/Exception/AbstractExceptionTestCase.php similarity index 94% rename from tests/Exception/AbstractExceptionTest.php rename to tests/Exception/AbstractExceptionTestCase.php index 361f3ab64..6052825ef 100644 --- a/tests/Exception/AbstractExceptionTest.php +++ b/tests/Exception/AbstractExceptionTestCase.php @@ -7,7 +7,7 @@ use Elastica\Exception\ExceptionInterface; use Elastica\Test\Base as BaseTest; -abstract class AbstractExceptionTest extends BaseTest +abstract class AbstractExceptionTestCase extends BaseTest { /** * @group unit diff --git a/tests/Exception/Bulk/Response/ActionExceptionTest.php b/tests/Exception/Bulk/Response/ActionExceptionTest.php index 97059814b..1f35c8d9d 100644 --- a/tests/Exception/Bulk/Response/ActionExceptionTest.php +++ b/tests/Exception/Bulk/Response/ActionExceptionTest.php @@ -4,11 +4,11 @@ namespace Elastica\Test\Exception\Bulk\Response; -use Elastica\Test\Exception\AbstractExceptionTest; +use Elastica\Test\Exception\AbstractExceptionTestCase; /** * @internal */ -class ActionExceptionTest extends AbstractExceptionTest +class ActionExceptionTest extends AbstractExceptionTestCase { } diff --git a/tests/Exception/Bulk/ResponseExceptionTest.php b/tests/Exception/Bulk/ResponseExceptionTest.php index 4e4df8b91..0123e1ce7 100644 --- a/tests/Exception/Bulk/ResponseExceptionTest.php +++ b/tests/Exception/Bulk/ResponseExceptionTest.php @@ -4,11 +4,11 @@ namespace Elastica\Test\Exception\Bulk; -use Elastica\Test\Exception\AbstractExceptionTest; +use Elastica\Test\Exception\AbstractExceptionTestCase; /** * @internal */ -class ResponseExceptionTest extends AbstractExceptionTest +class ResponseExceptionTest extends AbstractExceptionTestCase { } diff --git a/tests/Exception/BulkExceptionTest.php b/tests/Exception/BulkExceptionTest.php index 38f8c23bf..3b661efe0 100644 --- a/tests/Exception/BulkExceptionTest.php +++ b/tests/Exception/BulkExceptionTest.php @@ -7,6 +7,6 @@ /** * @internal */ -class BulkExceptionTest extends AbstractExceptionTest +class BulkExceptionTest extends AbstractExceptionTestCase { } diff --git a/tests/Exception/ClientExceptionTest.php b/tests/Exception/ClientExceptionTest.php index 8410ba83a..68ecef3b7 100644 --- a/tests/Exception/ClientExceptionTest.php +++ b/tests/Exception/ClientExceptionTest.php @@ -7,6 +7,6 @@ /** * @internal */ -class ClientExceptionTest extends AbstractExceptionTest +class ClientExceptionTest extends AbstractExceptionTestCase { } diff --git a/tests/Exception/InvalidExceptionTest.php b/tests/Exception/InvalidExceptionTest.php index c7752116d..e85ff3d36 100644 --- a/tests/Exception/InvalidExceptionTest.php +++ b/tests/Exception/InvalidExceptionTest.php @@ -7,6 +7,6 @@ /** * @internal */ -class InvalidExceptionTest extends AbstractExceptionTest +class InvalidExceptionTest extends AbstractExceptionTestCase { } diff --git a/tests/Exception/NotFoundExceptionTest.php b/tests/Exception/NotFoundExceptionTest.php index 2fead75bb..617f8d0bc 100644 --- a/tests/Exception/NotFoundExceptionTest.php +++ b/tests/Exception/NotFoundExceptionTest.php @@ -7,6 +7,6 @@ /** * @internal */ -class NotFoundExceptionTest extends AbstractExceptionTest +class NotFoundExceptionTest extends AbstractExceptionTestCase { } diff --git a/tests/Exception/NotImplementedExceptionTest.php b/tests/Exception/NotImplementedExceptionTest.php index 890f3f233..f8e1f1b06 100644 --- a/tests/Exception/NotImplementedExceptionTest.php +++ b/tests/Exception/NotImplementedExceptionTest.php @@ -9,7 +9,7 @@ /** * @internal */ -class NotImplementedExceptionTest extends AbstractExceptionTest +class NotImplementedExceptionTest extends AbstractExceptionTestCase { /** * @group unit diff --git a/tests/Exception/QueryBuilderExceptionTest.php b/tests/Exception/QueryBuilderExceptionTest.php index 91670f9c7..ed089ec70 100644 --- a/tests/Exception/QueryBuilderExceptionTest.php +++ b/tests/Exception/QueryBuilderExceptionTest.php @@ -7,6 +7,6 @@ /** * @internal */ -class QueryBuilderExceptionTest extends AbstractExceptionTest +class QueryBuilderExceptionTest extends AbstractExceptionTestCase { } diff --git a/tests/Exception/RuntimeExceptionTest.php b/tests/Exception/RuntimeExceptionTest.php index b1980196e..6d5c752f5 100644 --- a/tests/Exception/RuntimeExceptionTest.php +++ b/tests/Exception/RuntimeExceptionTest.php @@ -7,6 +7,6 @@ /** * @internal */ -class RuntimeExceptionTest extends AbstractExceptionTest +class RuntimeExceptionTest extends AbstractExceptionTestCase { } diff --git a/tests/Index/RecoveryTest.php b/tests/Index/RecoveryTest.php index a646fe10c..b70d98042 100644 --- a/tests/Index/RecoveryTest.php +++ b/tests/Index/RecoveryTest.php @@ -6,15 +6,14 @@ use Elastica\Index\Recovery; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class RecoveryTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGetSettings(): void { $indexName = 'test'; diff --git a/tests/Index/SettingsTest.php b/tests/Index/SettingsTest.php index 192555d56..4e5227e56 100644 --- a/tests/Index/SettingsTest.php +++ b/tests/Index/SettingsTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Index\Settings as IndexSettings; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SettingsTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGet(): void { $indexName = 'elasticatest'; @@ -38,9 +37,7 @@ public function testGet(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetWithDefaultValueIncluded(): void { $indexName = 'elasticatest'; @@ -60,9 +57,7 @@ public function testGetWithDefaultValueIncluded(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetWithDefaultValueOverride(): void { $indexName = 'elasticatest'; @@ -87,9 +82,7 @@ public function testGetWithDefaultValueOverride(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetWithAlias(): void { $indexName = 'elasticatest'; @@ -115,9 +108,7 @@ public function testGetWithAlias(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testDeleteAliasWithException(): void { $indexName = 'deletetestaliasexception'; @@ -144,9 +135,7 @@ public function testDeleteAliasWithException(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testSetGetNumberOfReplicas(): void { $index = $this->_createIndex(); @@ -170,9 +159,7 @@ public function testSetGetNumberOfReplicas(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetNumberOfReplicas(): void { $index = $this->_createIndex(); @@ -189,9 +176,7 @@ public function testGetNumberOfReplicas(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetNumberOfShards(): void { $index = $this->_createIndex(); @@ -208,9 +193,7 @@ public function testGetNumberOfShards(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetDefaultNumberOfShards(): void { $index = $this->_createIndex(); @@ -228,9 +211,7 @@ public function testGetDefaultNumberOfShards(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testSetRefreshInterval(): void { $index = $this->_createIndex(); @@ -251,9 +232,7 @@ public function testSetRefreshInterval(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetRefreshInterval(): void { $index = $this->_createIndex(); @@ -274,9 +253,7 @@ public function testGetRefreshInterval(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testSetMergePolicy(): void { $index = $this->_createIndex(); @@ -297,9 +274,7 @@ public function testSetMergePolicy(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testSetMaxMergeAtOnce(): void { $index = $this->_createIndex(); @@ -322,9 +297,7 @@ public function testSetMaxMergeAtOnce(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testSetReadOnly(): void { $index = $this->_createIndex(); @@ -367,9 +340,7 @@ public function testSetReadOnly(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetSetBlocksRead(): void { $index = $this->_createIndex(); @@ -390,9 +361,7 @@ public function testGetSetBlocksRead(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetSetBlocksWrite(): void { $index = $this->_createIndex(); @@ -413,9 +382,7 @@ public function testGetSetBlocksWrite(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetSetBlocksMetadata(): void { $index = $this->_createIndex(); @@ -438,9 +405,7 @@ public function testGetSetBlocksMetadata(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testNotFoundIndex(): void { $client = $this->_getClient(); @@ -456,9 +421,7 @@ public function testNotFoundIndex(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testSetMultiple(): void { $index = $this->_createIndex(); diff --git a/tests/Index/StatsTest.php b/tests/Index/StatsTest.php index 2e2874e9f..9499b18b0 100644 --- a/tests/Index/StatsTest.php +++ b/tests/Index/StatsTest.php @@ -6,15 +6,14 @@ use Elastica\Index\Stats; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class StatsTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGetSettings(): void { $indexName = 'test'; diff --git a/tests/IndexTemplateTest.php b/tests/IndexTemplateTest.php index c0f05516f..616371ead 100644 --- a/tests/IndexTemplateTest.php +++ b/tests/IndexTemplateTest.php @@ -8,6 +8,7 @@ use Elastica\Exception\InvalidException; use Elastica\IndexTemplate; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * IndexTemplate class tests. @@ -18,9 +19,7 @@ */ class IndexTemplateTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testInstantiate(): void { $name = 'index_template1'; @@ -31,9 +30,7 @@ public function testInstantiate(): void $this->assertEquals($name, $indexTemplate->getName()); } - /** - * @group unit - */ + #[Group('unit')] public function testIncorrectInstantiate(): void { $this->expectException(InvalidException::class); @@ -42,9 +39,7 @@ public function testIncorrectInstantiate(): void new IndexTemplate($client, null); } - /** - * @group functional - */ + #[Group('functional')] public function testCreateTemplate(): void { $template = [ @@ -61,9 +56,7 @@ public function testCreateTemplate(): void $this->assertFalse($indexTemplate->exists()); } - /** - * @group functional - */ + #[Group('functional')] public function testCreateAlreadyExistsTemplateException(): void { $template = [ diff --git a/tests/IndexTest.php b/tests/IndexTest.php index 11c0f8bf5..e304bef72 100644 --- a/tests/IndexTest.php +++ b/tests/IndexTest.php @@ -16,18 +16,14 @@ use Elastica\Script\Script; use Elastica\Status; use Elastica\Test\Base as BaseTest; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class IndexTest extends BaseTest { - use ExpectDeprecationTrait; - - /** - * @group functional - */ + #[Group('functional')] public function testMapping(): void { $index = $this->_createIndex(); @@ -53,9 +49,7 @@ public function testMapping(): void $this->assertEquals('integer', $storedMapping['properties']['test']['type']); } - /** - * @group functional - */ + #[Group('functional')] public function testGetMappingAlias(): void { $index = $this->_createIndex(); @@ -82,9 +76,7 @@ public function testGetMappingAlias(): void $this->assertEquals($mapping1, $mapping2); } - /** - * @group functional - */ + #[Group('functional')] public function testAddRemoveAlias(): void { $this->expectException(ClientResponseException::class); @@ -123,9 +115,7 @@ public function testAddRemoveAlias(): void $client->getIndex($aliasName)->search('ruflin'); } - /** - * @group functional - */ + #[Group('functional')] public function testCount(): void { $index = $this->_createIndex(); @@ -149,9 +139,7 @@ public function testCount(): void $this->assertEquals(1, $index->count($query)); } - /** - * @group functional - */ + #[Group('functional')] public function testCountGet(): void { $index = $this->_createIndex(); @@ -175,9 +163,7 @@ public function testCountGet(): void $this->assertEquals(1, $index->count($query, Request::GET)); } - /** - * @group unit - */ + #[Group('unit')] public function testDeleteDocumentsSetsIndex(): void { $client = $this->createMock(Client::class); @@ -192,9 +178,7 @@ public function testDeleteDocumentsSetsIndex(): void $this->assertEquals('test', $doc2->getIndex()); } - /** - * @group functional - */ + #[Group('functional')] public function testDeleteByQueryWithQueryString(): void { $index = $this->_createIndex(); @@ -224,9 +208,7 @@ public function testDeleteByQueryWithQueryString(): void $this->assertEquals(0, $response->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testDeleteByQueryWithQuery(): void { $index = $this->_createIndex(); @@ -256,9 +238,7 @@ public function testDeleteByQueryWithQuery(): void $this->assertEquals(0, $response->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testDeleteByQueryWithArrayQuery(): void { $index = $this->_createIndex(); @@ -288,9 +268,7 @@ public function testDeleteByQueryWithArrayQuery(): void $this->assertEquals(0, $response->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testDeleteByQueryWithQueryAndOptions(): void { $index = $this->_createIndex(null, true, 2); @@ -347,9 +325,7 @@ public function testDeleteByQueryWithQueryAndOptions(): void $this->assertEquals(0, $response->count()); } - /** - * @group unit - */ + #[Group('unit')] public function testUpdateDocumentsSetsIndex(): void { $client = $this->createMock(Client::class); @@ -364,9 +340,7 @@ public function testUpdateDocumentsSetsIndex(): void $this->assertEquals('test', $doc2->getIndex()); } - /** - * @group functional - */ + #[Group('functional')] public function testUpdateByQueryWithQueryString(): void { $index = $this->_createIndex(); @@ -399,9 +373,7 @@ public function testUpdateByQueryWithQueryString(): void $this->assertEquals(0, $response->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testUpdateByQueryAll(): void { $index = $this->_createIndex(); @@ -434,9 +406,7 @@ public function testUpdateByQueryAll(): void $this->assertEquals(0, $response->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testDeleteIndexDeleteAlias(): void { $indexName = 'test'; @@ -462,9 +432,7 @@ public function testDeleteIndexDeleteAlias(): void $this->assertFalse($status->aliasExists($aliasName)); } - /** - * @group functional - */ + #[Group('functional')] public function testOpenPointInTime(): void { $index = $this->_createIndex(); @@ -477,9 +445,7 @@ public function testOpenPointInTime(): void $this->assertArrayHasKey('id', $data); } - /** - * @group functional - */ + #[Group('functional')] public function testAddAliasTwoIndices(): void { $indexName1 = 'test1'; @@ -505,9 +471,7 @@ public function testAddAliasTwoIndices(): void $this->assertTrue($index1->hasAlias($aliasName)); } - /** - * @group functional - */ + #[Group('functional')] public function testReplaceAlias(): void { $indexName1 = 'test1'; @@ -530,9 +494,7 @@ public function testReplaceAlias(): void $this->assertTrue($index1->hasAlias($aliasName)); } - /** - * @group functional - */ + #[Group('functional')] public function testAddDocumentVersion(): void { $client = $this->_getClient(); @@ -553,9 +515,7 @@ public function testAddDocumentVersion(): void $this->assertEquals(2, $data['_version']); } - /** - * @group functional - */ + #[Group('functional')] public function testAddDocumentAcrossIndices(): void { $client = $this->_getClient(); @@ -575,9 +535,7 @@ public function testAddDocumentAcrossIndices(): void $this->assertEquals('Hello world', $index2Doc->get('title')); } - /** - * @group functional - */ + #[Group('functional')] public function testClearCache(): void { $index = $this->_createIndex(); @@ -585,9 +543,7 @@ public function testClearCache(): void $this->assertFalse($response->hasError()); } - /** - * @group functional - */ + #[Group('functional')] public function testFlush(): void { $index = $this->_createIndex(); @@ -595,9 +551,7 @@ public function testFlush(): void $this->assertFalse($response->hasError()); } - /** - * @group functional - */ + #[Group('functional')] public function testExists(): void { $index = $this->_createIndex(); @@ -615,9 +569,8 @@ public function testExists(): void * Tests if deleting an index that does not exist in Elasticsearch, * correctly returns a boolean true from the hasError() method of * the \Elastica\Response object - * - * @group functional */ + #[Group('functional')] public function testDeleteMissingIndexHasError(): void { $client = $this->_getClient(); @@ -633,9 +586,8 @@ public function testDeleteMissingIndexHasError(): void /** * Tests to see if the test type mapping exists when calling $index->getMapping(). - * - * @group functional */ + #[Group('functional')] public function testIndexGetMapping(): void { $index = $this->_createIndex(); @@ -657,9 +609,7 @@ public function testIndexGetMapping(): void $this->assertEquals('integer', $indexMappings['properties']['test']['type']); } - /** - * @group functional - */ + #[Group('functional')] public function testEmptyIndexGetMapping(): void { $indexMappings = $this->_createIndex()->getMapping(); @@ -669,9 +619,8 @@ public function testEmptyIndexGetMapping(): void /** * Test to see if search Default Limit works. - * - * @group functional */ + #[Group('functional')] public function testLimitDefaultIndex(): void { $client = $this->_getClient(); @@ -703,9 +652,7 @@ public function testLimitDefaultIndex(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testCreate(): void { $client = $this->_getClient(); @@ -727,9 +674,7 @@ public function testCreate(): void $this->assertTrue($status->indexExists($indexName)); } - /** - * @group unit - */ + #[Group('unit')] public function testCreateSearch(): void { $client = $this->createMock(Client::class); @@ -753,9 +698,7 @@ public function testCreateSearch(): void $this->assertTrue($search->hasIndex($index)); } - /** - * @group functional - */ + #[Group('functional')] public function testSearch(): void { $index = $this->_createIndex(); @@ -783,9 +726,7 @@ public function testSearch(): void $this->assertEquals(3, $count); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchGet(): void { $index = $this->_createIndex(); @@ -801,9 +742,7 @@ public function testSearchGet(): void $this->assertEquals(1, $count); } - /** - * @group functional - */ + #[Group('functional')] public function testForcemerge(): void { $client = $this->_getClient(); @@ -849,9 +788,7 @@ public function testForcemerge(): void $this->assertSame(0, $stats['_all']['primaries']['docs']['deleted']); } - /** - * @group functional - */ + #[Group('functional')] public function testAnalyze(): void { $index = $this->_createIndex(); @@ -871,9 +808,7 @@ public function testAnalyze(): void $this->assertEquals($tokens, $returnedTokens); } - /** - * @group functional - */ + #[Group('functional')] public function testRequestEndpoint(): void { $index = $this->_createIndex(); @@ -895,9 +830,7 @@ public function testRequestEndpoint(): void $this->assertEquals($tokens, $returnedTokens); } - /** - * @group functional - */ + #[Group('functional')] public function testAnalyzeExplain(): void { $index = $this->_createIndex(); @@ -907,9 +840,7 @@ public function testAnalyzeExplain(): void $this->assertArrayHasKey('custom_analyzer', $data); } - /** - * @group functional - */ + #[Group('functional')] public function testGetEmptyAliases(): void { $indexName = 'test-getaliases'; diff --git a/tests/MappingTest.php b/tests/MappingTest.php index 1f70565a3..5eb6143e9 100644 --- a/tests/MappingTest.php +++ b/tests/MappingTest.php @@ -9,15 +9,14 @@ use Elastica\Query; use Elastica\Query\QueryString; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class MappingTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testMappingStoreFields(): void { $client = $this->_getClient(); @@ -68,9 +67,7 @@ public function testMappingStoreFields(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testNestedMapping(): void { $client = $this->_getClient(); @@ -110,9 +107,7 @@ public function testNestedMapping(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testJoinMapping(): void { $client = $this->_getClient(); @@ -191,9 +186,7 @@ public function testJoinMapping(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testMappingExample(): void { $index = $this->_createIndex(); @@ -232,13 +225,11 @@ public function testMappingExample(): void } /** - * @group functional - * - * Test setting a dynamic template and validate whether the right mapping is applied after adding a document which - * should match the dynamic template. - * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html */ + #[Group('functional +Test setting a dynamic template and validate whether the right mapping is applied after adding a document which +should match the dynamic template.')] public function testDynamicTemplate(): void { $index = $this->_createIndex(); @@ -281,9 +272,7 @@ public function testDynamicTemplate(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testSetMeta(): void { $index = $this->_createIndex(); @@ -301,9 +290,7 @@ public function testSetMeta(): void $index->delete(); } - /** - * @group functional - */ + #[Group('functional')] public function testGetters(): void { $properties = [ diff --git a/tests/Multi/MultiBuilderTest.php b/tests/Multi/MultiBuilderTest.php index 5f6419309..225fb337b 100644 --- a/tests/Multi/MultiBuilderTest.php +++ b/tests/Multi/MultiBuilderTest.php @@ -10,24 +10,22 @@ use Elastica\ResultSet\BuilderInterface; use Elastica\Search; use Elastica\Test\Base as BaseTest; +use Elastica\Test\WithConsecutive; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; /** - * @group unit - * * @internal */ +#[Group('unit')] class MultiBuilderTest extends BaseTest { /** * @var BuilderInterface&MockObject */ - private $builder; + private MockObject $builder; - /** - * @var MultiBuilder - */ - private $multiBuilder; + private MultiBuilder $multiBuilder; protected function setUp(): void { @@ -70,10 +68,10 @@ public function testBuildMultiResultSet(): void $this->builder->expects($this->exactly(2)) ->method('buildResultSet') - ->withConsecutive( + ->with(...WithConsecutive::create( [$this->isInstanceOf(Response::class), $s1->getQuery()], [$this->isInstanceOf(Response::class), $s2->getQuery()] - ) + )) ->willReturnOnConsecutiveCalls($resultSet1, $resultSet2) ; diff --git a/tests/Multi/SearchTest.php b/tests/Multi/SearchTest.php index d59570a69..4fa440031 100644 --- a/tests/Multi/SearchTest.php +++ b/tests/Multi/SearchTest.php @@ -13,15 +13,14 @@ use Elastica\ResultSet; use Elastica\Search; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SearchTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $client = $this->_getClient(); @@ -30,9 +29,7 @@ public function testConstruct(): void $this->assertSame($client, $multiSearch->getClient()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetSearches(): void { $client = $this->_getClient(); @@ -62,9 +59,7 @@ public function testSetSearches(): void $this->assertCount(0, $searches); } - /** - * @group unit - */ + #[Group('unit')] public function testSetSearchesByKeys(): void { $client = $this->_getClient(); @@ -94,9 +89,7 @@ public function testSetSearchesByKeys(): void $this->assertCount(0, $searches); } - /** - * @group functional - */ + #[Group('functional')] public function testSearch(): void { $index = $this->_createIndex(); @@ -182,9 +175,7 @@ public function testSearch(): void $this->assertEquals(6, $resultSets[1]->getTotalHits()); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchWithKeys(): void { $index = $this->_createIndex(); @@ -272,9 +263,7 @@ public function testSearchWithKeys(): void $this->assertEquals(6, $resultSets['search2']->getTotalHits()); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchWithError(): void { $index = $this->_createIndex(); @@ -317,9 +306,7 @@ public function testSearchWithError(): void $this->assertTrue($multiResultSet->hasError()); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchWithErrorWithKeys(): void { $index = $this->_createIndex(); @@ -362,9 +349,7 @@ public function testSearchWithErrorWithKeys(): void $this->assertTrue($multiResultSet->hasError()); } - /** - * @group functional - */ + #[Group('functional')] public function testGlobalSearchTypeSearch(): void { $index = $this->_createIndex(); @@ -442,9 +427,7 @@ public function testGlobalSearchTypeSearch(): void $this->assertEquals(6, $resultSets[1]->getTotalHits()); } - /** - * @group functional - */ + #[Group('functional')] public function testGlobalSearchTypeSearchWithKeys(): void { $index = $this->_createIndex(); diff --git a/tests/Node/InfoTest.php b/tests/Node/InfoTest.php index 0ce429abb..1a0510000 100644 --- a/tests/Node/InfoTest.php +++ b/tests/Node/InfoTest.php @@ -7,15 +7,14 @@ use Elastica\Node; use Elastica\Node\Info as NodeInfo; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class InfoTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGet(): void { $client = $this->_getClient(); @@ -37,9 +36,7 @@ public function testGet(): void $this->assertNull($info->get('test', 'notest', 'notexist')); } - /** - * @group functional - */ + #[Group('functional')] public function testHasPlugin(): void { $client = $this->_getClient(); @@ -56,9 +53,7 @@ public function testHasPlugin(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testGetId(): void { $client = $this->_getClient(); @@ -75,9 +70,7 @@ public function testGetId(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testGetName(): void { $client = $this->_getClient(); @@ -92,9 +85,7 @@ public function testGetName(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testParams(): void { $client = $this->_getClient(); diff --git a/tests/NodeTest.php b/tests/NodeTest.php index 1d1be7ab1..186202487 100644 --- a/tests/NodeTest.php +++ b/tests/NodeTest.php @@ -6,15 +6,14 @@ use Elastica\Node; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class NodeTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testCreateNode(): void { $client = $this->_getClient(); @@ -25,9 +24,7 @@ public function testCreateNode(): void $this->assertSame($name, $node->getId()); } - /** - * @group functional - */ + #[Group('functional')] public function testGetInfo(): void { $client = $this->_getClient(); @@ -41,9 +38,7 @@ public function testGetInfo(): void $this->assertSame($node, $info->getNode()); } - /** - * @group functional - */ + #[Group('functional')] public function testGetStats(): void { $client = $this->_getClient(); @@ -57,9 +52,7 @@ public function testGetStats(): void $this->assertSame($node, $stats->getNode()); } - /** - * @group functional - */ + #[Group('functional')] public function testGetName(): void { $client = $this->_getClient(); diff --git a/tests/ParamTest.php b/tests/ParamTest.php index bd1668d45..569b33bbe 100644 --- a/tests/ParamTest.php +++ b/tests/ParamTest.php @@ -7,15 +7,14 @@ use Elastica\Exception\InvalidException; use Elastica\Param; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ParamTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArrayEmpty(): void { $param = new Param(); @@ -23,9 +22,7 @@ public function testToArrayEmpty(): void $this->assertEquals(['param' => []], $param->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetParams(): void { $param = new Param(); @@ -36,9 +33,7 @@ public function testSetParams(): void $this->assertEquals(['param' => $params], $param->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetGetParam(): void { $param = new Param(); @@ -53,9 +48,7 @@ public function testSetGetParam(): void $this->assertEquals($value, $param->getParam($key)); } - /** - * @group unit - */ + #[Group('unit')] public function testAddParam(): void { $param = new Param(); @@ -69,9 +62,7 @@ public function testAddParam(): void $this->assertEquals([$value], $param->getParam($key)); } - /** - * @group unit - */ + #[Group('unit')] public function testAddParam2(): void { $param = new Param(); @@ -87,9 +78,7 @@ public function testAddParam2(): void $this->assertEquals([$value1, $value2], $param->getParam($key)); } - /** - * @group unit - */ + #[Group('unit')] public function testGetParamInvalid(): void { $this->expectException(InvalidException::class); @@ -99,9 +88,7 @@ public function testGetParamInvalid(): void $param->getParam('notest'); } - /** - * @group unit - */ + #[Group('unit')] public function testHasParam(): void { $param = new Param(); diff --git a/tests/PipelineTest.php b/tests/PipelineTest.php index 1c81de5ab..4ccc65092 100644 --- a/tests/PipelineTest.php +++ b/tests/PipelineTest.php @@ -12,15 +12,14 @@ use Elastica\Processor\RenameProcessor; use Elastica\Processor\SetProcessor; use Elastica\Processor\TrimProcessor; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class PipelineTest extends BasePipeline { - /** - * @group unit - */ + #[Group('unit')] public function testProcessor(): void { $trim = new TrimProcessor('field1'); @@ -60,9 +59,7 @@ public function testProcessor(): void $this->assertEquals($expected, $processors->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testPipelineCreate(): void { $set = new SetProcessor('field4', 333); @@ -89,9 +86,7 @@ public function testPipelineCreate(): void $this->assertSame('foo', $result['my_custom_pipeline']['processors'][2]['rename']['field']); } - /** - * @group functional - */ + #[Group('functional')] public function testPipelineonIndex(): void { $set = new SetProcessor('foo', 333); @@ -131,9 +126,7 @@ public function testPipelineonIndex(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testDeletePipeline(): void { $pipeline = $this->_createPipeline(); diff --git a/tests/PointInTimeTest.php b/tests/PointInTimeTest.php index 822465e90..779201a8a 100644 --- a/tests/PointInTimeTest.php +++ b/tests/PointInTimeTest.php @@ -5,15 +5,14 @@ namespace Elastica\Test; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class PointInTimeTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testOpenClosePointInTime(): void { $index = $this->_createIndex(); diff --git a/tests/Processor/AppendProcessorTest.php b/tests/Processor/AppendProcessorTest.php index e15cb87be..48c2d5721 100644 --- a/tests/Processor/AppendProcessorTest.php +++ b/tests/Processor/AppendProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\AppendProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class AppendProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testAppendSingleValue(): void { $processor = new AppendProcessor('field1', 'item2'); @@ -31,9 +30,7 @@ public function testAppendSingleValue(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testAppendArray(): void { $processor = new AppendProcessor('field1', ['item2', 'item3', 'item4']); @@ -48,9 +45,7 @@ public function testAppendArray(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testAppend(): void { $append = new AppendProcessor('foo', ['item2', 'item3', 'item4']); diff --git a/tests/Processor/AttachmentProcessorTest.php b/tests/Processor/AttachmentProcessorTest.php index f76b48b7b..553c5825e 100644 --- a/tests/Processor/AttachmentProcessorTest.php +++ b/tests/Processor/AttachmentProcessorTest.php @@ -9,15 +9,14 @@ use Elastica\Mapping; use Elastica\Processor\AttachmentProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class AttachmentProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testAttachment(): void { $processor = new AttachmentProcessor('data'); @@ -31,9 +30,7 @@ public function testAttachment(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testAttachmentWithNonDefaultOptions(): void { $processor = new AttachmentProcessor('data'); @@ -55,9 +52,7 @@ public function testAttachmentWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testAttachmentAddPdf(): void { $attachment = new AttachmentProcessor('data'); @@ -97,9 +92,7 @@ public function testAttachmentAddPdf(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testAttachmentAddPdfFileContent(): void { $attachment = new AttachmentProcessor('data'); @@ -142,9 +135,7 @@ public function testAttachmentAddPdfFileContent(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testAddWordxFile(): void { $attachment = new AttachmentProcessor('data'); @@ -185,9 +176,7 @@ public function testAddWordxFile(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testExcludeFileSource(): void { $attachment = new AttachmentProcessor('data'); diff --git a/tests/Processor/BytesProcessorTest.php b/tests/Processor/BytesProcessorTest.php index 0a36184c9..4f8420587 100644 --- a/tests/Processor/BytesProcessorTest.php +++ b/tests/Processor/BytesProcessorTest.php @@ -6,15 +6,14 @@ use Elastica\Processor\BytesProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class BytesProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testBytes(): void { $processor = new BytesProcessor('foo'); @@ -28,9 +27,7 @@ public function testBytes(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testBytesWithTargetField(): void { $processor = (new BytesProcessor('foo')) @@ -47,9 +44,7 @@ public function testBytesWithTargetField(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testBytesWithNonDefaultOptions(): void { $processor = (new BytesProcessor('foo')) diff --git a/tests/Processor/ConvertProcessorTest.php b/tests/Processor/ConvertProcessorTest.php index 460a53856..5b28bc338 100644 --- a/tests/Processor/ConvertProcessorTest.php +++ b/tests/Processor/ConvertProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\ConvertProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ConvertProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testConvert(): void { $processor = new ConvertProcessor('foo', 'integer'); @@ -31,9 +30,7 @@ public function testConvert(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testConvertWithNonDefaultOptions(): void { $processor = (new ConvertProcessor('foo', 'integer')) @@ -67,9 +64,7 @@ public function testConvertWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testConvertField(): void { $append = new ConvertProcessor('foo', 'float'); diff --git a/tests/Processor/DateIndexNameProcessorTest.php b/tests/Processor/DateIndexNameProcessorTest.php index 5fbaff830..e218de643 100644 --- a/tests/Processor/DateIndexNameProcessorTest.php +++ b/tests/Processor/DateIndexNameProcessorTest.php @@ -6,15 +6,14 @@ use Elastica\Processor\DateIndexNameProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class DateIndexNameProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testDateIndexName(): void { $processor = new DateIndexNameProcessor('date1', 'M'); @@ -29,9 +28,7 @@ public function testDateIndexName(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testDateIndexNameWithNonDefaultOptions(): void { $processor = (new DateIndexNameProcessor('date1', 'M')) diff --git a/tests/Processor/DateProcessorTest.php b/tests/Processor/DateProcessorTest.php index 998d96461..44552951a 100644 --- a/tests/Processor/DateProcessorTest.php +++ b/tests/Processor/DateProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\DateProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class DateProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testDate(): void { $processor = new DateProcessor('initial_date', ['dd/MM/yyyy hh:mm:ss']); @@ -42,9 +41,7 @@ public function testDate(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testDateWithNonDefaultOptions(): void { $processor = (new DateProcessor('initial_date', ['dd/MM/yyyy hh:mm:ss', 'ISO8601', 'UNIX', 'UNIX_MS'])) @@ -68,9 +65,7 @@ public function testDateWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testDateField(): void { $date = new DateProcessor('date_field', ['yyyy dd MM hh:mm:ss']); diff --git a/tests/Processor/DotExpanderProcessorTest.php b/tests/Processor/DotExpanderProcessorTest.php index 33039b8ba..ad967c006 100644 --- a/tests/Processor/DotExpanderProcessorTest.php +++ b/tests/Processor/DotExpanderProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\DotExpanderProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class DotExpanderProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testDotExpander(): void { $processor = new DotExpanderProcessor('foo.bar'); @@ -30,9 +29,7 @@ public function testDotExpander(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testDotExpanderWithNonDefaultOptions(): void { $processor = (new DotExpanderProcessor('foo.bar')) @@ -49,9 +46,7 @@ public function testDotExpanderWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testDotExpanderField(): void { $dotExpander = new DotExpanderProcessor('foo.bar'); diff --git a/tests/Processor/FailProcessorTest.php b/tests/Processor/FailProcessorTest.php index bffd2cae5..1b5aa1185 100644 --- a/tests/Processor/FailProcessorTest.php +++ b/tests/Processor/FailProcessorTest.php @@ -9,15 +9,14 @@ use Elastica\Processor\FailProcessor; use Elastica\Processor\JsonProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class FailProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testFail(): void { $processor = new FailProcessor('This is a custom fail message for processor'); @@ -31,9 +30,7 @@ public function testFail(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testFailWithNonDefaultOptions(): void { $processor = (new FailProcessor('This is a custom fail message for processor')) @@ -50,9 +47,7 @@ public function testFailWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testFailField(): void { $fail = new FailProcessor('custom error fail message'); diff --git a/tests/Processor/ForeachProcessorTest.php b/tests/Processor/ForeachProcessorTest.php index 95a0bc251..054defcf2 100644 --- a/tests/Processor/ForeachProcessorTest.php +++ b/tests/Processor/ForeachProcessorTest.php @@ -9,15 +9,14 @@ use Elastica\Processor\ForeachProcessor; use Elastica\Processor\UppercaseProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ForeachProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testForeachProcessorDefault(): void { $subprocessor = new UppercaseProcessor('field2'); @@ -37,9 +36,7 @@ public function testForeachProcessorDefault(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testForeachRawProcessorDefault(): void { $subprocessor = [ @@ -63,9 +60,7 @@ public function testForeachRawProcessorDefault(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testForeachProcessorIgnoreMissing(): void { $subprocessor = new UppercaseProcessor('field2'); @@ -87,9 +82,7 @@ public function testForeachProcessorIgnoreMissing(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testForeachProcessor(): void { $subprocessor = new UppercaseProcessor('_ingest._value'); diff --git a/tests/Processor/JoinProcessorTest.php b/tests/Processor/JoinProcessorTest.php index 5f7e50d06..1e418f2f1 100644 --- a/tests/Processor/JoinProcessorTest.php +++ b/tests/Processor/JoinProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\JoinProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class JoinProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testJoin(): void { $processor = new JoinProcessor('joined_array_field', '-'); @@ -31,9 +30,7 @@ public function testJoin(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testJoinWithNonDefaultOptions(): void { $processor = (new JoinProcessor('joined_array_field', '-')) @@ -51,9 +48,7 @@ public function testJoinWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testJoinField(): void { $join = new JoinProcessor('name', '-'); diff --git a/tests/Processor/JsonProcessorTest.php b/tests/Processor/JsonProcessorTest.php index 36555e600..b4e8f17d6 100644 --- a/tests/Processor/JsonProcessorTest.php +++ b/tests/Processor/JsonProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\JsonProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class JsonProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testJson(): void { $processor = new JsonProcessor('string_source'); @@ -30,9 +29,7 @@ public function testJson(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testJsonWithNonDefaultOptions(): void { $processor = (new JsonProcessor('string_source')) @@ -53,9 +50,7 @@ public function testJsonWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testJsonField(): void { $json = new JsonProcessor('name'); diff --git a/tests/Processor/KvProcessorTest.php b/tests/Processor/KvProcessorTest.php index 6a393fa57..02bb8a069 100644 --- a/tests/Processor/KvProcessorTest.php +++ b/tests/Processor/KvProcessorTest.php @@ -6,15 +6,14 @@ use Elastica\Processor\KvProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class KvProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testKv(): void { $processor = new KvProcessor('message', ' ', '='); @@ -30,9 +29,7 @@ public function testKv(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testKvWithNonDefaultOptions(): void { $processor = (new KvProcessor('message', ' ', '=')) @@ -59,9 +56,7 @@ public function testKvWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testKVIncludeExludeKeys(): void { $kv = new KvProcessor('field1', '&', '='); diff --git a/tests/Processor/LowercaseProcessorTest.php b/tests/Processor/LowercaseProcessorTest.php index 158d26827..861ff6485 100644 --- a/tests/Processor/LowercaseProcessorTest.php +++ b/tests/Processor/LowercaseProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\LowercaseProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class LowercaseProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testLowercase(): void { $processor = new LowercaseProcessor('foo'); @@ -30,9 +29,7 @@ public function testLowercase(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testLowercaseWithNonDefaultOptions(): void { $processor = (new LowercaseProcessor('foo')) @@ -51,9 +48,7 @@ public function testLowercaseWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testLowercaseField(): void { $lcase = new LowercaseProcessor('name'); diff --git a/tests/Processor/RemoveProcessorTest.php b/tests/Processor/RemoveProcessorTest.php index 4c8fd05b3..0f3ab48e5 100644 --- a/tests/Processor/RemoveProcessorTest.php +++ b/tests/Processor/RemoveProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\RemoveProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class RemoveProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testRemove(): void { $processor = new RemoveProcessor('foo'); @@ -30,9 +29,7 @@ public function testRemove(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testRemoveWithNonDefaultOptions(): void { $processor = (new RemoveProcessor('foo')) @@ -51,9 +48,7 @@ public function testRemoveWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testRemoveArray(): void { $processor = new RemoveProcessor(['foo', 'bar']); @@ -67,9 +62,7 @@ public function testRemoveArray(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testRemoveField(): void { $remove = new RemoveProcessor(['es_version', 'package']); diff --git a/tests/Processor/RenameProcessorTest.php b/tests/Processor/RenameProcessorTest.php index 6f7e26430..8eb5472c9 100644 --- a/tests/Processor/RenameProcessorTest.php +++ b/tests/Processor/RenameProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\RenameProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class RenameProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testRename(): void { $processor = new RenameProcessor('foo', 'foobar'); @@ -31,9 +30,7 @@ public function testRename(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testRenameWithNonDefaultOptions(): void { $processor = (new RenameProcessor('foo', 'foobar')) @@ -53,9 +50,7 @@ public function testRenameWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testRenameField(): void { $rename = new RenameProcessor('package', 'packages'); diff --git a/tests/Processor/SetProcessorTest.php b/tests/Processor/SetProcessorTest.php index bcddb236a..74b8dc9ef 100644 --- a/tests/Processor/SetProcessorTest.php +++ b/tests/Processor/SetProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\SetProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SetProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testSet(): void { $processor = new SetProcessor('field1', 582.1); @@ -31,9 +30,7 @@ public function testSet(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetWithNonDefaultOptions(): void { $processor = (new SetProcessor('field1', 582.1)) @@ -53,9 +50,7 @@ public function testSetWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetField(): void { $set = new SetProcessor('package', 'Elastica'); diff --git a/tests/Processor/SortProcessorTest.php b/tests/Processor/SortProcessorTest.php index 1850158c4..41816ad69 100644 --- a/tests/Processor/SortProcessorTest.php +++ b/tests/Processor/SortProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\SortProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SortProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testSort(): void { $processor = new SortProcessor('field_to_sort'); @@ -30,9 +29,7 @@ public function testSort(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSortWithNonDefaultOptions(): void { $processor = (new SortProcessor('field_to_sort')) @@ -51,9 +48,7 @@ public function testSortWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSortField(): void { $sort = new SortProcessor('name'); diff --git a/tests/Processor/SplitProcessorTest.php b/tests/Processor/SplitProcessorTest.php index 5a030d7ac..93d148a88 100644 --- a/tests/Processor/SplitProcessorTest.php +++ b/tests/Processor/SplitProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\SplitProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SplitProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testSplit(): void { $processor = new SplitProcessor('joined_array_field', '-'); @@ -31,9 +30,7 @@ public function testSplit(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSplitWithNonDefaultOptions(): void { $processor = (new SplitProcessor('joined_array_field', '-')) @@ -53,9 +50,7 @@ public function testSplitWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSplitField(): void { $split = new SplitProcessor('name', '&'); diff --git a/tests/Processor/TrimProcessorTest.php b/tests/Processor/TrimProcessorTest.php index 3a4e9cb65..def6862f0 100644 --- a/tests/Processor/TrimProcessorTest.php +++ b/tests/Processor/TrimProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\TrimProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class TrimProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testTrim(): void { $processor = new TrimProcessor('foo'); @@ -30,9 +29,7 @@ public function testTrim(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testTrimWithNonDefaultOptions(): void { $processor = (new TrimProcessor('foo')) @@ -51,9 +48,7 @@ public function testTrimWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testTrimField(): void { $trim = new TrimProcessor('name'); diff --git a/tests/Processor/UppercaseProcessorTest.php b/tests/Processor/UppercaseProcessorTest.php index ee6208b52..497404825 100644 --- a/tests/Processor/UppercaseProcessorTest.php +++ b/tests/Processor/UppercaseProcessorTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Processor\UppercaseProcessor; use Elastica\Test\BasePipeline as BasePipelineTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class UppercaseProcessorTest extends BasePipelineTest { - /** - * @group unit - */ + #[Group('unit')] public function testUppercase(): void { $processor = new UppercaseProcessor('foo'); @@ -30,9 +29,7 @@ public function testUppercase(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testUppercaseWithNonDefaultOptions(): void { $processor = (new UppercaseProcessor('foo')) @@ -51,9 +48,7 @@ public function testUppercaseWithNonDefaultOptions(): void $this->assertEquals($expected, $processor->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testUppercaseField(): void { $ucase = new UppercaseProcessor('name'); diff --git a/tests/Query/BoolQueryTest.php b/tests/Query/BoolQueryTest.php index 4bc04cc81..6829d5690 100644 --- a/tests/Query/BoolQueryTest.php +++ b/tests/Query/BoolQueryTest.php @@ -10,15 +10,14 @@ use Elastica\Query\Ids; use Elastica\Query\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class BoolQueryTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new BoolQuery(); @@ -67,9 +66,8 @@ public function testToArray(): void * Test to resolve the following issue. * * @see https://groups.google.com/forum/?fromgroups#!topic/elastica-php-client/zK_W_hClfvU - * - * @group unit */ + #[Group('unit')] public function testToArrayStructure(): void { $boolQuery = new BoolQuery(); @@ -86,9 +84,7 @@ public function testToArrayStructure(): void $this->assertEquals($jsonString, \json_encode($boolQuery->toArray())); } - /** - * @group functional - */ + #[Group('functional')] public function testSearch(): void { $client = $this->_getClient(); @@ -141,9 +137,7 @@ public function testSearch(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testEmptyBoolQuery(): void { $index = $this->_createIndex(); diff --git a/tests/Query/BoostingTest.php b/tests/Query/BoostingTest.php index d0a846f08..b65c9f7c8 100644 --- a/tests/Query/BoostingTest.php +++ b/tests/Query/BoostingTest.php @@ -7,15 +7,14 @@ use Elastica\Query\Boosting; use Elastica\Query\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class BoostingTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $keyword = 'vital'; @@ -38,9 +37,7 @@ public function testToArray(): void $this->assertEquals($expected, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testNegativeBoost(): void { $keyword = 'vital'; diff --git a/tests/Query/CombinedFieldsQueryTest.php b/tests/Query/CombinedFieldsQueryTest.php index f10d96340..7311d1b6e 100644 --- a/tests/Query/CombinedFieldsQueryTest.php +++ b/tests/Query/CombinedFieldsQueryTest.php @@ -11,6 +11,7 @@ use Elastica\Query\CombinedFields; use Elastica\ResultSet; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -24,9 +25,7 @@ class CombinedFieldsQueryTest extends BaseTest ['id' => '4', 'title' => 'John', 'body' => 'not Doe', 'abstract' => 'Consectetur'], ]; - /** - * @group functional - */ + #[Group('functional')] public function testMinimumShouldMatch(): void { // Note that the OR operator is the default. @@ -39,9 +38,7 @@ public function testMinimumShouldMatch(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testAndOperator(): void { $combinedFields = new CombinedFields(); @@ -53,9 +50,7 @@ public function testAndOperator(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testZeroTerm(): void { $combinedFields = new CombinedFields(); @@ -72,9 +67,7 @@ public function testZeroTerm(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testBaseCombinedFields(): void { $combinedFields = new CombinedFields(); diff --git a/tests/Query/ConstantScoreTest.php b/tests/Query/ConstantScoreTest.php index 87a1986aa..15d7dc7ca 100644 --- a/tests/Query/ConstantScoreTest.php +++ b/tests/Query/ConstantScoreTest.php @@ -7,15 +7,14 @@ use Elastica\Query\ConstantScore; use Elastica\Query\Ids; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ConstantScoreTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new ConstantScore(); @@ -36,9 +35,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $filter = new Ids(); @@ -55,9 +52,7 @@ public function testConstruct(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructEmpty(): void { $query = new ConstantScore(); diff --git a/tests/Query/DisMaxTest.php b/tests/Query/DisMaxTest.php index f84d27123..52062bb8f 100644 --- a/tests/Query/DisMaxTest.php +++ b/tests/Query/DisMaxTest.php @@ -9,15 +9,14 @@ use Elastica\Query\Ids; use Elastica\Query\QueryString; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class DisMaxTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new DisMax(); @@ -55,9 +54,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testQuery(): void { $index = $this->_createIndex(); @@ -87,9 +84,7 @@ public function testQuery(): void $this->assertEquals(3, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testQueryArray(): void { $index = $this->_createIndex(); diff --git a/tests/Query/DistanceFeatureTest.php b/tests/Query/DistanceFeatureTest.php index 88b3ff812..413f5e403 100644 --- a/tests/Query/DistanceFeatureTest.php +++ b/tests/Query/DistanceFeatureTest.php @@ -6,15 +6,14 @@ use Elastica\Query\DistanceFeature; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class DistanceFeatureTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArrayDate(): void { $query = new DistanceFeature('field_date', 'now', '7d'); @@ -30,9 +29,7 @@ public function testToArrayDate(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testToArrayGeoPoint(): void { $query = new DistanceFeature('field_geo_point', [-71.3, 41.15], '1000m'); @@ -48,9 +45,7 @@ public function testToArrayGeoPoint(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetBoost(): void { $query = new DistanceFeature('field_date', 'now', '7d'); diff --git a/tests/Query/EscapeStringTest.php b/tests/Query/EscapeStringTest.php index 2db43b5bc..d0be03e12 100644 --- a/tests/Query/EscapeStringTest.php +++ b/tests/Query/EscapeStringTest.php @@ -8,15 +8,14 @@ use Elastica\Query\QueryString; use Elastica\Test\Base as BaseTest; use Elastica\Util; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class EscapeStringTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testSearch(): void { $index = $this->_createIndex(); diff --git a/tests/Query/ExistsTest.php b/tests/Query/ExistsTest.php index 842e26522..83ec32d4c 100644 --- a/tests/Query/ExistsTest.php +++ b/tests/Query/ExistsTest.php @@ -6,15 +6,14 @@ use Elastica\Query\Exists; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ExistsTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $field = 'test'; @@ -24,9 +23,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetField(): void { $field = 'test'; diff --git a/tests/Query/FunctionScoreTest.php b/tests/Query/FunctionScoreTest.php index daf25b9dc..dd0207274 100644 --- a/tests/Query/FunctionScoreTest.php +++ b/tests/Query/FunctionScoreTest.php @@ -12,6 +12,7 @@ use Elastica\Query\Term; use Elastica\Script\Script; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -20,9 +21,7 @@ class FunctionScoreTest extends BaseTest { protected $locationOrigin = '32.804654, -117.242594'; - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $priceOrigin = 0; @@ -59,9 +58,7 @@ public function testToArray(): void $this->assertEquals($expected, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testDecayWeight(): void { $priceOrigin = 0; @@ -122,9 +119,7 @@ public function testDecayWeight(): void $this->assertEquals($expected, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testGauss(): void { $query = new FunctionScore(); @@ -138,9 +133,7 @@ public function testGauss(): void $this->assertEquals("Mr. Frostie's", $result0['name']); } - /** - * @group functional - */ + #[Group('functional')] public function testGaussMultiValue(): void { $query = new FunctionScore(); @@ -163,9 +156,7 @@ public function testGaussMultiValue(): void $this->assertEquals("Miller's Field", $result0['name']); } - /** - * @group unit - */ + #[Group('unit')] public function testAddWeightFunction(): void { $filter = new Term(['price' => 4.5]); @@ -179,9 +170,7 @@ public function testAddWeightFunction(): void $this->assertEquals($query->toArray(), $sameQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testLegacyFilterAddWeightFunction(): void { $query = new FunctionScore(); @@ -195,9 +184,7 @@ public function testLegacyFilterAddWeightFunction(): void $this->assertEquals($query->toArray(), $sameQuery->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testWeight(): void { $filter = new Term(['price' => 4.5]); @@ -229,9 +216,7 @@ public function testWeight(): void $this->assertEquals("Mr. Frostie's", $result0['name']); } - /** - * @group functional - */ + #[Group('functional')] public function testWeightWithLegacyFilter(): void { $filter = new Term(['price' => 4.5]); @@ -263,9 +248,7 @@ public function testWeightWithLegacyFilter(): void $this->assertEquals("Mr. Frostie's", $result0['name']); } - /** - * @group functional - */ + #[Group('functional')] public function testRandomScore(): void { $filter = new Term(['price' => 4.5]); @@ -301,9 +284,7 @@ public function testRandomScore(): void $this->assertEquals("Miller's Field", $result0['name']); } - /** - * @group functional - */ + #[Group('functional')] public function testRandomScoreWithLegacyFilter(): void { $filter = new Term(['price' => 4.5]); @@ -339,9 +320,7 @@ public function testRandomScoreWithLegacyFilter(): void $this->assertEquals("Miller's Field", $result0['name']); } - /** - * @group unit - */ + #[Group('unit')] public function testRandomScoreWeight(): void { $filter = new Term(['price' => 4.5]); @@ -370,9 +349,7 @@ public function testRandomScoreWeight(): void $this->assertEquals($expected, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testRandomScoreWeightWithLegacyFilter(): void { $filter = new Term(['price' => 4.5]); @@ -401,9 +378,7 @@ public function testRandomScoreWeightWithLegacyFilter(): void $this->assertEquals($expected, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testRandomScoreWithoutSeed(): void { $query = new FunctionScore(); @@ -414,9 +389,7 @@ public function testRandomScoreWithoutSeed(): void $this->assertEquals(2, $response->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testRandomScoreWithoutField(): void { $filter = new Term(['price' => 4.5]); @@ -451,9 +424,7 @@ public function testRandomScoreWithoutField(): void $this->assertEquals("Miller's Field", $result0['name']); } - /** - * @group functional - */ + #[Group('functional')] public function testScriptScore(): void { $scriptString = "_score * doc['price'].value"; @@ -485,9 +456,7 @@ public function testScriptScore(): void $this->assertEquals("Miller's Field", $result0['name']); } - /** - * @group functional - */ + #[Group('functional')] public function testSetMinScore(): void { $expected = [ @@ -520,9 +489,7 @@ public function testSetMinScore(): void $this->assertEquals(1, $results[0]->getId()); } - /** - * @group functional - */ + #[Group('functional')] public function testFieldValueFactor(): void { $expected = [ diff --git a/tests/Query/FuzzyTest.php b/tests/Query/FuzzyTest.php index 9c19eafa4..4ed994d00 100644 --- a/tests/Query/FuzzyTest.php +++ b/tests/Query/FuzzyTest.php @@ -8,15 +8,14 @@ use Elastica\Exception\InvalidException; use Elastica\Query\Fuzzy; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class FuzzyTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testAddField(): void { $fuzzy = new Fuzzy(); @@ -30,9 +29,7 @@ public function testAddField(): void $this->assertEquals($sameFuzzy->toArray(), $fuzzy->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $fuzzy = new Fuzzy(); @@ -73,9 +70,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $fuzzy->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testNeedSetFieldBeforeOption(): void { $fuzzy = new Fuzzy(); @@ -84,9 +79,7 @@ public function testNeedSetFieldBeforeOption(): void $fuzzy->setFieldOption('boost', 1.0); } - /** - * @group functional - */ + #[Group('functional')] public function testQuery(): void { $client = $this->_getClient(); @@ -114,9 +107,7 @@ public function testQuery(): void $this->assertEquals(2, $resultSet->count()); } - /** - * @group unit - */ + #[Group('unit')] public function testResetSingleField(): void { $fuzzy = new Fuzzy(); @@ -132,9 +123,7 @@ public function testResetSingleField(): void $this->assertEquals($expected, $fuzzy->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testOnlySetSingleField(): void { $fuzzy = new Fuzzy(); diff --git a/tests/Query/GeoBoundingBoxTest.php b/tests/Query/GeoBoundingBoxTest.php index 3f13b5447..24e61cb25 100644 --- a/tests/Query/GeoBoundingBoxTest.php +++ b/tests/Query/GeoBoundingBoxTest.php @@ -7,15 +7,14 @@ use Elastica\Exception\InvalidException; use Elastica\Query\GeoBoundingBox; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class GeoBoundingBoxTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testAddCoordinates(): void { $key = 'pin.location'; @@ -27,9 +26,7 @@ public function testAddCoordinates(): void $this->assertSame($expectedArray, $query->getParam($key)); } - /** - * @group unit - */ + #[Group('unit')] public function testAddCoordinatesInvalidException(): void { $this->expectException(InvalidException::class); @@ -37,9 +34,7 @@ public function testAddCoordinatesInvalidException(): void new GeoBoundingBox('foo', []); } - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $key = 'pin.location'; diff --git a/tests/Query/GeoDistanceTest.php b/tests/Query/GeoDistanceTest.php index 2d699b24e..f9f202818 100644 --- a/tests/Query/GeoDistanceTest.php +++ b/tests/Query/GeoDistanceTest.php @@ -9,15 +9,14 @@ use Elastica\Query; use Elastica\Query\GeoDistance; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class GeoDistanceTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGeoPoint(): void { $index = $this->_createIndex(); @@ -51,9 +50,7 @@ public function testGeoPoint(): void $this->assertEquals(2, $index->count($query)); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructLatlon(): void { $key = 'location'; @@ -77,9 +74,7 @@ public function testConstructLatlon(): void $this->assertEquals($expected, $data); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructGeohash(): void { $key = 'location'; @@ -100,9 +95,7 @@ public function testConstructGeohash(): void $this->assertEquals($expected, $data); } - /** - * @group unit - */ + #[Group('unit')] public function testSetDistanceType(): void { $query = new GeoDistance('location', ['lat' => 48.86, 'lon' => 2.35], '10km'); diff --git a/tests/Query/GeoPolygonTest.php b/tests/Query/GeoPolygonTest.php index 513c678d8..ad0abe8f0 100644 --- a/tests/Query/GeoPolygonTest.php +++ b/tests/Query/GeoPolygonTest.php @@ -10,15 +10,14 @@ use Elastica\Query\GeoPolygon; use Elastica\Query\MatchAll; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class GeoPolygonTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGeoPoint(): void { $index = $this->_createIndex(); diff --git a/tests/Query/GeoShapePreIndexedTest.php b/tests/Query/GeoShapePreIndexedTest.php index df6fbc961..91548babf 100644 --- a/tests/Query/GeoShapePreIndexedTest.php +++ b/tests/Query/GeoShapePreIndexedTest.php @@ -10,15 +10,14 @@ use Elastica\Query\BoolQuery; use Elastica\Query\GeoShapePreIndexed; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class GeoShapePreIndexedTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testSearch(): void { $index = $this->_createIndex(); @@ -60,9 +59,7 @@ public function testSearch(): void $this->assertEquals(0, $index->count($query), 'Changing the relation should take effect'); } - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $gsp = new GeoShapePreIndexed( @@ -88,9 +85,7 @@ public function testConstruct(): void $this->assertEquals($expected, $gsp->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetRelation(): void { $gsp = new GeoShapePreIndexed('location', '1', 'indexName', 'location'); diff --git a/tests/Query/GeoShapeProvidedTest.php b/tests/Query/GeoShapeProvidedTest.php index 19c08cc4c..2377d035c 100644 --- a/tests/Query/GeoShapeProvidedTest.php +++ b/tests/Query/GeoShapeProvidedTest.php @@ -10,15 +10,14 @@ use Elastica\Query\BoolQuery; use Elastica\Query\GeoShapeProvided; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class GeoShapeProvidedTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testSearch(): void { $index = $this->_createIndex(); @@ -60,9 +59,7 @@ public function testSearch(): void $index->delete(); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructEnvelope(): void { $envelope = [ @@ -86,9 +83,7 @@ public function testConstructEnvelope(): void $this->assertEquals($expected, $gsp->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructPolygon(): void { $polygon = [[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [103.0, 3.0], [102.0, 2.0]]; @@ -109,9 +104,7 @@ public function testConstructPolygon(): void $this->assertEquals($expected, $gsp->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetRelation(): void { $gsp = new GeoShapeProvided('location', [[25.0, 75.0], [75.0, 25.0]]); diff --git a/tests/Query/HasChildTest.php b/tests/Query/HasChildTest.php index 63032a520..d410ea150 100644 --- a/tests/Query/HasChildTest.php +++ b/tests/Query/HasChildTest.php @@ -9,15 +9,14 @@ use Elastica\Query\MatchAll; use Elastica\Search; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class HasChildTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $q = new MatchAll(); @@ -36,9 +35,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScope(): void { $q = new MatchAll(); @@ -61,9 +58,7 @@ public function testSetScope(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testHasChildren(): void { $client = $this->_getClient(); diff --git a/tests/Query/HasParentTest.php b/tests/Query/HasParentTest.php index 72509e49c..2fbe3e9d1 100644 --- a/tests/Query/HasParentTest.php +++ b/tests/Query/HasParentTest.php @@ -9,15 +9,14 @@ use Elastica\Query\MatchAll; use Elastica\Search; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class HasParentTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $q = new MatchAll(); @@ -36,9 +35,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScope(): void { $q = new MatchAll(); @@ -61,9 +58,7 @@ public function testSetScope(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testHasParent(): void { $client = $this->_getClient(); diff --git a/tests/Query/HighlightTest.php b/tests/Query/HighlightTest.php index d64ebb51b..685fd8c11 100644 --- a/tests/Query/HighlightTest.php +++ b/tests/Query/HighlightTest.php @@ -8,15 +8,14 @@ use Elastica\Query; use Elastica\Query\MatchPhrase; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class HighlightTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testHightlightSearch(): void { $index = $this->_createIndex(); diff --git a/tests/Query/IdsTest.php b/tests/Query/IdsTest.php index 15c5d1480..fcf6b4a72 100644 --- a/tests/Query/IdsTest.php +++ b/tests/Query/IdsTest.php @@ -8,6 +8,7 @@ use Elastica\Index; use Elastica\Query\Ids; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -30,9 +31,7 @@ protected function setUp(): void $this->index->refresh(); } - /** - * @group functional - */ + #[Group('functional')] public function testSetIdsSearchSingle(): void { $query = new Ids(); @@ -43,9 +42,7 @@ public function testSetIdsSearchSingle(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetIdsSearchArray(): void { $query = new Ids(); @@ -56,9 +53,7 @@ public function testSetIdsSearchArray(): void $this->assertEquals(2, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testAddIdsSearchSingle(): void { $query = new Ids(); @@ -69,9 +64,7 @@ public function testAddIdsSearchSingle(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testComboIdsSearchArray(): void { $query = new Ids(); @@ -84,9 +77,7 @@ public function testComboIdsSearchArray(): void $this->assertEquals(3, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetTypeSingleSearchSingle(): void { $query = new Ids(); @@ -96,9 +87,7 @@ public function testSetTypeSingleSearchSingle(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetTypeSingleSearchArray(): void { $query = new Ids(); @@ -109,9 +98,7 @@ public function testSetTypeSingleSearchArray(): void $this->assertEquals(2, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetTypeSingleSearchSingleDocInOtherType(): void { $query = new Ids(); @@ -125,9 +112,7 @@ public function testSetTypeSingleSearchSingleDocInOtherType(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetTypeSingleSearchArrayDocInOtherType(): void { $query = new Ids(); diff --git a/tests/Query/InnerHitsTest.php b/tests/Query/InnerHitsTest.php index d1efc52e8..4a09b6abd 100644 --- a/tests/Query/InnerHitsTest.php +++ b/tests/Query/InnerHitsTest.php @@ -16,15 +16,14 @@ use Elastica\Script\Script; use Elastica\Script\ScriptFields; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class InnerHitsTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testSetSize(): void { $innerHits = (new InnerHits()) @@ -34,9 +33,7 @@ public function testSetSize(): void $this->assertSame(12, $innerHits->getParam('size')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetFrom(): void { $innerHits = (new InnerHits()) @@ -46,9 +43,7 @@ public function testSetFrom(): void $this->assertSame(12, $innerHits->getParam('from')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetSort(): void { $sort = ['last_activity_date' => ['order' => 'desc']]; @@ -59,9 +54,7 @@ public function testSetSort(): void $this->assertSame($sort, $innerHits->getParam('sort')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetSource(): void { $fields = ['title', 'tags']; @@ -72,9 +65,7 @@ public function testSetSource(): void $this->assertSame($fields, $innerHits->getParam('_source')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetVersion(): void { $innerHits = (new InnerHits()) @@ -88,9 +79,7 @@ public function testSetVersion(): void $this->assertFalse($innerHits->getParam('version')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetExplain(): void { $innerHits = (new InnerHits()) @@ -104,9 +93,7 @@ public function testSetExplain(): void $this->assertFalse($innerHits->getParam('explain')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetHighlight(): void { $highlight = [ @@ -121,9 +108,7 @@ public function testSetHighlight(): void $this->assertSame($highlight, $innerHits->getParam('highlight')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetFieldDataFields(): void { $fields = ['title', 'tags']; @@ -134,9 +119,7 @@ public function testSetFieldDataFields(): void $this->assertSame($fields, $innerHits->getParam('docvalue_fields')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScriptFields(): void { $script = new Script('1 + 2'); @@ -149,9 +132,7 @@ public function testSetScriptFields(): void $this->assertSame($scriptFields, $innerHits->getParam('script_fields')); } - /** - * @group unit - */ + #[Group('unit')] public function testAddScriptField(): void { $script = new Script('2+3'); @@ -162,9 +143,7 @@ public function testAddScriptField(): void $this->assertSame(['five' => $script->toArray()], $innerHits->getParam('script_fields')->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsNested(): void { $queryString = new SimpleQueryString('windows newton', ['title', 'users.name']); @@ -179,9 +158,7 @@ public function testInnerHitsNested(): void $this->assertEquals('Newton', $innerHitsResults['users']['hits']['hits'][0]['_source']['name']); } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsParentChildren(): void { $queryString = new SimpleQueryString('linux cool'); @@ -203,9 +180,7 @@ public function testInnerHitsParentChildren(): void $this->assertEquals([6, 7], $responsesId); } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsLimitedSource(): void { $innerHits = (new InnerHits()) @@ -223,9 +198,7 @@ public function testInnerHitsLimitedSource(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsWithOffset(): void { $queryString = new SimpleQueryString('linux cool'); @@ -244,9 +217,7 @@ public function testInnerHitsWithOffset(): void $this->assertEquals(7, $responses[0]['_id']); } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsWithSort(): void { $queryString = new SimpleQueryString('linux cool'); @@ -270,9 +241,7 @@ public function testInnerHitsWithSort(): void $this->assertEquals([7, 6], $responsesId); } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsWithExplain(): void { $matchAll = new MatchAll(); @@ -290,9 +259,7 @@ public function testInnerHitsWithExplain(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsWithVersion(): void { $matchAll = new MatchAll(); @@ -310,9 +277,7 @@ public function testInnerHitsWithVersion(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsWithScriptFields(): void { $matchAll = new MatchAll(); @@ -336,9 +301,7 @@ public function testInnerHitsWithScriptFields(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsWithHighlight(): void { $queryString = new SimpleQueryString('question simon', ['title', 'users.name']); @@ -357,9 +320,7 @@ public function testInnerHitsWithHighlight(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testInnerHitsWithFieldData(): void { $queryString = new SimpleQueryString('question simon', ['title', 'users.name']); diff --git a/tests/Query/LimitTest.php b/tests/Query/LimitTest.php index 4bf6c76d2..498e071fb 100644 --- a/tests/Query/LimitTest.php +++ b/tests/Query/LimitTest.php @@ -6,15 +6,14 @@ use Elastica\Query\Limit; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class LimitTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testSetType(): void { $query = new Limit(10); @@ -24,9 +23,7 @@ public function testSetType(): void $this->assertSame(20, $query->getParam('value')); } - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new Limit(15); diff --git a/tests/Query/MatchAllTest.php b/tests/Query/MatchAllTest.php index e2dc07fe8..b0bf5485b 100644 --- a/tests/Query/MatchAllTest.php +++ b/tests/Query/MatchAllTest.php @@ -8,15 +8,14 @@ use Elastica\Query\MatchAll; use Elastica\Search; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class MatchAllTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new MatchAll(); @@ -26,9 +25,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testMatchAllIndicesTypes(): void { $index1 = $this->_createIndex(); diff --git a/tests/Query/MatchNoneTest.php b/tests/Query/MatchNoneTest.php index 16b423b1c..50d29ca6f 100644 --- a/tests/Query/MatchNoneTest.php +++ b/tests/Query/MatchNoneTest.php @@ -8,15 +8,14 @@ use Elastica\Query\MatchNone; use Elastica\Search; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class MatchNoneTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new MatchNone(); @@ -26,9 +25,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testMatchNone(): void { $index = $this->_createIndex(); diff --git a/tests/Query/MatchPhrasePrefixTest.php b/tests/Query/MatchPhrasePrefixTest.php index d5b429916..b2bce275c 100644 --- a/tests/Query/MatchPhrasePrefixTest.php +++ b/tests/Query/MatchPhrasePrefixTest.php @@ -7,15 +7,14 @@ use Elastica\Document; use Elastica\Query\MatchPhrasePrefix; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class MatchPhrasePrefixTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $field = 'test'; @@ -44,9 +43,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testMatchPhrasePrefix(): void { $client = $this->_getClient(); diff --git a/tests/Query/MatchPhraseTest.php b/tests/Query/MatchPhraseTest.php index d3934fc57..f26be7ac4 100644 --- a/tests/Query/MatchPhraseTest.php +++ b/tests/Query/MatchPhraseTest.php @@ -7,15 +7,14 @@ use Elastica\Document; use Elastica\Query\MatchPhrase; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class MatchPhraseTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $field = 'test'; @@ -41,9 +40,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testMatchPhrase(): void { $client = $this->_getClient(); diff --git a/tests/Query/MatchQueryTest.php b/tests/Query/MatchQueryTest.php index a4e895f69..2ec2f8ad1 100644 --- a/tests/Query/MatchQueryTest.php +++ b/tests/Query/MatchQueryTest.php @@ -7,15 +7,14 @@ use Elastica\Document; use Elastica\Query\MatchQuery; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class MatchQueryTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $field = 'test'; @@ -31,8 +30,6 @@ public function testToArray(): void $query = new MatchQuery(); $query->setFieldQuery($field, $testQuery); - $this->hideDeprecated(); - $this->showDeprecated(); $query->setFieldOperator($field, $operator); $query->setFieldAnalyzer($field, $analyzer); $query->setFieldBoost($field, $boost); @@ -61,9 +58,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testMatch(): void { $client = $this->_getClient(); @@ -93,9 +88,7 @@ public function testMatch(): void $this->assertEquals(4, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testMatchSetFieldBoost(): void { $client = $this->_getClient(); @@ -126,9 +119,7 @@ public function testMatchSetFieldBoost(): void $this->assertEquals(4, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testMatchZeroTerm(): void { $client = $this->_getClient(); @@ -153,9 +144,7 @@ public function testMatchZeroTerm(): void $this->assertEquals(2, $resultSet->count()); } - /** - * @group unit - */ + #[Group('unit')] public function testMatchFuzzinessType(): void { $field = 'test'; @@ -174,9 +163,7 @@ public function testMatchFuzzinessType(): void $this->assertEquals($fuzziness, $parameters['fuzziness']); } - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $match = new MatchQuery(null, 'values'); diff --git a/tests/Query/MoreLikeThisTest.php b/tests/Query/MoreLikeThisTest.php index a9cd4e754..64af1e7e5 100644 --- a/tests/Query/MoreLikeThisTest.php +++ b/tests/Query/MoreLikeThisTest.php @@ -12,15 +12,14 @@ use Elastica\Query\MoreLikeThis; use Elastica\Query\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class MoreLikeThisTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testSearch(): void { $client = $this->_getClient(); @@ -62,9 +61,7 @@ public function testSearch(): void $this->assertEquals(2, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchByDocument(): void { $client = $this->_getClient(); @@ -131,9 +128,7 @@ public function testSearchByDocument(): void $this->assertEquals(1, $index->count($mltQuery)); } - /** - * @group unit - */ + #[Group('unit')] public function testSetFields(): void { $query = new MoreLikeThis(); @@ -145,9 +140,7 @@ public function testSetFields(): void $this->assertEquals($fields, $data['more_like_this']['fields']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetLike(): void { $query = new MoreLikeThis(); @@ -157,9 +150,7 @@ public function testSetLike(): void $this->assertEquals(' hello world', $data['more_like_this']['like']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetBoost(): void { $query = new MoreLikeThis(); @@ -170,9 +161,7 @@ public function testSetBoost(): void $this->assertEquals($boost, $query->getParam('boost')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetMaxQueryTerms(): void { $query = new MoreLikeThis(); @@ -183,9 +172,7 @@ public function testSetMaxQueryTerms(): void $this->assertEquals($max, $query->getParam('max_query_terms')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetMinimumShouldMatch(): void { $query = new MoreLikeThis(); @@ -196,9 +183,7 @@ public function testSetMinimumShouldMatch(): void $this->assertEquals($match, $query->getParam('minimum_should_match')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetMinDocFrequency(): void { $query = new MoreLikeThis(); @@ -209,9 +194,7 @@ public function testSetMinDocFrequency(): void $this->assertEquals($freq, $query->getParam('min_doc_freq')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetMaxDocFrequency(): void { $query = new MoreLikeThis(); @@ -222,9 +205,7 @@ public function testSetMaxDocFrequency(): void $this->assertEquals($freq, $query->getParam('max_doc_freq')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetMinWordLength(): void { $query = new MoreLikeThis(); @@ -235,9 +216,7 @@ public function testSetMinWordLength(): void $this->assertEquals($length, $query->getParam('min_word_length')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetMaxWordLength(): void { $query = new MoreLikeThis(); @@ -248,9 +227,7 @@ public function testSetMaxWordLength(): void $this->assertEquals($length, $query->getParam('max_word_length')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetBoostTerms(): void { $query = new MoreLikeThis(); @@ -261,9 +238,7 @@ public function testSetBoostTerms(): void $this->assertEquals($boost, $query->getParam('boost_terms')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetAnalyzer(): void { $query = new MoreLikeThis(); @@ -274,9 +249,7 @@ public function testSetAnalyzer(): void $this->assertEquals($analyzer, $query->getParam('analyzer')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetStopWords(): void { $query = new MoreLikeThis(); @@ -287,9 +260,7 @@ public function testSetStopWords(): void $this->assertEquals($stopWords, $query->getParam('stop_words')); } - /** - * @group unit - */ + #[Group('unit')] public function testToArrayForId(): void { $query = new MoreLikeThis(); @@ -309,9 +280,7 @@ public function testToArrayForId(): void ); } - /** - * @group unit - */ + #[Group('unit')] public function testToArrayForSource(): void { $query = new MoreLikeThis(); diff --git a/tests/Query/MultiMatchTest.php b/tests/Query/MultiMatchTest.php index 2ea320999..91038ebc2 100644 --- a/tests/Query/MultiMatchTest.php +++ b/tests/Query/MultiMatchTest.php @@ -11,6 +11,7 @@ use Elastica\Query\MultiMatch; use Elastica\ResultSet; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -24,9 +25,7 @@ class MultiMatchTest extends BaseTest ['id' => '4', 'name' => 'John', 'last_name' => 'not Doe', 'full_name' => 'John not Doe'], ]; - /** - * @group functional - */ + #[Group('functional')] public function testMinimumShouldMatch(): void { $multiMatch = new MultiMatch(); @@ -38,9 +37,7 @@ public function testMinimumShouldMatch(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testAndOperator(): void { $multiMatch = new MultiMatch(); @@ -52,9 +49,7 @@ public function testAndOperator(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testTypePhrasePrefix(): void { $multiMatch = new MultiMatch(); @@ -66,9 +61,7 @@ public function testTypePhrasePrefix(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testTypeBoolPrefix(): void { $multiMatch = new MultiMatch(); @@ -80,9 +73,7 @@ public function testTypeBoolPrefix(): void $this->assertEquals(2, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testFuzzy(): void { $multiMatch = new MultiMatch(); @@ -110,9 +101,7 @@ public function testFuzzy(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testFuzzyWithOptions1(): void { // Here Elasticsearch will not accept mispells @@ -127,9 +116,7 @@ public function testFuzzyWithOptions1(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testFuzzyWithOptions2(): void { // Here with a 'M' search we should hit 'Moraes' first @@ -146,9 +133,7 @@ public function testFuzzyWithOptions2(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testZeroTerm(): void { $multiMatch = new MultiMatch(); @@ -166,9 +151,7 @@ public function testZeroTerm(): void $this->assertEquals(4, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testBaseMultiMatch(): void { $multiMatch = new MultiMatch(); diff --git a/tests/Query/NestedTest.php b/tests/Query/NestedTest.php index a8be50bab..5ba324000 100644 --- a/tests/Query/NestedTest.php +++ b/tests/Query/NestedTest.php @@ -7,15 +7,14 @@ use Elastica\Query\Nested; use Elastica\Query\QueryString; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class NestedTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testSetQuery(): void { $queryString = new QueryString('test'); diff --git a/tests/Query/ParentIdTest.php b/tests/Query/ParentIdTest.php index 18804d9a4..12cc45dac 100644 --- a/tests/Query/ParentIdTest.php +++ b/tests/Query/ParentIdTest.php @@ -9,15 +9,14 @@ use Elastica\QueryBuilder\DSL\Query; use Elastica\Search; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ParentIdTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new ParentId('join', '1'); @@ -32,9 +31,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testParentId(): void { $client = $this->_getClient(); @@ -125,9 +122,7 @@ public function testParentId(): void $this->assertEquals(2, $results->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testQueryBuilderParentId(): void { $client = $this->_getClient(); diff --git a/tests/Query/PercolateTest.php b/tests/Query/PercolateTest.php index 0600cb4c5..7c909ebbc 100644 --- a/tests/Query/PercolateTest.php +++ b/tests/Query/PercolateTest.php @@ -10,6 +10,7 @@ use Elastica\Mapping; use Elastica\Query\Percolate; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -21,9 +22,7 @@ class PercolateTest extends BaseTest */ private $index; - /** - * @group functional - */ + #[Group('functional')] public function testPercolateQueryOnNewDocument(): void { $this->_prepareIndexForPercolate(); @@ -61,9 +60,7 @@ public function testPercolateQueryOnNewDocument(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testPercolateQueryOnExistingDocument(): void { $this->_prepareIndexForPercolate(); @@ -102,9 +99,7 @@ public function testPercolateQueryOnExistingDocument(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetField(): void { $field = 'field1'; @@ -116,9 +111,7 @@ public function testSetField(): void $this->assertEquals($data['percolate']['field'], $field); } - /** - * @group unit - */ + #[Group('unit')] public function testSetDocument(): void { $query = new Percolate(); @@ -130,9 +123,7 @@ public function testSetDocument(): void $this->assertEquals($data['percolate']['document'], $doc->getData()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetDocumentIndex(): void { $client = $this->createMock(Client::class); @@ -145,9 +136,7 @@ public function testSetDocumentIndex(): void $this->assertEquals($data['percolate']['index'], $index->getName()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetDocumentId(): void { $id = 3; @@ -159,9 +148,7 @@ public function testSetDocumentId(): void $this->assertEquals($data['percolate']['id'], $id); } - /** - * @group unit - */ + #[Group('unit')] public function testSetDocumentRouting(): void { $routing = 'testRout'; @@ -173,9 +160,7 @@ public function testSetDocumentRouting(): void $this->assertEquals($data['percolate']['routing'], $routing); } - /** - * @group unit - */ + #[Group('unit')] public function testSetDocumentPreference(): void { $preference = ['pref1' => 'test', 'pref2' => 'test2']; @@ -187,9 +172,7 @@ public function testSetDocumentPreference(): void $this->assertEquals($data['percolate']['preference'], $preference); } - /** - * @group unit - */ + #[Group('unit')] public function testSetDocumentVersion(): void { $version = 10; diff --git a/tests/Query/PostFilterTest.php b/tests/Query/PostFilterTest.php index d8349226b..cce6eb11a 100644 --- a/tests/Query/PostFilterTest.php +++ b/tests/Query/PostFilterTest.php @@ -10,15 +10,14 @@ use Elastica\Query\MatchQuery; use Elastica\Query\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class PostFilterTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new Query(); @@ -32,9 +31,7 @@ public function testToArray(): void $this->assertEquals(['term' => ['color' => 'green']], $data['post_filter']); } - /** - * @group functional - */ + #[Group('functional')] public function testQuery(): void { $query = new Query(); diff --git a/tests/Query/PrefixTest.php b/tests/Query/PrefixTest.php index 3efe28e8d..274a387aa 100644 --- a/tests/Query/PrefixTest.php +++ b/tests/Query/PrefixTest.php @@ -6,15 +6,14 @@ use Elastica\Query\Prefix; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class PrefixTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new Prefix(); diff --git a/tests/Query/QueryStringTest.php b/tests/Query/QueryStringTest.php index e426b22ff..7f56406bf 100644 --- a/tests/Query/QueryStringTest.php +++ b/tests/Query/QueryStringTest.php @@ -8,15 +8,14 @@ use Elastica\Document; use Elastica\Query\QueryString; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class QueryStringTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testSearchMultipleFields(): void { $str = \uniqid(); @@ -46,9 +45,7 @@ public function testSearchMultipleFields(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testSearch(): void { $index = $this->_createIndex(); @@ -66,9 +63,8 @@ public function testSearch(): void /** * Tests if search in multiple fields is possible. - * - * @group functional */ + #[Group('functional')] public function testSearchFields(): void { $index = $this->_createIndex(); @@ -87,9 +83,8 @@ public function testSearchFields(): void /** * Tests if search in multiple fields is possible. - * - * @group functional */ + #[Group('functional')] public function testSearchFieldsValidationException(): void { $index = $this->_createIndex(); @@ -116,9 +111,7 @@ public function testSearchFieldsValidationException(): void } } - /** - * @group unit - */ + #[Group('unit')] public function testSetDefaultOperator(): void { $operator = 'AND'; @@ -130,9 +123,7 @@ public function testSetDefaultOperator(): void $this->assertEquals($data['query_string']['default_operator'], $operator); } - /** - * @group unit - */ + #[Group('unit')] public function testSetDefaultField(): void { $default = 'field1'; @@ -144,9 +135,7 @@ public function testSetDefaultField(): void $this->assertEquals($data['query_string']['default_field'], $default); } - /** - * @group unit - */ + #[Group('unit')] public function testSetAnalyzer(): void { $value = 'test'; @@ -156,9 +145,7 @@ public function testSetAnalyzer(): void $this->assertEquals($value, $query->toArray()['query_string']['analyzer']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetAllowLeadingWildcard(): void { $value = true; @@ -168,9 +155,7 @@ public function testSetAllowLeadingWildcard(): void $this->assertEquals($value, $query->toArray()['query_string']['allow_leading_wildcard']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetEnablePositionIncrements(): void { $value = true; @@ -180,9 +165,7 @@ public function testSetEnablePositionIncrements(): void $this->assertEquals($value, $query->toArray()['query_string']['enable_position_increments']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetFuzzyPrefixLength(): void { $value = 1; @@ -192,9 +175,7 @@ public function testSetFuzzyPrefixLength(): void $this->assertEquals($value, $query->toArray()['query_string']['fuzzy_prefix_length']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetFuzzyMinSim(): void { $value = 0.1; @@ -204,9 +185,7 @@ public function testSetFuzzyMinSim(): void $this->assertEquals($value, $query->toArray()['query_string']['fuzzy_min_sim']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetAnalyzeWildcard(): void { $value = true; @@ -216,9 +195,7 @@ public function testSetAnalyzeWildcard(): void $this->assertEquals($value, $query->toArray()['query_string']['analyze_wildcard']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetTieBreaker(): void { $value = 0.2; @@ -228,9 +205,7 @@ public function testSetTieBreaker(): void $this->assertEquals($value, $query->toArray()['query_string']['tie_breaker']); } - /** - * @group unit - */ + #[Group('unit')] public function testSetRewrite(): void { $rewrite = 'scoring_boolean'; @@ -242,9 +217,7 @@ public function testSetRewrite(): void $this->assertEquals($data['query_string']['rewrite'], $rewrite); } - /** - * @group unit - */ + #[Group('unit')] public function testSetTimezone(): void { $timezone = 'Europe/Paris'; @@ -264,9 +237,7 @@ public function testSetTimezone(): void $this->assertSame($expected, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetPhraseSlop(): void { $phraseSlop = 9; @@ -278,9 +249,7 @@ public function testSetPhraseSlop(): void $this->assertEquals($phraseSlop, $data['query_string']['phrase_slop']); } - /** - * @group functional - */ + #[Group('functional')] public function testSetBoost(): void { $index = $this->_createIndex(); diff --git a/tests/Query/RangeTest.php b/tests/Query/RangeTest.php index f687b4cf1..7942726ac 100644 --- a/tests/Query/RangeTest.php +++ b/tests/Query/RangeTest.php @@ -7,15 +7,14 @@ use Elastica\Document; use Elastica\Query\Range; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class RangeTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testQuery(): void { $client = $this->_getClient(); @@ -45,9 +44,7 @@ public function testQuery(): void $this->assertEquals(2, $result); } - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $range = new Range(); @@ -64,9 +61,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $range->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $ranges = ['from' => 20, 'to' => 40]; diff --git a/tests/Query/RegexpTest.php b/tests/Query/RegexpTest.php index 1689a4dd7..07350a4b9 100644 --- a/tests/Query/RegexpTest.php +++ b/tests/Query/RegexpTest.php @@ -6,15 +6,14 @@ use Elastica\Query\Regexp; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class RegexpTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $field = 'name'; diff --git a/tests/Query/RescoreTest.php b/tests/Query/RescoreTest.php index 2e435f03b..833c286f0 100644 --- a/tests/Query/RescoreTest.php +++ b/tests/Query/RescoreTest.php @@ -9,15 +9,14 @@ use Elastica\Query\Term; use Elastica\Rescore\Query as QueryRescore; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class RescoreTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new Query(); @@ -55,9 +54,7 @@ public function testToArray(): void $this->assertEquals($expected, $data); } - /** - * @group unit - */ + #[Group('unit')] public function testSetSize(): void { $query = new Query(); @@ -97,9 +94,7 @@ public function testSetSize(): void $this->assertEquals($expected, $data); } - /** - * @group unit - */ + #[Group('unit')] public function testSetWeights(): void { $query = new Query(); @@ -143,9 +138,7 @@ public function testSetWeights(): void $this->assertEquals($expected, $data); } - /** - * @group functional - */ + #[Group('functional')] public function testMultipleQueries(): void { $query = new Query(); @@ -215,9 +208,7 @@ public function testMultipleQueries(): void $this->assertEquals(0, $results->getTotalHits()); } - /** - * @group functional - */ + #[Group('functional')] public function testQuery(): void { $mainQuery = (new MatchQuery()) diff --git a/tests/Query/ScriptTest.php b/tests/Query/ScriptTest.php index 64c31f7e0..b71e86d97 100644 --- a/tests/Query/ScriptTest.php +++ b/tests/Query/ScriptTest.php @@ -7,15 +7,14 @@ use Elastica\Query\Script as ScriptQuery; use Elastica\Script\Script; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ScriptTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $string = '_score * 2.0'; @@ -35,9 +34,7 @@ public function testToArray(): void $this->assertEquals($expected, $array); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScript(): void { $string = '_score * 2.0'; diff --git a/tests/Query/SimpleQueryStringTest.php b/tests/Query/SimpleQueryStringTest.php index b6b37dd34..5a0701a8e 100644 --- a/tests/Query/SimpleQueryStringTest.php +++ b/tests/Query/SimpleQueryStringTest.php @@ -7,15 +7,14 @@ use Elastica\Document; use Elastica\Query\SimpleQueryString; use Elastica\Test\Base; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SimpleQueryStringTest extends Base { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $string = 'this is a test'; @@ -36,9 +35,7 @@ public function testToArray(): void $this->assertEquals($expected, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testQuery(): void { $index = $this->_createIndex(); @@ -64,9 +61,7 @@ public function testQuery(): void $this->assertEquals(0, $results->getTotalHits()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetMinimumShouldMatch(): void { $expected = [ @@ -83,9 +78,7 @@ public function testSetMinimumShouldMatch(): void $this->assertEquals($expected, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetMinimumShouldMatchWorks(): void { $index = $this->_createIndex(); diff --git a/tests/Query/SimpleTest.php b/tests/Query/SimpleTest.php index d6b80be84..75cc27136 100644 --- a/tests/Query/SimpleTest.php +++ b/tests/Query/SimpleTest.php @@ -6,15 +6,14 @@ use Elastica\Query\Simple; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SimpleTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $testQuery = ['hello' => ['world'], 'name' => 'ruflin']; diff --git a/tests/Query/SpanContainingTest.php b/tests/Query/SpanContainingTest.php index 91fc816b5..138292cd7 100644 --- a/tests/Query/SpanContainingTest.php +++ b/tests/Query/SpanContainingTest.php @@ -9,15 +9,14 @@ use Elastica\Query\SpanNear; use Elastica\Query\SpanTerm; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SpanContainingTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $field = 'name'; @@ -62,9 +61,7 @@ public function testToArray(): void $this->assertEquals($expected, $spanContainingQuery->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSpanContaining(): void { $field = 'lorem'; diff --git a/tests/Query/SpanFirstTest.php b/tests/Query/SpanFirstTest.php index b280919e9..3ca0f2199 100644 --- a/tests/Query/SpanFirstTest.php +++ b/tests/Query/SpanFirstTest.php @@ -8,15 +8,14 @@ use Elastica\Query\SpanFirst; use Elastica\Query\SpanTerm; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SpanFirstTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new SpanFirst(); @@ -35,9 +34,7 @@ public function testToArray(): void ], $data); } - /** - * @group functional - */ + #[Group('functional')] public function testSpanNearTerm(): void { $field = 'lorem'; diff --git a/tests/Query/SpanMultiTest.php b/tests/Query/SpanMultiTest.php index 0b2c2bdfa..e3d0f3f4c 100644 --- a/tests/Query/SpanMultiTest.php +++ b/tests/Query/SpanMultiTest.php @@ -11,15 +11,14 @@ use Elastica\Query\SpanMulti; use Elastica\Query\Wildcard; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SpanMultiTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testConstructValid(): void { $field = 'name'; @@ -58,9 +57,7 @@ public function testConstructValid(): void $this->assertEquals($expected, $spanMultiQuery->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSpanMulti(): void { $field = 'lorem'; diff --git a/tests/Query/SpanNearTest.php b/tests/Query/SpanNearTest.php index c522c0870..3ceaf4957 100644 --- a/tests/Query/SpanNearTest.php +++ b/tests/Query/SpanNearTest.php @@ -10,15 +10,14 @@ use Elastica\Query\SpanTerm; use Elastica\Query\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SpanNearTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testConstructWrongTypeInvalid(): void { $this->expectException(InvalidException::class); @@ -29,9 +28,7 @@ public function testConstructWrongTypeInvalid(): void new SpanNear([$term1, $term2]); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructValid(): void { $field = 'name'; @@ -65,9 +62,7 @@ public function testConstructValid(): void $this->assertEquals($expected, $spanNearQuery->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSpanNearTerm(): void { $field = 'lorem'; diff --git a/tests/Query/SpanNotTest.php b/tests/Query/SpanNotTest.php index 73f0a434b..b26ab0bf3 100644 --- a/tests/Query/SpanNotTest.php +++ b/tests/Query/SpanNotTest.php @@ -9,15 +9,14 @@ use Elastica\Query\SpanNot; use Elastica\Query\SpanTerm; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SpanNotTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $field = 'name'; @@ -62,9 +61,7 @@ public function testToArray(): void $this->assertEquals($expected, $spanContainingQuery->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSpanNot(): void { $field = 'lorem'; diff --git a/tests/Query/SpanOrTest.php b/tests/Query/SpanOrTest.php index 7a32b635e..ddedcfc2e 100644 --- a/tests/Query/SpanOrTest.php +++ b/tests/Query/SpanOrTest.php @@ -10,15 +10,14 @@ use Elastica\Query\SpanTerm; use Elastica\Query\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SpanOrTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testConstructWrongTypeInvalid(): void { $this->expectException(InvalidException::class); @@ -29,9 +28,7 @@ public function testConstructWrongTypeInvalid(): void new SpanOr([$term1, $term2]); } - /** - * @group unit - */ + #[Group('unit')] public function testConstructValid(): void { $field = 'name'; @@ -63,9 +60,7 @@ public function testConstructValid(): void $this->assertEquals($expected, $spanOrQuery->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSpanOrTerm(): void { $field = 'lorem'; diff --git a/tests/Query/SpanTermTest.php b/tests/Query/SpanTermTest.php index faddc13fa..6b2e6d39b 100644 --- a/tests/Query/SpanTermTest.php +++ b/tests/Query/SpanTermTest.php @@ -7,15 +7,14 @@ use Elastica\Document; use Elastica\Query\SpanTerm; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SpanTermTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $field = 'name'; @@ -31,9 +30,7 @@ public function testConstruct(): void $this->assertEquals($expectedArray, $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSpanTerm(): void { $field = 'name'; diff --git a/tests/Query/SpanWithinTest.php b/tests/Query/SpanWithinTest.php index 05afae725..84895c61b 100644 --- a/tests/Query/SpanWithinTest.php +++ b/tests/Query/SpanWithinTest.php @@ -9,15 +9,14 @@ use Elastica\Query\SpanTerm; use Elastica\Query\SpanWithin; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SpanWithinTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $field = 'name'; @@ -62,9 +61,7 @@ public function testToArray(): void $this->assertEquals($expected, $spanContainingQuery->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSpanWithin(): void { $field = 'lorem'; diff --git a/tests/Query/TermTest.php b/tests/Query/TermTest.php index 3655c4201..a1a416dbe 100644 --- a/tests/Query/TermTest.php +++ b/tests/Query/TermTest.php @@ -6,15 +6,14 @@ use Elastica\Query\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class TermTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $query = new Term(); @@ -31,9 +30,7 @@ public function testToArray(): void $this->assertEquals($data['term'][$key]['boost'], $boost); } - /** - * @group unit - */ + #[Group('unit')] public function testDiacriticsValueToArray(): void { $query = new Term(); diff --git a/tests/Query/TermsSetTest.php b/tests/Query/TermsSetTest.php index 7b377427c..3ee345693 100644 --- a/tests/Query/TermsSetTest.php +++ b/tests/Query/TermsSetTest.php @@ -9,15 +9,14 @@ use Elastica\Query\TermsSet; use Elastica\Script\Script; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class TermsSetTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testMinimumShouldMatchField(): void { $expected = [ @@ -34,9 +33,7 @@ public function testMinimumShouldMatchField(): void $this->assertSame($expected, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testEmptyField(): void { $this->expectException(InvalidException::class); @@ -45,9 +42,7 @@ public function testEmptyField(): void new TermsSet('', ['foo', 'bar'], 'match_field'); } - /** - * @group functional - */ + #[Group('functional')] public function testMinimumShouldMatchScriptSearch(): void { $index = $this->_createIndex(); @@ -81,9 +76,7 @@ public function testMinimumShouldMatchScriptSearch(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testMinimumShouldMatchFieldSearch(): void { $index = $this->_createIndex(); @@ -117,9 +110,7 @@ public function testMinimumShouldMatchFieldSearch(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testVariousDataTypesViaConstructor(): void { $index = $this->_createIndex(); diff --git a/tests/Query/TermsTest.php b/tests/Query/TermsTest.php index 6c6bc0a11..f5de0263c 100644 --- a/tests/Query/TermsTest.php +++ b/tests/Query/TermsTest.php @@ -8,15 +8,14 @@ use Elastica\Exception\InvalidException; use Elastica\Query\Terms; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class TermsTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testSetTermsLookup(): void { $expected = [ @@ -36,9 +35,7 @@ public function testSetTermsLookup(): void $this->assertSame($expected, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetBoost(): void { $expected = [ @@ -55,9 +52,7 @@ public function testSetBoost(): void $this->assertSame($expected, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testInvalidParams(): void { $this->expectException(InvalidException::class); @@ -69,9 +64,7 @@ public function testInvalidParams(): void ; } - /** - * @group unit - */ + #[Group('unit')] public function testEmptyField(): void { $this->expectException(InvalidException::class); @@ -80,9 +73,7 @@ public function testEmptyField(): void new Terms(''); } - /** - * @group functional - */ + #[Group('functional')] public function testFilteredSearch(): void { $index = $this->_createIndex(); @@ -106,9 +97,7 @@ public function testFilteredSearch(): void $this->assertEquals(3, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testFilteredSearchWithLookup(): void { $index = $this->_createIndex(); @@ -134,9 +123,7 @@ public function testFilteredSearchWithLookup(): void $this->assertEquals(2, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testVariousDataTypesViaConstructor(): void { $index = $this->_createIndex(); @@ -162,9 +149,7 @@ public function testVariousDataTypesViaConstructor(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testVariousMixedDataTypesViaConstructor(): void { $index = $this->_createIndex(); @@ -182,9 +167,7 @@ public function testVariousMixedDataTypesViaConstructor(): void $this->assertEquals(3, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testVariousDataTypesViaAddTerm(): void { $index = $this->_createIndex(); @@ -213,9 +196,7 @@ public function testVariousDataTypesViaAddTerm(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddTermTypeError(): void { $this->expectException(\TypeError::class); diff --git a/tests/Query/WildcardTest.php b/tests/Query/WildcardTest.php index a4d1558ce..1760e373b 100644 --- a/tests/Query/WildcardTest.php +++ b/tests/Query/WildcardTest.php @@ -8,15 +8,15 @@ use Elastica\Mapping; use Elastica\Query\Wildcard; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class WildcardTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $wildcard = new Wildcard('name', 'aaa*'); @@ -28,9 +28,7 @@ public function testConstruct(): void $this->assertSame(1.0, $data['boost']); } - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $wildcard = new Wildcard('name', 'value*', 2.0); @@ -49,9 +47,7 @@ public function testToArray(): void $this->assertEquals($expectedArray, $wildcard->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchWithAnalyzer(): void { $client = $this->_getClient(); @@ -104,11 +100,8 @@ public function testSearchWithAnalyzer(): void $this->assertEquals(0, $resultSet->count()); } - /** - * @group functional - * - * @dataProvider caseInsensitiveDataProvider - */ + #[Group('functional')] + #[DataProvider('caseInsensitiveDataProvider')] public function testCaseInsensitive(bool $expected): void { // feature doesn't exist on version prior 7.10; @@ -129,7 +122,7 @@ public function testCaseInsensitive(bool $expected): void $this->assertEquals($expectedArray, $query->toArray()); } - public function caseInsensitiveDataProvider(): iterable + public static function caseInsensitiveDataProvider(): iterable { yield [true]; yield [false]; diff --git a/tests/QueryBuilder/DSL/AbstractDSLTest.php b/tests/QueryBuilder/DSL/AbstractDSLTestCase.php similarity index 98% rename from tests/QueryBuilder/DSL/AbstractDSLTest.php rename to tests/QueryBuilder/DSL/AbstractDSLTestCase.php index 179fd515b..65aba1f59 100644 --- a/tests/QueryBuilder/DSL/AbstractDSLTest.php +++ b/tests/QueryBuilder/DSL/AbstractDSLTestCase.php @@ -8,7 +8,7 @@ use Elastica\QueryBuilder\DSL; use Elastica\Test\Base as BaseTest; -abstract class AbstractDSLTest extends BaseTest +abstract class AbstractDSLTestCase extends BaseTest { protected function _assertImplemented(DSL $dsl, string $methodName, string $className, array $arguments): void { diff --git a/tests/QueryBuilder/DSL/AggregationTest.php b/tests/QueryBuilder/DSL/AggregationTestCase.php similarity index 97% rename from tests/QueryBuilder/DSL/AggregationTest.php rename to tests/QueryBuilder/DSL/AggregationTestCase.php index 5dd9fa4c6..26f7773ac 100644 --- a/tests/QueryBuilder/DSL/AggregationTest.php +++ b/tests/QueryBuilder/DSL/AggregationTestCase.php @@ -7,15 +7,14 @@ use Elastica\Aggregation; use Elastica\Query\Exists; use Elastica\QueryBuilder\DSL; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class AggregationTest extends AbstractDSLTest +class AggregationTestCase extends AbstractDSLTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testType(): void { $aggregationDSL = new DSL\Aggregation(); @@ -24,9 +23,7 @@ public function testType(): void $this->assertEquals(DSL::TYPE_AGGREGATION, $aggregationDSL->getType()); } - /** - * @group unit - */ + #[Group('unit')] public function testInterface(): void { $aggregationDSL = new DSL\Aggregation(); diff --git a/tests/QueryBuilder/DSL/CollapseTest.php b/tests/QueryBuilder/DSL/CollapseTestCase.php similarity index 81% rename from tests/QueryBuilder/DSL/CollapseTest.php rename to tests/QueryBuilder/DSL/CollapseTestCase.php index d62716205..c611d1e0f 100644 --- a/tests/QueryBuilder/DSL/CollapseTest.php +++ b/tests/QueryBuilder/DSL/CollapseTestCase.php @@ -6,15 +6,14 @@ use Elastica\Collapse; use Elastica\QueryBuilder\DSL; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class CollapseTest extends AbstractDSLTest +class CollapseTestCase extends AbstractDSLTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testType(): void { $collapseDSL = new DSL\Collapse(); @@ -23,9 +22,7 @@ public function testType(): void $this->assertEquals(DSL::TYPE_COLLAPSE, $collapseDSL->getType()); } - /** - * @group unit - */ + #[Group('unit')] public function testInterface(): void { $collapseDSL = new DSL\Collapse(); diff --git a/tests/QueryBuilder/DSL/QueryTest.php b/tests/QueryBuilder/DSL/QueryTestCase.php similarity index 94% rename from tests/QueryBuilder/DSL/QueryTest.php rename to tests/QueryBuilder/DSL/QueryTestCase.php index 6ad7795b1..d0e4f7952 100644 --- a/tests/QueryBuilder/DSL/QueryTest.php +++ b/tests/QueryBuilder/DSL/QueryTestCase.php @@ -7,18 +7,14 @@ use Elastica\Query; use Elastica\Query\MatchQuery; use Elastica\QueryBuilder\DSL; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class QueryTest extends AbstractDSLTest +class QueryTestCase extends AbstractDSLTestCase { - use ExpectDeprecationTrait; - - /** - * @group unit - */ + #[Group('unit')] public function testType(): void { $queryDSL = new DSL\Query(); @@ -27,9 +23,7 @@ public function testType(): void $this->assertEquals(DSL::TYPE_QUERY, $queryDSL->getType()); } - /** - * @group unit - */ + #[Group('unit')] public function testMatch(): void { $match = (new DSL\Query()) @@ -39,9 +33,7 @@ public function testMatch(): void $this->assertEquals('value', $match->getParam('field')); } - /** - * @group unit - */ + #[Group('unit')] public function testInterface(): void { $queryDSL = new DSL\Query(); diff --git a/tests/QueryBuilder/DSL/SuggestTest.php b/tests/QueryBuilder/DSL/SuggestTestCase.php similarity index 85% rename from tests/QueryBuilder/DSL/SuggestTest.php rename to tests/QueryBuilder/DSL/SuggestTestCase.php index d208aed4e..79374cf27 100644 --- a/tests/QueryBuilder/DSL/SuggestTest.php +++ b/tests/QueryBuilder/DSL/SuggestTestCase.php @@ -6,15 +6,14 @@ use Elastica\QueryBuilder\DSL; use Elastica\Suggest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ -class SuggestTest extends AbstractDSLTest +class SuggestTestCase extends AbstractDSLTestCase { - /** - * @group unit - */ + #[Group('unit')] public function testType(): void { $suggestDSL = new DSL\Suggest(); @@ -23,9 +22,7 @@ public function testType(): void $this->assertEquals(DSL::TYPE_SUGGEST, $suggestDSL->getType()); } - /** - * @group unit - */ + #[Group('unit')] public function testInterface(): void { $suggestDSL = new DSL\Suggest(); diff --git a/tests/QueryBuilder/VersionTest.php b/tests/QueryBuilder/VersionTest.php index 6384a5343..b83be1417 100644 --- a/tests/QueryBuilder/VersionTest.php +++ b/tests/QueryBuilder/VersionTest.php @@ -7,12 +7,12 @@ use Elastica\QueryBuilder\DSL; use Elastica\QueryBuilder\Version; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** - * @group unit - * * @internal */ +#[Group('unit')] class VersionTest extends BaseTest { public function testVersions(): void diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index f7d0d28a7..f9af8fa16 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -10,15 +10,14 @@ use Elastica\Query\AbstractQuery; use Elastica\QueryBuilder; use Elastica\Suggest\AbstractSuggest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class QueryBuilderTest extends Base { - /** - * @group unit - */ + #[Group('unit')] public function testCustomDSL(): void { $qb = new QueryBuilder(); @@ -39,9 +38,7 @@ public function testCustomDSL(): void $this->assertEquals('DSL "invalid" not supported', $exceptionMessage); } - /** - * @group unit - */ + #[Group('unit')] public function testFacade(): void { $qb = new QueryBuilder(); diff --git a/tests/QueryTest.php b/tests/QueryTest.php index f257e3613..ceda2e239 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -20,15 +20,15 @@ use Elastica\Search; use Elastica\Suggest; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class QueryTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testRawQuery(): void { $textQuery = new Term(['title' => 'test']); @@ -41,9 +41,7 @@ public function testRawQuery(): void $this->assertEquals($query1->toArray(), $query2->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSuggestShouldNotRemoveOtherParameters(): void { $query1 = new Query(); @@ -61,9 +59,7 @@ public function testSuggestShouldNotRemoveOtherParameters(): void $this->assertEquals($query1->toArray(), $query2->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testArrayQuery(): void { $query = [ @@ -82,9 +78,7 @@ public function testArrayQuery(): void $this->assertEquals($query1->toArray(), $query2->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSetSort(): void { $index = $this->_createIndex(); @@ -129,9 +123,7 @@ public function testSetSort(): void $this->assertEquals('guschti', $second['firstname']); } - /** - * @group unit - */ + #[Group('unit')] public function testAddSort(): void { $query = new Query(); @@ -141,9 +133,7 @@ public function testAddSort(): void $this->assertEquals($query->getParam('sort'), [$sortParam]); } - /** - * @group unit - */ + #[Group('unit')] public function testSetTrackScores(): void { $query = new Query(); @@ -153,9 +143,7 @@ public function testSetTrackScores(): void $this->assertEquals($param, $query->getParam('track_scores')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetRawQuery(): void { $query = new Query(); @@ -166,9 +154,7 @@ public function testSetRawQuery(): void $this->assertEquals($params, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetStoredFields(): void { $query = (new Query()) @@ -183,9 +169,7 @@ public function testSetStoredFields(): void $this->assertCount(2, $data['stored_fields']); } - /** - * @group unit - */ + #[Group('unit')] public function testGetQuery(): void { $query = new Query(); @@ -204,9 +188,7 @@ public function testGetQuery(): void $this->assertSame($termQuery, $query->getQuery()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetQueryToArrayCast(): void { $query = new Query(); @@ -222,9 +204,7 @@ public function testSetQueryToArrayCast(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testNotCloneInnerObjects(): void { $query = new Query(); @@ -239,9 +219,7 @@ public function testNotCloneInnerObjects(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetQueryToArrayChangeQuery(): void { $query = new Query(); @@ -258,9 +236,7 @@ public function testSetQueryToArrayChangeQuery(): void $this->assertNotEquals($queryArray, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScriptFieldsToArrayCast(): void { $query = new Query(); @@ -277,9 +253,7 @@ public function testSetScriptFieldsToArrayCast(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddScriptFieldsToArrayCast(): void { $query = new Query(); @@ -295,9 +269,7 @@ public function testAddScriptFieldsToArrayCast(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddScriptFieldToExistingScriptFields(): void { $script1 = new Script('s1'); @@ -320,9 +292,7 @@ public function testAddScriptFieldToExistingScriptFields(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddAggregationToArrayCast(): void { $query = new Query(); @@ -339,9 +309,7 @@ public function testAddAggregationToArrayCast(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetSuggestToArrayCast(): void { $query = new Query(); @@ -358,9 +326,7 @@ public function testSetSuggestToArrayCast(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetRescoreToArrayCast(): void { $query = new Query(); @@ -377,9 +343,7 @@ public function testSetRescoreToArrayCast(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetPostFilterToArrayCast(): void { $query = new Query(); @@ -394,9 +358,7 @@ public function testSetPostFilterToArrayCast(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testRawPostFilter(): void { $query = (new Query()) @@ -420,9 +382,7 @@ public function testRawPostFilter(): void ], $query->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testNoSource(): void { $index = $this->_createIndex(); @@ -459,9 +419,7 @@ public function testNoSource(): void $this->assertNotEmpty($result->getData()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetCollapseToArrayCast(): void { $query = new Query(); @@ -478,9 +436,7 @@ public function testSetCollapseToArrayCast(): void $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testCollapseArrayStructure(): void { $query = new Query(); @@ -514,9 +470,7 @@ public function testCollapseArrayStructure(): void $this->assertEquals($expected, $actual['collapse']); } - /** - * @group unit - */ + #[Group('unit')] public function testCollapseSecondLevelArrayStructure(): void { $query = new Query(); @@ -557,9 +511,7 @@ public function testCollapseSecondLevelArrayStructure(): void $this->assertEquals($expected, $actual['collapse']); } - /** - * @group unit - */ + #[Group('unit')] public function testIndicesBoostQuery(): void { $query = (new Query(new Term(['field' => 'value']))) @@ -581,9 +533,7 @@ public function testIndicesBoostQuery(): void $this->assertSame($expected, $query->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testPointInTimeInQuery(): void { $query = new Query(); @@ -597,9 +547,7 @@ public function testPointInTimeInQuery(): void $this->assertSame('5m', $queryAsArray['pit']['keep_alive']); } - /** - * @group functional - */ + #[Group('functional')] public function testPointInTimeQueryExecution(): void { $index = $this->_createIndex(); @@ -611,9 +559,7 @@ public function testPointInTimeQueryExecution(): void $this->assertSame($pitId, $search->search()->getPointInTimeId()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetTrackTotalHitsIsInParams(): void { $query = new Query(); @@ -622,7 +568,7 @@ public function testSetTrackTotalHitsIsInParams(): void $this->assertFalse($query->getParam('track_total_hits')); } - public function provideSetTrackTotalHitsInvalidValue(): iterable + public static function provideSetTrackTotalHitsInvalidValue(): iterable { yield 'string' => ['string string']; yield 'null' => [null]; @@ -630,11 +576,8 @@ public function provideSetTrackTotalHitsInvalidValue(): iterable yield 'array' => [[]]; } - /** - * @group functional - * - * @dataProvider provideSetTrackTotalHitsInvalidValue - */ + #[Group('functional')] + #[DataProvider('provideSetTrackTotalHitsInvalidValue')] public function testSetTrackTotalHitsInvalidValue($value): void { $this->expectException(InvalidException::class); @@ -642,9 +585,7 @@ public function testSetTrackTotalHitsInvalidValue($value): void (new Query())->setTrackTotalHits($value); } - /** - * @group functional - */ + #[Group('functional')] public function testSetTrackTotalHits(): void { $index = $this->_createIndex(); diff --git a/tests/ReindexTest.php b/tests/ReindexTest.php index 0d8f84316..af89306eb 100644 --- a/tests/ReindexTest.php +++ b/tests/ReindexTest.php @@ -13,15 +13,14 @@ use Elastica\Query\MatchQuery; use Elastica\Reindex; use Elastica\Script\Script; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ReindexTest extends Base { - /** - * @group functional - */ + #[Group('functional')] public function testReindex(): void { $oldIndex = $this->_createIndex('idx1', true, 2); @@ -37,9 +36,7 @@ public function testReindex(): void $this->assertEquals($oldIndex->count(), $response->getData()['created']); } - /** - * @group functional - */ + #[Group('functional')] public function testReindexOpTypeOptionWithProceedSetOnConflicts(): void { $oldIndex = $this->_createIndex('idx1', true, 2); @@ -64,9 +61,7 @@ public function testReindexOpTypeOptionWithProceedSetOnConflicts(): void $this->assertEquals($oldIndex->count(), $newIndex->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testReindexOpTypeOptionWithProceedSetOnConflictStop(): void { $oldIndex = $this->_createIndex('idx1', true, 2); @@ -95,9 +90,7 @@ public function testReindexOpTypeOptionWithProceedSetOnConflictStop(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testReindexWithQueryOption(): void { $oldIndex = $this->_createIndex('idx1', true, 2); @@ -120,9 +113,7 @@ public function testReindexWithQueryOption(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testReindexWithSizeOption(): void { // @see https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking-changes-8.0 @@ -145,9 +136,7 @@ public function testReindexWithSizeOption(): void $this->assertEquals(5, $newIndex->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testReindexWithFalseSetOnWaitForCompletion(): void { $oldIndex = $this->_createIndex('idx1', true, 2); @@ -162,9 +151,7 @@ public function testReindexWithFalseSetOnWaitForCompletion(): void $this->assertNotEmpty($reindex->getTaskId()); } - /** - * @group functional - */ + #[Group('functional')] public function testReindexWithScript(): void { $oldIndex = $this->_createIndex('idx1', true, 2); @@ -188,9 +175,7 @@ public function testReindexWithScript(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testReindexWithRemote(): void { $oldIndex = $this->_createIndex('idx1', true, 1); @@ -210,9 +195,7 @@ public function testReindexWithRemote(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testReindexWithPipeline(): void { $oldIndex = $this->_createIndex('idx1', true, 2); @@ -243,9 +226,7 @@ public function testReindexWithPipeline(): void } } - /** - * @group functional - */ + #[Group('functional')] public function testReindexWithRefresh(): void { $oldIndex = $this->_createIndex('idx1', true, 2); diff --git a/tests/ResponseFunctionalTest.php b/tests/ResponseFunctionalTest.php index 934f7dbce..ec55d3fe3 100644 --- a/tests/ResponseFunctionalTest.php +++ b/tests/ResponseFunctionalTest.php @@ -9,12 +9,12 @@ use Elastica\Query; use Elastica\Query\MatchAll; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** - * @group functional - * * @internal */ +#[Group('functional')] class ResponseFunctionalTest extends BaseTest { public function testResponse(): void diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index 8888c0a19..34e0df7c0 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -6,12 +6,12 @@ use Elastica\Response; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** - * @group unit - * * @internal */ +#[Group('unit')] class ResponseTest extends BaseTest { public function testIsOkBulkWithErrorsField(): void diff --git a/tests/ResultSet/BuilderTest.php b/tests/ResultSet/BuilderTest.php index 6c4307dd6..4483133fc 100644 --- a/tests/ResultSet/BuilderTest.php +++ b/tests/ResultSet/BuilderTest.php @@ -8,12 +8,12 @@ use Elastica\Response; use Elastica\ResultSet\DefaultBuilder; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** - * @group unit - * * @internal */ +#[Group('unit')] class BuilderTest extends BaseTest { /** diff --git a/tests/ResultSet/ChainProcessorTest.php b/tests/ResultSet/ChainProcessorTest.php index f89dddf09..e24aabc76 100644 --- a/tests/ResultSet/ChainProcessorTest.php +++ b/tests/ResultSet/ChainProcessorTest.php @@ -10,12 +10,12 @@ use Elastica\ResultSet\ChainProcessor; use Elastica\ResultSet\ProcessorInterface; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** - * @group unit - * * @internal */ +#[Group('unit')] class ChainProcessorTest extends BaseTest { public function testProcessor(): void diff --git a/tests/ResultSet/ProcessingBuilderTest.php b/tests/ResultSet/ProcessingBuilderTest.php index 7e77237d3..5221d53b1 100644 --- a/tests/ResultSet/ProcessingBuilderTest.php +++ b/tests/ResultSet/ProcessingBuilderTest.php @@ -11,13 +11,13 @@ use Elastica\ResultSet\ProcessingBuilder; use Elastica\ResultSet\ProcessorInterface; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; /** - * @group unit - * * @internal */ +#[Group('unit')] class ProcessingBuilderTest extends BaseTest { /** diff --git a/tests/ResultSetTest.php b/tests/ResultSetTest.php index c733e0a2a..59766a5b6 100644 --- a/tests/ResultSetTest.php +++ b/tests/ResultSetTest.php @@ -8,15 +8,14 @@ use Elastica\Exception\InvalidException; use Elastica\Result; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ResultSetTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGetters(): void { $index = $this->_createIndex(); @@ -40,9 +39,7 @@ public function testGetters(): void $this->assertCount(3, $resultSet); } - /** - * @group functional - */ + #[Group('functional')] public function testArrayAccess(): void { $index = $this->_createIndex(); @@ -59,9 +56,7 @@ public function testArrayAccess(): void $this->assertArrayNotHasKey(3, $resultSet); } - /** - * @group functional - */ + #[Group('functional')] public function testDocumentsAccess(): void { $index = $this->_createIndex(); @@ -82,9 +77,7 @@ public function testDocumentsAccess(): void $this->assertEquals('elastica search', $documents[0]->get('name')); } - /** - * @group functional - */ + #[Group('functional')] public function testInvalidOffsetCreation(): void { $this->expectException(InvalidException::class); @@ -97,9 +90,7 @@ public function testInvalidOffsetCreation(): void $resultSet[1] = new Result(['_id' => 'fakeresult']); } - /** - * @group functional - */ + #[Group('functional')] public function testInvalidOffsetGet(): void { $this->expectException(InvalidException::class); diff --git a/tests/ResultTest.php b/tests/ResultTest.php index b35e85996..4f9945703 100644 --- a/tests/ResultTest.php +++ b/tests/ResultTest.php @@ -9,15 +9,14 @@ use Elastica\Query; use Elastica\Result; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ResultTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGetters(): void { // Creates a new index 'xodoa' @@ -39,9 +38,7 @@ public function testGetters(): void $this->assertEquals('hans', $result->username); } - /** - * @group functional - */ + #[Group('functional')] public function testGetIdNoSource(): void { // Creates a new index 'xodoa' @@ -78,9 +75,7 @@ public function testGetIdNoSource(): void $this->assertIsArray($result->getData()); } - /** - * @group functional - */ + #[Group('functional')] public function testGetTotalTimeReturnsExpectedResults(): void { $index = $this->_createIndex(); @@ -103,9 +98,7 @@ public function testGetTotalTimeReturnsExpectedResults(): void ); } - /** - * @group functional - */ + #[Group('functional')] public function testGetSort(): void { $index = $this->_createIndex(); @@ -122,9 +115,7 @@ public function testGetSort(): void $this->assertSame(['3'], $result->getSort()); } - /** - * @group functional - */ + #[Group('functional')] public function testGetSortWithNoSorting(): void { $index = $this->_createIndex(); @@ -140,9 +131,7 @@ public function testGetSortWithNoSorting(): void $this->assertNull($result->getSort()); } - /** - * @group unit - */ + #[Group('unit')] public function testHasFields(): void { $data = ['value set']; diff --git a/tests/Script/ScriptFieldsTest.php b/tests/Script/ScriptFieldsTest.php index 3e195f94c..5f41e890b 100644 --- a/tests/Script/ScriptFieldsTest.php +++ b/tests/Script/ScriptFieldsTest.php @@ -9,15 +9,14 @@ use Elastica\Script\Script; use Elastica\Script\ScriptFields; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class ScriptFieldsTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testNewScriptFields(): void { $script = new Script('1 + 2'); @@ -41,9 +40,7 @@ public function testNewScriptFields(): void $this->assertSame($script, $scriptFields->getParam('test')); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScriptFields(): void { $query = new Query(); @@ -61,9 +58,7 @@ public function testSetScriptFields(): void $this->assertSame($script, $query->getParam('script_fields')->getParam('test')); } - /** - * @group functional - */ + #[Group('functional')] public function testQuery(): void { $index = $this->_createIndex(); @@ -86,9 +81,7 @@ public function testQuery(): void $this->assertEquals(3, $first['test'][0]); } - /** - * @group functional - */ + #[Group('functional')] public function testScriptFieldWithJoin(): void { $client = $this->_getClient(); diff --git a/tests/Script/ScriptIdTest.php b/tests/Script/ScriptIdTest.php index 8e10f4e8f..97f918922 100644 --- a/tests/Script/ScriptIdTest.php +++ b/tests/Script/ScriptIdTest.php @@ -7,6 +7,8 @@ use Elastica\Exception\InvalidException; use Elastica\Script\ScriptId; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -15,9 +17,7 @@ class ScriptIdTest extends BaseTest { private const SCRIPT_ID = 'my_script'; - /** - * @group unit - */ + #[Group('unit')] public function testConstructor(): void { $script = new ScriptId(self::SCRIPT_ID); @@ -58,9 +58,7 @@ public function testConstructor(): void $this->assertEquals(ScriptId::LANG_PAINLESS, $script->getLang()); } - /** - * @group unit - */ + #[Group('unit')] public function testCreateString(): void { $script = ScriptId::create(self::SCRIPT_ID); @@ -75,9 +73,7 @@ public function testCreateString(): void $this->assertEquals($expected, $script->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testCreateScript(): void { $data = new ScriptId(self::SCRIPT_ID); @@ -88,9 +84,7 @@ public function testCreateScript(): void $this->assertSame($data, $script); } - /** - * @group unit - */ + #[Group('unit')] public function testCreateArray(): void { $params = [ @@ -115,11 +109,8 @@ public function testCreateArray(): void $this->assertEquals(ScriptId::LANG_PAINLESS, $script->getLang()); } - /** - * @group unit - * - * @dataProvider dataProviderCreateInvalid - */ + #[Group('unit')] + #[DataProvider('dataProviderCreateInvalid')] public function testCreateInvalid($data): void { $this->expectException(InvalidException::class); @@ -127,7 +118,7 @@ public function testCreateInvalid($data): void ScriptId::create($data); } - public function dataProviderCreateInvalid(): array + public static function dataProviderCreateInvalid(): array { return [ [ @@ -142,9 +133,7 @@ public function dataProviderCreateInvalid(): array ]; } - /** - * @group unit - */ + #[Group('unit')] public function testSetLang(): void { $script = new ScriptId(self::SCRIPT_ID, [], ScriptId::LANG_PAINLESS); @@ -153,9 +142,7 @@ public function testSetLang(): void $this->assertEquals(ScriptId::LANG_PAINLESS, $script->getLang()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScriptId(): void { $script = new ScriptId(self::SCRIPT_ID); diff --git a/tests/Script/ScriptTest.php b/tests/Script/ScriptTest.php index 38a9600c8..82b8f60ae 100644 --- a/tests/Script/ScriptTest.php +++ b/tests/Script/ScriptTest.php @@ -7,6 +7,8 @@ use Elastica\Exception\InvalidException; use Elastica\Script\Script; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -15,9 +17,7 @@ class ScriptTest extends BaseTest { private const SCRIPT = "_score * doc['my_numeric_field'].value"; - /** - * @group unit - */ + #[Group('unit')] public function testConstructor(): void { $script = new Script(self::SCRIPT); @@ -58,9 +58,7 @@ public function testConstructor(): void $this->assertEquals(Script::LANG_PAINLESS, $script->getLang()); } - /** - * @group unit - */ + #[Group('unit')] public function testCreateString(): void { $script = Script::create(self::SCRIPT); @@ -75,9 +73,7 @@ public function testCreateString(): void $this->assertEquals($expected, $script->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testCreateScript(): void { $data = new Script(self::SCRIPT); @@ -88,9 +84,7 @@ public function testCreateScript(): void $this->assertSame($data, $script); } - /** - * @group unit - */ + #[Group('unit')] public function testCreateArray(): void { $params = [ @@ -115,11 +109,8 @@ public function testCreateArray(): void $this->assertEquals(Script::LANG_PAINLESS, $script->getLang()); } - /** - * @group unit - * - * @dataProvider dataProviderCreateInvalid - */ + #[Group('unit')] + #[DataProvider('dataProviderCreateInvalid')] public function testCreateInvalid($data): void { $this->expectException(InvalidException::class); @@ -127,7 +118,7 @@ public function testCreateInvalid($data): void Script::create($data); } - public function dataProviderCreateInvalid(): array + public static function dataProviderCreateInvalid(): array { return [ [ @@ -142,9 +133,7 @@ public function dataProviderCreateInvalid(): array ]; } - /** - * @group unit - */ + #[Group('unit')] public function testSetLang(): void { $script = new Script(self::SCRIPT, [], Script::LANG_PAINLESS); @@ -153,9 +142,7 @@ public function testSetLang(): void $this->assertEquals(Script::LANG_PAINLESS, $script->getLang()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetScript(): void { $script = new Script(self::SCRIPT); diff --git a/tests/ScrollTest.php b/tests/ScrollTest.php index f7a678cdc..be0e76d7b 100644 --- a/tests/ScrollTest.php +++ b/tests/ScrollTest.php @@ -8,6 +8,7 @@ use Elastica\Document; use Elastica\Scroll; use Elastica\Search; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -16,9 +17,8 @@ class ScrollTest extends Base { /** * Full foreach test. - * - * @group functional */ + #[Group('functional')] public function testForeach(): void { $search = $this->_prepareSearch(); @@ -62,9 +62,8 @@ public function testForeach(): void /** * Scroll must not overwrite options. - * - * @group functional */ + #[Group('functional')] public function testSearchRevert(): void { $search = $this->_prepareSearch(); @@ -84,9 +83,8 @@ public function testSearchRevert(): void /** * Empty scroll (no results) must not run foreach. - * - * @group functional */ + #[Group('functional')] public function testEmptyScroll(): void { $search = $this->_prepareSearch(0); @@ -104,9 +102,8 @@ public function testEmptyScroll(): void /** * Test with ignore_unavailable search option. - * - * @group functional */ + #[Group('functional')] public function testScrollWithIgnoreUnavailable(): void { $search = $this->_prepareSearch(); diff --git a/tests/SearchTest.php b/tests/SearchTest.php index 84252bf63..78d8376ab 100644 --- a/tests/SearchTest.php +++ b/tests/SearchTest.php @@ -21,15 +21,14 @@ use Elastica\Suggest; use Elastica\Test\Base as BaseTest; use GuzzleHttp\Psr7\Response as Psr7Response; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class SearchTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testConstruct(): void { $client = $this->_getClient(); @@ -38,9 +37,7 @@ public function testConstruct(): void $this->assertSame($client, $search->getClient()); } - /** - * @group functional - */ + #[Group('functional')] public function testAddIndex(): void { $client = $this->_getClient(); @@ -63,9 +60,7 @@ public function testAddIndex(): void $this->assertContains($index2->getName(), $indices); } - /** - * @group functional - */ + #[Group('functional')] public function testAddIndexByName(): void { $client = $this->_getClient(); @@ -78,9 +73,7 @@ public function testAddIndexByName(): void $this->assertContains('index1', $indices); } - /** - * @group functional - */ + #[Group('functional')] public function testHasIndex(): void { $client = $this->_getClient(); @@ -99,9 +92,7 @@ public function testHasIndex(): void $this->assertTrue($search->hasIndex($index2)); } - /** - * @group functional - */ + #[Group('functional')] public function testHasIndexByName(): void { $client = $this->_getClient(); @@ -120,9 +111,7 @@ public function testHasIndexByName(): void $this->assertTrue($search->hasIndexByName($indexName2)); } - /** - * @group unit - */ + #[Group('unit')] public function testAddIndices(): void { $client = $this->_getClient(); @@ -137,9 +126,7 @@ public function testAddIndices(): void $this->assertCount(2, $search->getIndices()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddIndicesWithInvalidParametersThrowsException(): void { $client = $this->_getClient(); @@ -149,9 +136,7 @@ public function testAddIndicesWithInvalidParametersThrowsException(): void $search->addIndices([new \stdClass()]); } - /** - * @group unit - */ + #[Group('unit')] public function testAddIndicesByName(): void { $client = $this->_getClient(); @@ -161,9 +146,7 @@ public function testAddIndicesByName(): void $this->assertCount(2, $search->getIndices()); } - /** - * @group unit - */ + #[Group('unit')] public function testAddIndicesByNameWithInvalidParametersThrowsException(): void { $client = $this->_getClient(); @@ -173,9 +156,7 @@ public function testAddIndicesByNameWithInvalidParametersThrowsException(): void $search->addIndicesByName([new \stdClass()]); } - /** - * @group functional - */ + #[Group('functional')] public function testGetPath(): void { $client = $this->_getClient(); @@ -196,9 +177,7 @@ public function testGetPath(): void $this->assertEquals($index1->getName().','.$index2->getName().'/_search', $search1->getPath()); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchRequest(): void { $client = $this->_getClient(); @@ -217,9 +196,7 @@ public function testSearchRequest(): void $this->assertFalse($result->getResponse()->hasError()); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchScrollRequest(): void { $client = $this->_getClient(); @@ -280,9 +257,8 @@ public function testSearchScrollRequest(): void /** * Default Limit tests for \Elastica\Search. - * - * @group functional */ + #[Group('functional')] public function testLimitDefaultSearch(): void { $client = $this->_getClient(); @@ -329,9 +305,7 @@ public function testLimitDefaultSearch(): void $this->assertEquals(1, $resultSet->count()); } - /** - * @group functional - */ + #[Group('functional')] public function testArrayConfigSearch(): void { $client = $this->_getClient(); @@ -434,9 +408,7 @@ public function testArrayConfigSearch(): void $this->assertTrue($resultSet->hasTimedOut()); } - /** - * @group functional - */ + #[Group('functional')] public function testInvalidConfigSearch(): void { $this->expectException(InvalidException::class); @@ -446,9 +418,7 @@ public function testInvalidConfigSearch(): void $search->search('test', ['invalid_option' => 'invalid_option_value']); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchWithVersionOption(): void { $index = $this->_createIndex(); @@ -470,9 +440,7 @@ public function testSearchWithVersionOption(): void $this->assertEquals(1, $hit->getParam('_version')); } - /** - * @group functional - */ + #[Group('functional')] public function testSearchGet(): void { $client = $this->_getClient(); @@ -482,9 +450,7 @@ public function testSearchGet(): void $this->assertFalse($result->getResponse()->hasError()); } - /** - * @group functional - */ + #[Group('functional')] public function testCountRequest(): void { $client = $this->_getClient(); @@ -538,9 +504,7 @@ public function testCountRequest(): void $this->assertEquals(0, $count); } - /** - * @group functional - */ + #[Group('functional')] public function testCountRequestGet(): void { $client = $this->_getClient(); @@ -594,9 +558,7 @@ public function testCountRequestGet(): void $this->assertEquals(0, $count); } - /** - * @group functional - */ + #[Group('functional')] public function testEmptySearch(): void { $client = $this->_getClient(); @@ -648,9 +610,7 @@ public function testEmptySearch(): void $this->assertEquals('bunny', $source['username']); } - /** - * @group functional - */ + #[Group('functional')] public function testCount(): void { $index = $this->_createIndex(); @@ -671,9 +631,7 @@ public function testCount(): void $this->assertEquals(1, $result2->getTotalHits()); } - /** - * @group functional - */ + #[Group('functional')] public function testIgnoreUnavailableOption(): void { $client = $this->_getClient(); @@ -696,9 +654,7 @@ public function testIgnoreUnavailableOption(): void $search->search($query, [Search::OPTION_SEARCH_IGNORE_UNAVAILABLE => true]); } - /** - * @group functional - */ + #[Group('functional')] public function testQuerySizeAfterCount(): void { $client = $this->_getClient(); diff --git a/tests/SnapshotTest.php b/tests/SnapshotTest.php index 2082e102f..f752c93d2 100644 --- a/tests/SnapshotTest.php +++ b/tests/SnapshotTest.php @@ -8,12 +8,12 @@ use Elastica\Exception\NotFoundException; use Elastica\Index; use Elastica\Snapshot; +use PHPUnit\Framework\Attributes\Group; /** - * @group functional - * * @internal */ +#[Group('functional')] class SnapshotTest extends Base { private const SNAPSHOT_PATH = '/usr/share/elasticsearch/repository/'; @@ -49,9 +49,7 @@ protected function setUp(): void $this->index->refresh(); } - /** - * @group functional - */ + #[Group('functional')] public function testRegisterRepository(): void { $location = $this->registerRepository('backup1'); @@ -68,9 +66,7 @@ public function testRegisterRepository(): void $this->assertTrue($response->isOk()); } - /** - * @group functional - */ + #[Group('functional')] public function testSnapshotAndRestore(): void { $this->registerRepository('backup2'); diff --git a/tests/StatusTest.php b/tests/StatusTest.php index dc7cab020..33eb131ba 100644 --- a/tests/StatusTest.php +++ b/tests/StatusTest.php @@ -8,15 +8,14 @@ use Elastica\Response; use Elastica\Status; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class StatusTest extends BaseTest { - /** - * @group functional - */ + #[Group('functional')] public function testGetResponse(): void { $index = $this->_createIndex(); @@ -24,9 +23,7 @@ public function testGetResponse(): void $this->assertInstanceOf(Response::class, $status->getResponse()); } - /** - * @group functional - */ + #[Group('functional')] public function testGetIndexNames(): void { $client = $this->_getClient(); @@ -49,9 +46,7 @@ public function testGetIndexNames(): void $this->assertSame($indexes, \array_intersect($indexes, $indexNames)); } - /** - * @group functional - */ + #[Group('functional')] public function testIndexExists(): void { $indexName = 'elastica_test'; @@ -74,9 +69,7 @@ public function testIndexExists(): void $this->assertTrue($status->indexExists($indexName)); } - /** - * @group functional - */ + #[Group('functional')] public function testAliasExists(): void { $aliasName = 'elastica_test-alias'; diff --git a/tests/Suggest/CompletionTest.php b/tests/Suggest/CompletionTest.php index 7833319fd..d7ee04ffd 100644 --- a/tests/Suggest/CompletionTest.php +++ b/tests/Suggest/CompletionTest.php @@ -11,15 +11,14 @@ use Elastica\Suggest; use Elastica\Suggest\Completion; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class CompletionTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $suggest = new Completion('suggestName', 'fieldName'); @@ -35,9 +34,7 @@ public function testToArray(): void $this->assertEquals($expected, $suggest->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSuggestWorks(): void { $suggest = new Completion('suggestName', 'fieldName'); @@ -55,9 +52,7 @@ public function testSuggestWorks(): void $this->assertEquals('Nevermind', $options[0]['text']); } - /** - * @group functional - */ + #[Group('functional')] public function testFuzzySuggestWorks(): void { $suggest = new Completion('suggestName', 'fieldName'); @@ -76,9 +71,7 @@ public function testFuzzySuggestWorks(): void $this->assertEquals('Nevermind', $options[0]['text']); } - /** - * @group functional - */ + #[Group('functional')] public function testCompletion(): void { $suggest = new Completion('suggestName1', 'fieldName'); @@ -118,9 +111,7 @@ public function testCompletion(): void $this->assertEquals($expectedSuggestions, $resultSet->getSuggests()); } - /** - * @group unit - */ + #[Group('unit')] public function testSetFuzzy(): void { $suggest = new Completion('suggestName', 'fieldName'); @@ -135,9 +126,7 @@ public function testSetFuzzy(): void $this->assertSame($fuzzy, $suggest->getParam('fuzzy')); } - /** - * @group functional - */ + #[Group('functional')] public function testRegexSuggestWorks(): void { $suggest = new Completion('suggestName', 'fieldName'); diff --git a/tests/Suggest/PhraseTest.php b/tests/Suggest/PhraseTest.php index af091f1a2..5e502adfd 100644 --- a/tests/Suggest/PhraseTest.php +++ b/tests/Suggest/PhraseTest.php @@ -10,18 +10,14 @@ use Elastica\Suggest\CandidateGenerator\DirectGenerator; use Elastica\Suggest\Phrase; use Elastica\Test\Base as BaseTest; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class PhraseTest extends BaseTest { - use ExpectDeprecationTrait; - - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $phraseSuggest = (new Phrase('suggest1', 'text')) @@ -50,9 +46,7 @@ public function testToArray(): void $this->assertEquals($expected, $suggest->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testPhraseSuggest(): void { $phraseSuggest = (new Phrase('suggest1', 'text')) diff --git a/tests/Suggest/TermTest.php b/tests/Suggest/TermTest.php index c573a5bfe..f56c5a2c5 100644 --- a/tests/Suggest/TermTest.php +++ b/tests/Suggest/TermTest.php @@ -9,15 +9,14 @@ use Elastica\Suggest; use Elastica\Suggest\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class TermTest extends BaseTest { - /** - * @group unit - */ + #[Group('unit')] public function testToArray(): void { $suggest = new Suggest(); @@ -53,9 +52,7 @@ public function testToArray(): void $this->assertEquals($expected, $suggest->toArray()); } - /** - * @group unit - */ + #[Group('unit')] public function testDistanceAlgorithm(): void { $suggest = new Suggest(); @@ -93,9 +90,7 @@ public function testDistanceAlgorithm(): void $this->assertEquals($expected, $suggest->toArray()); } - /** - * @group functional - */ + #[Group('functional')] public function testSuggestResults(): void { $suggest = new Suggest(); @@ -119,9 +114,7 @@ public function testSuggestResults(): void $this->assertEquals('food', $suggests['suggest1'][0]['options'][0]['text']); } - /** - * @group functional - */ + #[Group('functional')] public function testSuggestNoResults(): void { $termSuggest = new Term('suggest1', 'text'); diff --git a/tests/SuggestTest.php b/tests/SuggestTest.php index f6648128a..664634812 100644 --- a/tests/SuggestTest.php +++ b/tests/SuggestTest.php @@ -9,6 +9,7 @@ use Elastica\Suggest; use Elastica\Suggest\Term; use Elastica\Test\Base as BaseTest; +use PHPUnit\Framework\Attributes\Group; /** * @internal @@ -17,9 +18,8 @@ class SuggestTest extends BaseTest { /** * Create self test. - * - * @group functional */ + #[Group('functional')] public function testCreateSelf(): void { $suggest = new Suggest(); @@ -31,9 +31,8 @@ public function testCreateSelf(): void /** * Create with suggest test. - * - * @group functional */ + #[Group('functional')] public function testCreateWithSuggest(): void { $suggest1 = new Term('suggest1', '_all'); @@ -45,9 +44,8 @@ public function testCreateWithSuggest(): void /** * Create with non suggest test. - * - * @group functional */ + #[Group('functional')] public function testCreateWithNonSuggest(): void { try { diff --git a/tests/TaskTest.php b/tests/TaskTest.php index fc26a9d8e..67d3ea7d7 100644 --- a/tests/TaskTest.php +++ b/tests/TaskTest.php @@ -7,15 +7,14 @@ use Elastica\Document; use Elastica\Index; use Elastica\Task; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class TaskTest extends Base { - /** - * @group functional - */ + #[Group('functional')] public function testGetData(): void { $task = $this->_createTask(); @@ -25,9 +24,7 @@ public function testGetData(): void $this->assertNotEmpty($data); } - /** - * @group functional - */ + #[Group('functional')] public function testGetId(): void { $task = $this->_createTask(); @@ -37,9 +34,7 @@ public function testGetId(): void $this->assertEquals($task->getId(), \sprintf('%s:%s', $data['task']['node'], $data['task']['id'])); } - /** - * @group functional - */ + #[Group('functional')] public function testIsComplete(): void { $task = $this->_createTask(); @@ -55,9 +50,7 @@ public function testIsComplete(): void $this->assertTrue($task->isCompleted()); } - /** - * @group functional - */ + #[Group('functional')] public function testRefreshWithOptionsContainingOnWaitForResponseTrue(): void { $task = $this->_createTask(); @@ -65,9 +58,7 @@ public function testRefreshWithOptionsContainingOnWaitForResponseTrue(): void $this->assertTrue($task->isCompleted()); } - /** - * @group unit - */ + #[Group('unit')] public function testCancelThrowsExceptionWithEmptyTaskId(): void { $this->expectException(\Exception::class); @@ -77,9 +68,7 @@ public function testCancelThrowsExceptionWithEmptyTaskId(): void $task->cancel(); } - /** - * @group functional - */ + #[Group('functional')] public function testCancelDoesntCancelCompletedTasks(): void { $task = $this->_createTask(); diff --git a/tests/UtilTest.php b/tests/UtilTest.php index cd1f8a483..c3bebb846 100644 --- a/tests/UtilTest.php +++ b/tests/UtilTest.php @@ -6,23 +6,22 @@ use Elastica\Test\Base as BaseTest; use Elastica\Util; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal */ class UtilTest extends BaseTest { - /** - * @group unit - * - * @dataProvider getIsDateMathEscapedPairs - */ + #[Group('unit')] + #[DataProvider('getIsDateMathEscapedPairs')] public function testIsDateMathEscaped($requestUri, $expectedIsEscaped): void { $this->assertEquals($expectedIsEscaped, Util::isDateMathEscaped($requestUri)); } - public function getIsDateMathEscapedPairs(): array + public static function getIsDateMathEscapedPairs(): array { return [ ['', false], @@ -35,17 +34,14 @@ public function getIsDateMathEscapedPairs(): array ]; } - /** - * @group unit - * - * @dataProvider getEscapeDateMathPairs - */ + #[Group('unit')] + #[DataProvider('getEscapeDateMathPairs')] public function testEscapeDateMath($requestUri, $expectedEscapedRequestUri): void { $this->assertEquals($expectedEscapedRequestUri, Util::escapeDateMath($requestUri)); } - public function getEscapeDateMathPairs(): array + public static function getEscapeDateMathPairs(): array { return [ ['', ''], @@ -67,17 +63,14 @@ public function getEscapeDateMathPairs(): array ]; } - /** - * @group unit - * - * @dataProvider getEscapeTermPairs - */ + #[Group('unit')] + #[DataProvider('getEscapeTermPairs')] public function testEscapeTerm($unescaped, $escaped): void { $this->assertEquals($escaped, Util::escapeTerm($unescaped)); } - public function getEscapeTermPairs(): array + public static function getEscapeTermPairs(): array { return [ ['', ''], @@ -89,17 +82,14 @@ public function getEscapeTermPairs(): array ]; } - /** - * @group unit - * - * @dataProvider getReplaceBooleanWordsPairs - */ + #[Group('unit')] + #[DataProvider('getReplaceBooleanWordsPairs')] public function testReplaceBooleanWords($before, $after): void { $this->assertEquals($after, Util::replaceBooleanWords($before)); } - public function getReplaceBooleanWordsPairs(): array + public static function getReplaceBooleanWordsPairs(): array { return [ ['to be OR not to be', 'to be || not to be'], @@ -111,9 +101,7 @@ public function getReplaceBooleanWordsPairs(): array ]; } - /** - * @group unit - */ + #[Group('unit')] public function testEscapeTermSpecialCharacters(): void { $before = '\\+-&&||!(){}[]^"~*?:/<>'; @@ -122,9 +110,7 @@ public function testEscapeTermSpecialCharacters(): void $this->assertEquals(Util::escapeTerm($before), $after); } - /** - * @group unit - */ + #[Group('unit')] public function testToCamelCase(): void { $string = 'hello_world'; @@ -134,9 +120,7 @@ public function testToCamelCase(): void $this->assertEquals('HowAreYouToday', Util::toCamelCase($string)); } - /** - * @group unit - */ + #[Group('unit')] public function testToSnakeCase(): void { $this->assertSame('foo_bar', Util::toSnakeCase('fooBar')); @@ -144,9 +128,7 @@ public function testToSnakeCase(): void $this->assertSame('how_are_you_today', Util::toSnakeCase('HowAreYouToday')); } - /** - * @group unit - */ + #[Group('unit')] public function testConvertDateTimeObjectWithTimezone(): void { $dateTimeObject = new \DateTime(); @@ -159,9 +141,7 @@ public function testConvertDateTimeObjectWithTimezone(): void $this->assertEquals($convertedString, $date); } - /** - * @group unit - */ + #[Group('unit')] public function testConvertDateTimeObjectWithoutTimezone(): void { $dateTimeObject = new \DateTime(); @@ -174,9 +154,7 @@ public function testConvertDateTimeObjectWithoutTimezone(): void $this->assertEquals($convertedString, $date); } - /** - * @group unit - */ + #[Group('unit')] public function testConvertDateWithInt(): void { $dateInt = 1705361024; @@ -188,9 +166,7 @@ public function testConvertDateWithInt(): void $this->assertEquals($convertedString, $date); } - /** - * @group unit - */ + #[Group('unit')] public function testConvertDateWithString(): void { $dateString = 'Mon, 15 Jan 2024 23:23:44 GMT'; diff --git a/tests/WithConsecutive.php b/tests/WithConsecutive.php new file mode 100644 index 000000000..731d9a84c --- /dev/null +++ b/tests/WithConsecutive.php @@ -0,0 +1,76 @@ +with(...WithConsecutive::create(...$withCodes)). + * + * Originally copied from https://gist.github.com/oleg-andreyev/85c74dbf022237b03825c7e9f4439303 and modified + * See also https://github.com/sebastianbergmann/phpunit/issues/4026#issuecomment-1644072411 + */ +final class WithConsecutive +{ + /** + * @param array $parameterGroups + * + * @return array> + */ + public static function create(...$parameterGroups): array + { + $result = []; + $parametersCount = null; + $groups = []; + $values = []; + + foreach ($parameterGroups as $index => $parameters) { + // initial + $parametersCount ??= \count($parameters); + + // compare + if ($parametersCount !== \count($parameters)) { + throw new \RuntimeException('Parameters count max much in all groups'); + } + + // prepare parameters + foreach ($parameters as $parameter) { + if (!$parameter instanceof Constraint) { + $parameter = new IsEqual($parameter); + } + + $groups[$index][] = $parameter; + } + } + + // collect values + foreach ($groups as $parameters) { + foreach ($parameters as $index => $parameter) { + $values[$index][] = $parameter; + } + } + + // build callback + for ($index = 0; $index < $parametersCount; ++$index) { + $result[$index] = Assert::callback(static function ($value) use ($values, $index) { + static $map = null; + $map ??= $values[$index]; + + $expectedArg = \array_shift($map); + + if (null !== $expectedArg) { + $expectedArg->evaluate($value); + } + + return true; + }); + } + + return $result; + } +}