From 4ec48699d52af05b7ba27cda97118e37e15f4aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 13 Sep 2024 21:07:25 +0200 Subject: [PATCH] Make data providers static --- rector.php | 2 + tests/Builder/FieldPathTest.php | 2 +- tests/Builder/Type/CombinedFieldQueryTest.php | 2 +- tests/Builder/Type/OutputWindowTest.php | 4 +- tests/Builder/Type/QueryObjectTest.php | 2 +- tests/Builder/VariableTest.php | 2 +- tests/ClientTest.php | 12 ++-- .../CodecCollectionFunctionalTest.php | 2 +- tests/Collection/CollectionFunctionalTest.php | 30 +++++----- tests/Command/ListCollectionsTest.php | 12 ++-- tests/Command/ListDatabasesTest.php | 14 ++--- tests/Database/DatabaseFunctionalTest.php | 14 ++--- .../InvalidArgumentExceptionTest.php | 2 +- tests/FunctionsTest.php | 18 +++--- tests/GridFS/BucketFunctionalTest.php | 32 +++++------ tests/GridFS/ReadableStreamFunctionalTest.php | 14 ++--- tests/GridFS/WritableStreamFunctionalTest.php | 12 ++-- tests/Model/BSONIteratorTest.php | 2 +- tests/Model/ChangeStreamIteratorTest.php | 4 +- tests/Model/IndexInputTest.php | 6 +- tests/Operation/AggregateFunctionalTest.php | 2 +- tests/Operation/AggregateTest.php | 34 +++++------ tests/Operation/BulkWriteFunctionalTest.php | 4 +- tests/Operation/BulkWriteTest.php | 18 +++--- tests/Operation/CountDocumentsTest.php | 20 +++---- tests/Operation/CountTest.php | 20 +++---- tests/Operation/CreateCollectionTest.php | 48 ++++++++-------- ...reateEncryptedCollectionFunctionalTest.php | 8 +-- .../CreateEncryptedCollectionTest.php | 6 +- .../Operation/CreateIndexesFunctionalTest.php | 2 +- tests/Operation/CreateIndexesTest.php | 16 +++--- .../DatabaseCommandFunctionalTest.php | 2 +- tests/Operation/DatabaseCommandTest.php | 10 ++-- tests/Operation/DeleteTest.php | 18 +++--- tests/Operation/DistinctFunctionalTest.php | 2 +- tests/Operation/DistinctTest.php | 16 +++--- tests/Operation/DropCollectionTest.php | 10 ++-- tests/Operation/DropDatabaseTest.php | 10 ++-- .../Operation/DropEncryptedCollectionTest.php | 6 +- tests/Operation/DropIndexesTest.php | 12 ++-- .../Operation/EstimatedDocumentCountTest.php | 12 ++-- tests/Operation/ExplainFunctionalTest.php | 2 +- tests/Operation/ExplainTest.php | 12 ++-- .../Operation/FindAndModifyFunctionalTest.php | 6 +- tests/Operation/FindAndModifyTest.php | 34 +++++------ tests/Operation/FindFunctionalTest.php | 4 +- tests/Operation/FindOneAndDeleteTest.php | 6 +- tests/Operation/FindOneAndReplaceTest.php | 14 ++--- tests/Operation/FindOneAndUpdateTest.php | 12 ++-- tests/Operation/FindOneFunctionalTest.php | 2 +- tests/Operation/FindTest.php | 56 +++++++++---------- tests/Operation/InsertManyTest.php | 14 ++--- tests/Operation/InsertOneFunctionalTest.php | 4 +- tests/Operation/InsertOneTest.php | 12 ++-- tests/Operation/ListIndexesTest.php | 8 +-- tests/Operation/ListSearchIndexesTest.php | 4 +- tests/Operation/MapReduceFunctionalTest.php | 2 +- tests/Operation/MapReduceTest.php | 40 ++++++------- tests/Operation/ModifyCollectionTest.php | 10 ++-- tests/Operation/RenameCollectionTest.php | 12 ++-- tests/Operation/ReplaceOneTest.php | 6 +- tests/Operation/TestCase.php | 2 +- tests/Operation/UpdateFunctionalTest.php | 2 +- tests/Operation/UpdateTest.php | 20 +++---- tests/Operation/WatchFunctionalTest.php | 2 +- tests/Operation/WatchTest.php | 30 +++++----- tests/PedantryTest.php | 2 +- .../ClientSideEncryptionSpecTest.php | 2 +- .../DocumentsMatchConstraintTest.php | 4 +- tests/TestCase.php | 36 ++++++------ .../Constraint/IsBsonTypeTest.php | 2 +- .../Constraint/MatchesTest.php | 4 +- 72 files changed, 416 insertions(+), 414 deletions(-) diff --git a/rector.php b/rector.php index a51182ee7..31f1f56f6 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,7 @@ use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector; use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector; use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; +use Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { @@ -18,6 +19,7 @@ $rectorConfig->sets([LevelSetList::UP_TO_PHP_74]); $rectorConfig->rule(ChangeSwitchToMatchRector::class); + $rectorConfig->rule(StaticDataProviderClassMethodRector::class); // phpcs:disable Squiz.Arrays.ArrayDeclaration.KeySpecified $rectorConfig->skip([ diff --git a/tests/Builder/FieldPathTest.php b/tests/Builder/FieldPathTest.php index ada1cc164..f8bd3a309 100644 --- a/tests/Builder/FieldPathTest.php +++ b/tests/Builder/FieldPathTest.php @@ -35,7 +35,7 @@ public function testRejectDollarPrefix(string $fieldPathClass): void Expression::{$fieldPathClass}('$foo'); } - public function provideFieldPath(): Generator + public static function provideFieldPath(): Generator { yield 'double' => ['doubleFieldPath', Expression\ResolvesToDouble::class]; yield 'string' => ['stringFieldPath', Expression\ResolvesToString::class]; diff --git a/tests/Builder/Type/CombinedFieldQueryTest.php b/tests/Builder/Type/CombinedFieldQueryTest.php index 1e302f8bd..ab326afd5 100644 --- a/tests/Builder/Type/CombinedFieldQueryTest.php +++ b/tests/Builder/Type/CombinedFieldQueryTest.php @@ -87,7 +87,7 @@ public function testRejectDuplicateOperator(array $fieldQueries): void ]); } - public function provideDuplicateOperator(): Generator + public static function provideDuplicateOperator(): Generator { yield 'array and FieldQuery' => [ [ diff --git a/tests/Builder/Type/OutputWindowTest.php b/tests/Builder/Type/OutputWindowTest.php index fed42a3eb..1527a1826 100644 --- a/tests/Builder/Type/OutputWindowTest.php +++ b/tests/Builder/Type/OutputWindowTest.php @@ -73,7 +73,7 @@ public function testRejectInvalidDocuments(array $documents): void ); } - public function provideInvalidDocuments(): Generator + public static function provideInvalidDocuments(): Generator { yield 'too few' => [[1]]; yield 'too many' => [[1, 2, 3]]; @@ -98,7 +98,7 @@ public function testRejectInvalidRange(array $range): void ); } - public function provideInvalidRange(): Generator + public static function provideInvalidRange(): Generator { yield 'too few' => [[1]]; yield 'too many' => [[1, 2, 3]]; diff --git a/tests/Builder/Type/QueryObjectTest.php b/tests/Builder/Type/QueryObjectTest.php index fe7a86959..cf5b67fde 100644 --- a/tests/Builder/Type/QueryObjectTest.php +++ b/tests/Builder/Type/QueryObjectTest.php @@ -57,7 +57,7 @@ public function testCreateQueryObjectFromArray(array $value, int $expectedCount $this->assertCount($expectedCount, $queryObject->queries); } - public function provideQueryObjectValue(): Generator + public static function provideQueryObjectValue(): Generator { yield 'int' => [['foo' => 1]]; yield 'float' => [['foo' => 1.1]]; diff --git a/tests/Builder/VariableTest.php b/tests/Builder/VariableTest.php index f9273bfe2..dc30134a5 100644 --- a/tests/Builder/VariableTest.php +++ b/tests/Builder/VariableTest.php @@ -35,7 +35,7 @@ public function testSystemVariables($factory): void $this->assertStringStartsNotWith('$$', $variable->name); } - public function provideVariableBuilders(): Generator + public static function provideVariableBuilders(): Generator { yield 'now' => [fn () => Variable::now()]; yield 'clusterTime' => [fn () => Variable::clusterTime()]; diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 584714c98..b830556d8 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -42,29 +42,29 @@ public function testConstructorDriverOptionTypeChecks(array $driverOptions, stri new Client(static::getUri(), [], $driverOptions); } - public function provideInvalidConstructorDriverOptions() + public static function provideInvalidConstructorDriverOptions() { $options = []; - foreach ($this->getInvalidObjectValues() as $value) { + foreach (self::getInvalidObjectValues() as $value) { $options[][] = ['builderEncoder' => $value]; } - foreach ($this->getInvalidArrayValues(true) as $value) { + foreach (self::getInvalidArrayValues(true) as $value) { $options[][] = ['typeMap' => $value]; } $options[][] = ['autoEncryption' => ['keyVaultClient' => 'foo']]; - foreach ($this->getInvalidStringValues() as $value) { + foreach (self::getInvalidStringValues() as $value) { $options[][] = ['driver' => ['name' => $value]]; } - foreach ($this->getInvalidStringValues() as $value) { + foreach (self::getInvalidStringValues() as $value) { $options[][] = ['driver' => ['version' => $value]]; } - foreach ($this->getInvalidStringValues() as $value) { + foreach (self::getInvalidStringValues() as $value) { $options[] = [ 'driverOptions' => ['driver' => ['platform' => $value]], 'exception' => DriverInvalidArgumentException::class, diff --git a/tests/Collection/CodecCollectionFunctionalTest.php b/tests/Collection/CodecCollectionFunctionalTest.php index 2eb0c09dd..d0d33522c 100644 --- a/tests/Collection/CodecCollectionFunctionalTest.php +++ b/tests/Collection/CodecCollectionFunctionalTest.php @@ -151,7 +151,7 @@ public function testBulkWrite($expected, $options): void ); } - public function provideFindOneAndModifyOptions(): Generator + public static function provideFindOneAndModifyOptions(): Generator { yield 'Default codec' => [ 'expected' => TestObject::createDecodedForFixture(1), diff --git a/tests/Collection/CollectionFunctionalTest.php b/tests/Collection/CollectionFunctionalTest.php index e4f6c649a..0f535acf8 100644 --- a/tests/Collection/CollectionFunctionalTest.php +++ b/tests/Collection/CollectionFunctionalTest.php @@ -49,7 +49,7 @@ public function testConstructorCollectionNameArgument($collectionName, string $e new Collection($this->manager, $this->getDatabaseName(), $collectionName); } - public function provideInvalidDatabaseAndCollectionNames() + public static function provideInvalidDatabaseAndCollectionNames() { return [ [null, TypeError::class], @@ -64,15 +64,15 @@ public function testConstructorOptionTypeChecks(array $options): void new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions(): array + public static function provideInvalidConstructorOptions(): array { - return $this->createOptionDataProvider([ - 'builderEncoder' => $this->getInvalidObjectValues(), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'builderEncoder' => self::getInvalidObjectValues(), + 'codec' => self::getInvalidDocumentCodecValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } @@ -210,7 +210,7 @@ public function testDistinctWithTypeMap(array $typeMap, array $expectedDocuments $this->assertEquals($expectedDocuments, $values); } - public function provideTypeMapOptionsAndExpectedDocuments() + public static function provideTypeMapOptionsAndExpectedDocuments() { return [ 'No type map' => [ @@ -448,7 +448,7 @@ public function testMapReduce(): void } } - public function collectionMethodClosures() + public static function collectionMethodClosures() { return [ 'read-only aggregate' => [ @@ -716,18 +716,18 @@ function($collection, $session, $options = []) { ]; } - public function collectionReadMethodClosures(): array + public static function collectionReadMethodClosures(): array { return array_filter( - $this->collectionMethodClosures(), + self::collectionMethodClosures(), fn ($rw) => str_contains($rw[1], 'r'), ); } - public function collectionWriteMethodClosures(): array + public static function collectionWriteMethodClosures(): array { return array_filter( - $this->collectionMethodClosures(), + self::collectionMethodClosures(), fn ($rw) => str_contains($rw[1], 'w'), ); } diff --git a/tests/Command/ListCollectionsTest.php b/tests/Command/ListCollectionsTest.php index 78c90afa6..b1d4b0535 100644 --- a/tests/Command/ListCollectionsTest.php +++ b/tests/Command/ListCollectionsTest.php @@ -15,13 +15,13 @@ public function testConstructorOptionTypeChecks(array $options): void new ListCollections($this->getDatabaseName(), $options); } - public function provideInvalidConstructorOptions(): array + public static function provideInvalidConstructorOptions(): array { - return $this->createOptionDataProvider([ - 'authorizedCollections' => $this->getInvalidBooleanValues(), - 'filter' => $this->getInvalidDocumentValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'session' => $this->getInvalidSessionValues(), + return self::createOptionDataProvider([ + 'authorizedCollections' => self::getInvalidBooleanValues(), + 'filter' => self::getInvalidDocumentValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'session' => self::getInvalidSessionValues(), ]); } } diff --git a/tests/Command/ListDatabasesTest.php b/tests/Command/ListDatabasesTest.php index 92de68afd..4043826cb 100644 --- a/tests/Command/ListDatabasesTest.php +++ b/tests/Command/ListDatabasesTest.php @@ -15,14 +15,14 @@ public function testConstructorOptionTypeChecks(array $options): void new ListDatabases($options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'authorizedDatabases' => $this->getInvalidBooleanValues(), - 'filter' => $this->getInvalidDocumentValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'nameOnly' => $this->getInvalidBooleanValues(), - 'session' => $this->getInvalidSessionValues(), + return self::createOptionDataProvider([ + 'authorizedDatabases' => self::getInvalidBooleanValues(), + 'filter' => self::getInvalidDocumentValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'nameOnly' => self::getInvalidBooleanValues(), + 'session' => self::getInvalidSessionValues(), ]); } } diff --git a/tests/Database/DatabaseFunctionalTest.php b/tests/Database/DatabaseFunctionalTest.php index c5f337bfc..7bf5a2322 100644 --- a/tests/Database/DatabaseFunctionalTest.php +++ b/tests/Database/DatabaseFunctionalTest.php @@ -30,7 +30,7 @@ public function testConstructorDatabaseNameArgument($databaseName, string $expec new Database($this->manager, $databaseName); } - public function provideInvalidDatabaseNames() + public static function provideInvalidDatabaseNames() { return [ [null, TypeError::class], @@ -45,13 +45,13 @@ public function testConstructorOptionTypeChecks(array $options): void new Database($this->manager, $this->getDatabaseName(), $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Exception/InvalidArgumentExceptionTest.php b/tests/Exception/InvalidArgumentExceptionTest.php index c4ab90a1d..a7a13d40a 100644 --- a/tests/Exception/InvalidArgumentExceptionTest.php +++ b/tests/Exception/InvalidArgumentExceptionTest.php @@ -15,7 +15,7 @@ public function testExpectedTypeFormatting($expectedType, $typeString): void $this->assertStringContainsString($typeString, $e->getMessage()); } - public function provideExpectedTypes() + public static function provideExpectedTypes() { yield 'expectedType is a string' => [ 'array', diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index a673ef719..cab0b529a 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -32,7 +32,7 @@ public function testApplyTypeMapToDocument($document, array $typeMap, $expectedD $this->assertEquals($expectedDocument, apply_type_map_to_document($document, $typeMap)); } - public function provideDocumentAndTypeMap() + public static function provideDocumentAndTypeMap() { return [ [ @@ -102,7 +102,7 @@ public function testDocumentToArray($document, array $expectedArray): void $this->assertSame($expectedArray, document_to_array($document)); } - public function provideDocumentsAndExpectedArrays(): array + public static function provideDocumentsAndExpectedArrays(): array { return [ 'array' => [['x' => 1], ['x' => 1]], @@ -122,13 +122,13 @@ public function testDocumentToArrayArgumentTypeCheck($document): void document_to_array($document); } - public function provideInvalidDocumentValuesForChecks(): array + public static function provideInvalidDocumentValuesForChecks(): array { // PackedArray is intentionally left out, as document_to_array is used to convert aggregation pipelines - return $this->wrapValuesForDataProvider([123, 3.14, 'foo', true]); + return self::wrapValuesForDataProvider([123, 3.14, 'foo', true]); } - public function provideDocumentCasts(): array + public static function provideDocumentCasts(): array { // phpcs:disable SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing // phpcs:disable Squiz.Functions.MultiLineFunctionDeclaration @@ -180,7 +180,7 @@ public function testCreateFieldPathTypeMap(array $expected, array $typeMap, $fie $this->assertEquals($expected, create_field_path_type_map($typeMap, $fieldPath)); } - public function provideTypeMapValues() + public static function provideTypeMapValues() { return [ 'No root type' => [ @@ -256,7 +256,7 @@ public function testIsPipeline($expected, $pipeline, $allowEmpty = false): void $this->assertSame($expected, is_pipeline($pipeline, $allowEmpty)); } - public function providePipelines(): array + public static function providePipelines(): array { $valid = [ ['$match' => ['foo' => 'bar']], @@ -320,7 +320,7 @@ public function testIsBuilderPipeline($expected, $pipeline): void $this->assertSame($expected, is_builder_pipeline($pipeline)); } - public function provideStagePipelines(): iterable + public static function provideStagePipelines(): iterable { yield 'empty array' => [false, []]; yield 'array of arrays' => [false, [['$match' => ['x' => 1]]]]; @@ -335,7 +335,7 @@ public function testIsWriteConcernAcknowledged($expected, WriteConcern $writeCon $this->assertSame($expected, is_write_concern_acknowledged($writeConcern)); } - public function provideWriteConcerns(): array + public static function provideWriteConcerns(): array { // Note: WriteConcern constructor prohibits w=-1 or w=0 and journal=true return [ diff --git a/tests/GridFS/BucketFunctionalTest.php b/tests/GridFS/BucketFunctionalTest.php index 795764900..1afaca069 100644 --- a/tests/GridFS/BucketFunctionalTest.php +++ b/tests/GridFS/BucketFunctionalTest.php @@ -71,17 +71,17 @@ public function testConstructorOptionTypeChecks(array $options): void new Bucket($this->manager, $this->getDatabaseName(), $options); } - public function provideInvalidConstructorOptions() - { - return $this->createOptionDataProvider([ - 'bucketName' => $this->getInvalidStringValues(true), - 'chunkSizeBytes' => $this->getInvalidIntegerValues(true), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'disableMD5' => $this->getInvalidBooleanValues(true), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + public static function provideInvalidConstructorOptions() + { + return self::createOptionDataProvider([ + 'bucketName' => self::getInvalidStringValues(true), + 'chunkSizeBytes' => self::getInvalidIntegerValues(true), + 'codec' => self::getInvalidDocumentCodecValues(), + 'disableMD5' => self::getInvalidBooleanValues(true), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } @@ -117,7 +117,7 @@ public function testDelete($input, $expectedChunks): void $this->assertCollectionCount($this->chunksCollection, 0); } - public function provideInputDataAndExpectedChunks() + public static function provideInputDataAndExpectedChunks() { return [ ['', 0], @@ -214,9 +214,9 @@ public function testDownloadToStreamShouldRequireDestinationStream($destination) $this->bucket->downloadToStream('id', $destination); } - public function provideInvalidStreamValues() + public static function provideInvalidStreamValues() { - return $this->wrapValuesForDataProvider($this->getInvalidStreamValues()); + return self::wrapValuesForDataProvider(self::getInvalidStreamValues()); } public function testDownloadToStreamShouldRequireFileToExist(): void @@ -278,7 +278,7 @@ public function testDownloadToStreamByNameShouldRequireFilenameAndRevisionToExis $this->bucket->downloadToStreamByName($filename, $destination, ['revision' => $revision]); } - public function provideNonexistentFilenameAndRevision() + public static function provideNonexistentFilenameAndRevision() { return [ ['filename', 2], @@ -552,7 +552,7 @@ public function testGetFileDocumentForStreamShouldRequireGridFSStreamResource($s public function provideInvalidGridFSStreamValues() { - return $this->wrapValuesForDataProvider(array_merge($this->getInvalidStreamValues(), [$this->createStream()])); + return self::wrapValuesForDataProvider(array_merge(self::getInvalidStreamValues(), [$this->createStream()])); } public function testGetFileIdForStreamUsesTypeMap(): void diff --git a/tests/GridFS/ReadableStreamFunctionalTest.php b/tests/GridFS/ReadableStreamFunctionalTest.php index dba7e0016..9916059c2 100644 --- a/tests/GridFS/ReadableStreamFunctionalTest.php +++ b/tests/GridFS/ReadableStreamFunctionalTest.php @@ -57,15 +57,15 @@ public function testConstructorFileDocumentChecks($file): void new ReadableStream($this->collectionWrapper, $file); } - public function provideInvalidConstructorFileDocuments() + public static function provideInvalidConstructorFileDocuments() { $options = []; - foreach ($this->getInvalidIntegerValues() as $value) { + foreach (self::getInvalidIntegerValues() as $value) { $options[][] = (object) ['_id' => 1, 'chunkSize' => $value, 'length' => 0]; } - foreach ($this->getInvalidIntegerValues() as $value) { + foreach (self::getInvalidIntegerValues() as $value) { $options[][] = (object) ['_id' => 1, 'chunkSize' => 1, 'length' => $value]; } @@ -85,7 +85,7 @@ public function testReadBytes($fileId, $length, $expectedBytes): void $this->assertSame($expectedBytes, $stream->readBytes($length)); } - public function provideFileIdAndExpectedBytes() + public static function provideFileIdAndExpectedBytes() { return [ ['length-0', 0, ''], @@ -221,7 +221,7 @@ function (array $event) use (&$commands): void { $this->assertSame(['find'], $commands); } - public function providePreviousChunkSeekOffsetAndBytes() + public static function providePreviousChunkSeekOffsetAndBytes() { return [ [0, 4, 'abcd'], @@ -255,7 +255,7 @@ function (array $event) use (&$commands): void { $this->assertSame([], $commands); } - public function provideSameChunkSeekOffsetAndBytes() + public static function provideSameChunkSeekOffsetAndBytes() { return [ [4, 4, 'efgh'], @@ -287,7 +287,7 @@ function (array $event) use (&$commands): void { $this->assertSame([], $commands); } - public function provideSubsequentChunkSeekOffsetAndBytes() + public static function provideSubsequentChunkSeekOffsetAndBytes() { return [ [4, 4, 'efgh'], diff --git a/tests/GridFS/WritableStreamFunctionalTest.php b/tests/GridFS/WritableStreamFunctionalTest.php index f87eaf1aa..a46741fae 100644 --- a/tests/GridFS/WritableStreamFunctionalTest.php +++ b/tests/GridFS/WritableStreamFunctionalTest.php @@ -39,12 +39,12 @@ public function testConstructorOptionTypeChecks(array $options): void new WritableStream($this->collectionWrapper, 'filename', $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'chunkSizeBytes' => $this->getInvalidIntegerValues(true), - 'disableMD5' => $this->getInvalidBooleanValues(true), - 'metadata' => $this->getInvalidDocumentValues(), + return self::createOptionDataProvider([ + 'chunkSizeBytes' => self::getInvalidIntegerValues(true), + 'disableMD5' => self::getInvalidBooleanValues(true), + 'metadata' => self::getInvalidDocumentValues(), ]); } @@ -86,7 +86,7 @@ public function testWriteBytesCalculatesMD5($input, $expectedMD5): void $this->assertSameDocument(['md5' => $expectedMD5], $fileDocument); } - public function provideInputDataAndExpectedMD5() + public static function provideInputDataAndExpectedMD5() { return [ ['', 'd41d8cd98f00b204e9800998ecf8427e'], diff --git a/tests/Model/BSONIteratorTest.php b/tests/Model/BSONIteratorTest.php index ff1a8bd1c..3ec945e39 100644 --- a/tests/Model/BSONIteratorTest.php +++ b/tests/Model/BSONIteratorTest.php @@ -33,7 +33,7 @@ public function testValidValues(?array $typeMap, array $expectedDocuments): void $this->assertEquals($expectedDocuments, $results); } - public function provideTypeMapOptionsAndExpectedDocuments(): Generator + public static function provideTypeMapOptionsAndExpectedDocuments(): Generator { yield 'No type map' => [ 'typeMap' => null, diff --git a/tests/Model/ChangeStreamIteratorTest.php b/tests/Model/ChangeStreamIteratorTest.php index 890870445..caba4726c 100644 --- a/tests/Model/ChangeStreamIteratorTest.php +++ b/tests/Model/ChangeStreamIteratorTest.php @@ -64,9 +64,9 @@ public function testPostBatchResumeTokenArgumentTypeCheck($postBatchResumeToken) new ChangeStreamIterator($this->collection->find(), 0, null, $postBatchResumeToken); } - public function provideInvalidObjectValues() + public static function provideInvalidObjectValues() { - return $this->wrapValuesForDataProvider([123, 3.14, 'foo', true, []]); + return self::wrapValuesForDataProvider([123, 3.14, 'foo', true, []]); } public function testPostBatchResumeTokenIsReturnedForLastElementInFirstBatch(): void diff --git a/tests/Model/IndexInputTest.php b/tests/Model/IndexInputTest.php index bc0539b51..6b4051e13 100644 --- a/tests/Model/IndexInputTest.php +++ b/tests/Model/IndexInputTest.php @@ -35,9 +35,9 @@ public function testConstructorShouldRequireKeyFieldOrderToBeNumericOrString($or new IndexInput(['key' => ['x' => $order]]); } - public function provideInvalidFieldOrderValues() + public static function provideInvalidFieldOrderValues() { - return $this->wrapValuesForDataProvider([true, [], new stdClass()]); + return self::wrapValuesForDataProvider([true, [], new stdClass()]); } /** @dataProvider provideInvalidStringValues */ @@ -54,7 +54,7 @@ public function testNameGeneration($expectedName, array|object $key): void $this->assertSame($expectedName, (string) new IndexInput(['key' => $key])); } - public function provideExpectedNameAndKey(): array + public static function provideExpectedNameAndKey(): array { return [ ['x_1', ['x' => 1]], diff --git a/tests/Operation/AggregateFunctionalTest.php b/tests/Operation/AggregateFunctionalTest.php index bd5ccee80..e277d07ed 100644 --- a/tests/Operation/AggregateFunctionalTest.php +++ b/tests/Operation/AggregateFunctionalTest.php @@ -271,7 +271,7 @@ function (array $event): void { ); } - public function provideTypeMapOptionsAndExpectedDocuments() + public static function provideTypeMapOptionsAndExpectedDocuments() { return [ [ diff --git a/tests/Operation/AggregateTest.php b/tests/Operation/AggregateTest.php index 81128dca4..237ddfc69 100644 --- a/tests/Operation/AggregateTest.php +++ b/tests/Operation/AggregateTest.php @@ -24,24 +24,24 @@ public function testConstructorOptionTypeChecks(array $options): void new Aggregate($this->getDatabaseName(), $this->getCollectionName(), [['$match' => ['x' => 1]]], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'allowDiskUse' => $this->getInvalidBooleanValues(), - 'batchSize' => $this->getInvalidIntegerValues(), - 'bypassDocumentValidation' => $this->getInvalidBooleanValues(), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'collation' => $this->getInvalidDocumentValues(), - 'hint' => $this->getInvalidHintValues(), - 'let' => $this->getInvalidDocumentValues(), - 'explain' => $this->getInvalidBooleanValues(), - 'maxAwaitTimeMS' => $this->getInvalidIntegerValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'allowDiskUse' => self::getInvalidBooleanValues(), + 'batchSize' => self::getInvalidIntegerValues(), + 'bypassDocumentValidation' => self::getInvalidBooleanValues(), + 'codec' => self::getInvalidDocumentCodecValues(), + 'collation' => self::getInvalidDocumentValues(), + 'hint' => self::getInvalidHintValues(), + 'let' => self::getInvalidDocumentValues(), + 'explain' => self::getInvalidBooleanValues(), + 'maxAwaitTimeMS' => self::getInvalidIntegerValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Operation/BulkWriteFunctionalTest.php b/tests/Operation/BulkWriteFunctionalTest.php index 46958e324..4bfef2704 100644 --- a/tests/Operation/BulkWriteFunctionalTest.php +++ b/tests/Operation/BulkWriteFunctionalTest.php @@ -87,7 +87,7 @@ function (array $event) use ($expectedDocument): void { ); } - public function provideDocumentsWithIds(): array + public static function provideDocumentsWithIds(): array { $expectedDocument = (object) ['_id' => 1]; @@ -99,7 +99,7 @@ public function provideDocumentsWithIds(): array ]; } - public function provideDocumentsWithoutIds(): array + public static function provideDocumentsWithoutIds(): array { /* Note: _id placeholders must be replaced with generated ObjectIds. We * also clone the value for each data set since tests may need to modify diff --git a/tests/Operation/BulkWriteTest.php b/tests/Operation/BulkWriteTest.php index e0783ad38..214305e57 100644 --- a/tests/Operation/BulkWriteTest.php +++ b/tests/Operation/BulkWriteTest.php @@ -229,9 +229,9 @@ public function testReplaceOneUpsertOptionTypeCheck($upsert): void ]); } - public function provideInvalidBooleanValues() + public static function provideInvalidBooleanValues() { - return $this->wrapValuesForDataProvider($this->getInvalidBooleanValues()); + return self::wrapValuesForDataProvider(self::getInvalidBooleanValues()); } public function testReplaceOneWithCodecRejectsInvalidDocuments(): void @@ -442,14 +442,14 @@ public function testConstructorOptionTypeChecks(array $options): void ); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'bypassDocumentValidation' => $this->getInvalidBooleanValues(), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'ordered' => $this->getInvalidBooleanValues(true), - 'session' => $this->getInvalidSessionValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'bypassDocumentValidation' => self::getInvalidBooleanValues(), + 'codec' => self::getInvalidDocumentCodecValues(), + 'ordered' => self::getInvalidBooleanValues(true), + 'session' => self::getInvalidSessionValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } } diff --git a/tests/Operation/CountDocumentsTest.php b/tests/Operation/CountDocumentsTest.php index 0a16e4399..65e002a46 100644 --- a/tests/Operation/CountDocumentsTest.php +++ b/tests/Operation/CountDocumentsTest.php @@ -23,17 +23,17 @@ public function testConstructorOptionTypeChecks(array $options): void new CountDocuments($this->getDatabaseName(), $this->getCollectionName(), [], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'collation' => $this->getInvalidDocumentValues(), - 'hint' => $this->getInvalidHintValues(), - 'limit' => $this->getInvalidIntegerValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'session' => $this->getInvalidSessionValues(), - 'skip' => $this->getInvalidIntegerValues(), + return self::createOptionDataProvider([ + 'collation' => self::getInvalidDocumentValues(), + 'hint' => self::getInvalidHintValues(), + 'limit' => self::getInvalidIntegerValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'session' => self::getInvalidSessionValues(), + 'skip' => self::getInvalidIntegerValues(), ]); } } diff --git a/tests/Operation/CountTest.php b/tests/Operation/CountTest.php index a096859ae..8d109ae81 100644 --- a/tests/Operation/CountTest.php +++ b/tests/Operation/CountTest.php @@ -24,17 +24,17 @@ public function testConstructorOptionTypeChecks(array $options): void new Count($this->getDatabaseName(), $this->getCollectionName(), [], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'collation' => $this->getInvalidDocumentValues(), - 'hint' => $this->getInvalidHintValues(), - 'limit' => $this->getInvalidIntegerValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'session' => $this->getInvalidSessionValues(), - 'skip' => $this->getInvalidIntegerValues(), + return self::createOptionDataProvider([ + 'collation' => self::getInvalidDocumentValues(), + 'hint' => self::getInvalidHintValues(), + 'limit' => self::getInvalidIntegerValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'session' => self::getInvalidSessionValues(), + 'skip' => self::getInvalidIntegerValues(), ]); } diff --git a/tests/Operation/CreateCollectionTest.php b/tests/Operation/CreateCollectionTest.php index 956fa6ed7..530299ba4 100644 --- a/tests/Operation/CreateCollectionTest.php +++ b/tests/Operation/CreateCollectionTest.php @@ -21,31 +21,31 @@ public function testConstructorOptionTypeChecks(array $options): void new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'autoIndexId' => $this->getInvalidBooleanValues(), - 'capped' => $this->getInvalidBooleanValues(), - 'changeStreamPreAndPostImages' => $this->getInvalidDocumentValues(), - 'clusteredIndex' => $this->getInvalidDocumentValues(), - 'collation' => $this->getInvalidDocumentValues(), - 'encryptedFields' => $this->getInvalidDocumentValues(), - 'expireAfterSeconds' => $this->getInvalidIntegerValues(), - 'flags' => $this->getInvalidIntegerValues(), - 'indexOptionDefaults' => $this->getInvalidDocumentValues(), - 'max' => $this->getInvalidIntegerValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'pipeline' => $this->getInvalidArrayValues(), - 'session' => $this->getInvalidSessionValues(), - 'size' => $this->getInvalidIntegerValues(), - 'storageEngine' => $this->getInvalidDocumentValues(), - 'timeseries' => $this->getInvalidDocumentValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'validationAction' => $this->getInvalidStringValues(), - 'validationLevel' => $this->getInvalidStringValues(), - 'validator' => $this->getInvalidDocumentValues(), - 'viewOn' => $this->getInvalidStringValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'autoIndexId' => self::getInvalidBooleanValues(), + 'capped' => self::getInvalidBooleanValues(), + 'changeStreamPreAndPostImages' => self::getInvalidDocumentValues(), + 'clusteredIndex' => self::getInvalidDocumentValues(), + 'collation' => self::getInvalidDocumentValues(), + 'encryptedFields' => self::getInvalidDocumentValues(), + 'expireAfterSeconds' => self::getInvalidIntegerValues(), + 'flags' => self::getInvalidIntegerValues(), + 'indexOptionDefaults' => self::getInvalidDocumentValues(), + 'max' => self::getInvalidIntegerValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'pipeline' => self::getInvalidArrayValues(), + 'session' => self::getInvalidSessionValues(), + 'size' => self::getInvalidIntegerValues(), + 'storageEngine' => self::getInvalidDocumentValues(), + 'timeseries' => self::getInvalidDocumentValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'validationAction' => self::getInvalidStringValues(), + 'validationLevel' => self::getInvalidStringValues(), + 'validator' => self::getInvalidDocumentValues(), + 'viewOn' => self::getInvalidStringValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Operation/CreateEncryptedCollectionFunctionalTest.php b/tests/Operation/CreateEncryptedCollectionFunctionalTest.php index dde1f7d4e..4c851edff 100644 --- a/tests/Operation/CreateEncryptedCollectionFunctionalTest.php +++ b/tests/Operation/CreateEncryptedCollectionFunctionalTest.php @@ -73,7 +73,7 @@ public function testCreateDataKeysNopIfFieldsIsMissing($input, array $expectedOu $this->assertSame($expectedOutput, $encryptedFieldsOutput); } - public function provideEncryptedFieldsAndFieldsIsMissing(): array + public static function provideEncryptedFieldsAndFieldsIsMissing(): array { $ef = []; @@ -104,7 +104,7 @@ public function testCreateDataKeysNopIfFieldsHasInvalidType($input, array $expec $this->assertSame($expectedOutput, $encryptedFieldsOutput); } - public function provideEncryptedFieldsAndFieldsHasInvalidType(): array + public static function provideEncryptedFieldsAndFieldsHasInvalidType(): array { $ef = ['fields' => 'not-an-array']; @@ -135,7 +135,7 @@ public function testCreateDataKeysSkipsNonDocumentFields($input, array $expected $this->assertSame($expectedOutput, $encryptedFieldsOutput); } - public function provideEncryptedFieldsElementHasInvalidType(): array + public static function provideEncryptedFieldsElementHasInvalidType(): array { $ef = ['fields' => ['not-an-array-or-object']]; @@ -190,7 +190,7 @@ public function testEncryptedFieldsDocuments($input): void $this->assertInstanceOf(Binary::class, $modifiedEncryptedFields['fields'][0]['keyId'] ?? null); } - public function provideEncryptedFields(): array + public static function provideEncryptedFields(): array { $ef = ['fields' => [['path' => 'ssn', 'bsonType' => 'string', 'keyId' => null]]]; diff --git a/tests/Operation/CreateEncryptedCollectionTest.php b/tests/Operation/CreateEncryptedCollectionTest.php index c3c22f5e3..fc38bc830 100644 --- a/tests/Operation/CreateEncryptedCollectionTest.php +++ b/tests/Operation/CreateEncryptedCollectionTest.php @@ -15,14 +15,14 @@ public function testConstructorOptionTypeChecks(array $options): void new CreateEncryptedCollection($this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions(): Generator + public static function provideInvalidConstructorOptions(): Generator { yield 'encryptedFields is required' => [ [], ]; - yield from $this->createOptionDataProvider([ - 'encryptedFields' => $this->getInvalidDocumentValues(), + yield from self::createOptionDataProvider([ + 'encryptedFields' => self::getInvalidDocumentValues(), ]); } } diff --git a/tests/Operation/CreateIndexesFunctionalTest.php b/tests/Operation/CreateIndexesFunctionalTest.php index 4204465d7..0b60868cf 100644 --- a/tests/Operation/CreateIndexesFunctionalTest.php +++ b/tests/Operation/CreateIndexesFunctionalTest.php @@ -121,7 +121,7 @@ public function testCreateIndexes(callable $cast): void }); } - public function provideKeyCasts(): array + public static function provideKeyCasts(): array { // phpcs:disable SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing // phpcs:disable Squiz.Functions.MultiLineFunctionDeclaration diff --git a/tests/Operation/CreateIndexesTest.php b/tests/Operation/CreateIndexesTest.php index 04e0e86ba..2647bcc46 100644 --- a/tests/Operation/CreateIndexesTest.php +++ b/tests/Operation/CreateIndexesTest.php @@ -25,14 +25,14 @@ public function testConstructorOptionTypeChecks(array $options): void new CreateIndexes($this->getDatabaseName(), $this->getCollectionName(), [['key' => ['x' => 1]]], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ + return self::createOptionDataProvider([ // commitQuorum is int|string, for which no helper exists 'commitQuorum' => ['float' => 3.14, 'bool' => true, 'array' => [], 'object' => new stdClass()], - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'session' => $this->getInvalidSessionValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'session' => self::getInvalidSessionValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } @@ -51,9 +51,9 @@ public function testConstructorRequiresIndexSpecificationsToBeAnArray($index): v new CreateIndexes($this->getDatabaseName(), $this->getCollectionName(), [$index]); } - public function provideInvalidIndexSpecificationTypes() + public static function provideInvalidIndexSpecificationTypes() { - return $this->wrapValuesForDataProvider($this->getInvalidArrayValues()); + return self::wrapValuesForDataProvider(self::getInvalidArrayValues()); } public function testConstructorRequiresIndexSpecificationKey(): void @@ -79,7 +79,7 @@ public function testConstructorValidatesIndexSpecificationKeyOrder($key): void new CreateIndexes($this->getDatabaseName(), $this->getCollectionName(), [['key' => $key]]); } - public function provideKeyDocumentsWithInvalidOrder(): Generator + public static function provideKeyDocumentsWithInvalidOrder(): Generator { $invalidOrderValues = [true, [], new stdClass(), null]; diff --git a/tests/Operation/DatabaseCommandFunctionalTest.php b/tests/Operation/DatabaseCommandFunctionalTest.php index 4381718e8..ed4bb85a1 100644 --- a/tests/Operation/DatabaseCommandFunctionalTest.php +++ b/tests/Operation/DatabaseCommandFunctionalTest.php @@ -28,7 +28,7 @@ function (array $event): void { ); } - public function provideCommandDocuments(): array + public static function provideCommandDocuments(): array { return [ 'array' => [['ping' => 1]], diff --git a/tests/Operation/DatabaseCommandTest.php b/tests/Operation/DatabaseCommandTest.php index 74b3d8343..869f0c7c3 100644 --- a/tests/Operation/DatabaseCommandTest.php +++ b/tests/Operation/DatabaseCommandTest.php @@ -23,12 +23,12 @@ public function testConstructorOptionTypeChecks(array $options): void new DatabaseCommand($this->getDatabaseName(), ['ping' => 1], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), + return self::createOptionDataProvider([ + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), ]); } } diff --git a/tests/Operation/DeleteTest.php b/tests/Operation/DeleteTest.php index 25d3b5ccf..818689610 100644 --- a/tests/Operation/DeleteTest.php +++ b/tests/Operation/DeleteTest.php @@ -37,9 +37,9 @@ public function testConstructorLimitArgumentMustBeOneOrZero($limit): void new Delete($this->getDatabaseName(), $this->getCollectionName(), [], $limit); } - public function provideInvalidLimitValues() + public static function provideInvalidLimitValues() { - return $this->wrapValuesForDataProvider([-1, 2]); + return self::wrapValuesForDataProvider([-1, 2]); } /** @dataProvider provideInvalidConstructorOptions */ @@ -49,14 +49,14 @@ public function testConstructorOptionTypeChecks(array $options): void new Delete($this->getDatabaseName(), $this->getCollectionName(), [], 1, $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'collation' => $this->getInvalidDocumentValues(), - 'hint' => $this->getInvalidHintValues(), - 'let' => $this->getInvalidDocumentValues(), - 'session' => $this->getInvalidSessionValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'collation' => self::getInvalidDocumentValues(), + 'hint' => self::getInvalidHintValues(), + 'let' => self::getInvalidDocumentValues(), + 'session' => self::getInvalidSessionValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Operation/DistinctFunctionalTest.php b/tests/Operation/DistinctFunctionalTest.php index 625053bd9..dda1fc764 100644 --- a/tests/Operation/DistinctFunctionalTest.php +++ b/tests/Operation/DistinctFunctionalTest.php @@ -118,7 +118,7 @@ public function testTypeMapOption(array $typeMap, array $expectedDocuments): voi $this->assertEquals($expectedDocuments, $values); } - public function provideTypeMapOptionsAndExpectedDocuments() + public static function provideTypeMapOptionsAndExpectedDocuments() { return [ 'No type map' => [ diff --git a/tests/Operation/DistinctTest.php b/tests/Operation/DistinctTest.php index 77380f249..e181abb0a 100644 --- a/tests/Operation/DistinctTest.php +++ b/tests/Operation/DistinctTest.php @@ -25,15 +25,15 @@ public function testConstructorOptionTypeChecks(array $options): void new Distinct($this->getDatabaseName(), $this->getCollectionName(), 'x', [], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'collation' => $this->getInvalidDocumentValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), + return self::createOptionDataProvider([ + 'collation' => self::getInvalidDocumentValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), ]); } diff --git a/tests/Operation/DropCollectionTest.php b/tests/Operation/DropCollectionTest.php index eb3ddf76d..dda688686 100644 --- a/tests/Operation/DropCollectionTest.php +++ b/tests/Operation/DropCollectionTest.php @@ -14,12 +14,12 @@ public function testConstructorOptionTypeChecks(array $options): void new DropCollection($this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } } diff --git a/tests/Operation/DropDatabaseTest.php b/tests/Operation/DropDatabaseTest.php index 04a5c763f..4bdc69192 100644 --- a/tests/Operation/DropDatabaseTest.php +++ b/tests/Operation/DropDatabaseTest.php @@ -14,12 +14,12 @@ public function testConstructorOptionTypeChecks(array $options): void new DropDatabase($this->getDatabaseName(), $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } } diff --git a/tests/Operation/DropEncryptedCollectionTest.php b/tests/Operation/DropEncryptedCollectionTest.php index 4cb0a2401..669cc8590 100644 --- a/tests/Operation/DropEncryptedCollectionTest.php +++ b/tests/Operation/DropEncryptedCollectionTest.php @@ -15,14 +15,14 @@ public function testConstructorOptionTypeChecks(array $options): void new DropEncryptedCollection($this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions(): Generator + public static function provideInvalidConstructorOptions(): Generator { yield 'encryptedFields is required' => [ [], ]; - yield from $this->createOptionDataProvider([ - 'encryptedFields' => $this->getInvalidDocumentValues(), + yield from self::createOptionDataProvider([ + 'encryptedFields' => self::getInvalidDocumentValues(), ]); } } diff --git a/tests/Operation/DropIndexesTest.php b/tests/Operation/DropIndexesTest.php index 5fc021071..c90ca1376 100644 --- a/tests/Operation/DropIndexesTest.php +++ b/tests/Operation/DropIndexesTest.php @@ -20,13 +20,13 @@ public function testConstructorOptionTypeChecks(array $options): void new DropIndexes($this->getDatabaseName(), $this->getCollectionName(), '*', $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } } diff --git a/tests/Operation/EstimatedDocumentCountTest.php b/tests/Operation/EstimatedDocumentCountTest.php index bf090c50d..f1b4c9211 100644 --- a/tests/Operation/EstimatedDocumentCountTest.php +++ b/tests/Operation/EstimatedDocumentCountTest.php @@ -14,13 +14,13 @@ public function testConstructorOptionTypeChecks(array $options): void new EstimatedDocumentCount($this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'session' => $this->getInvalidSessionValues(), + return self::createOptionDataProvider([ + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'session' => self::getInvalidSessionValues(), ]); } } diff --git a/tests/Operation/ExplainFunctionalTest.php b/tests/Operation/ExplainFunctionalTest.php index 19b59dc5f..d772d8bca 100644 --- a/tests/Operation/ExplainFunctionalTest.php +++ b/tests/Operation/ExplainFunctionalTest.php @@ -360,7 +360,7 @@ public function testAggregateOptimizedToQuery($verbosity, $executionStatsExpecte $this->assertExplainResult($result, $executionStatsExpected, $allPlansExecutionExpected); } - public function provideVerbosityInformation() + public static function provideVerbosityInformation() { return [ [Explain::VERBOSITY_ALL_PLANS, true, true], diff --git a/tests/Operation/ExplainTest.php b/tests/Operation/ExplainTest.php index 3b202de03..98937a1ca 100644 --- a/tests/Operation/ExplainTest.php +++ b/tests/Operation/ExplainTest.php @@ -16,13 +16,13 @@ public function testConstructorOptionTypeChecks(array $options): void new Explain($this->getDatabaseName(), $explainable, $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'verbosity' => $this->getInvalidStringValues(), + return self::createOptionDataProvider([ + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'verbosity' => self::getInvalidStringValues(), ]); } } diff --git a/tests/Operation/FindAndModifyFunctionalTest.php b/tests/Operation/FindAndModifyFunctionalTest.php index 05e819132..99235c6c4 100644 --- a/tests/Operation/FindAndModifyFunctionalTest.php +++ b/tests/Operation/FindAndModifyFunctionalTest.php @@ -35,7 +35,7 @@ function (array $event) use ($expectedQuery): void { ); } - public function provideQueryDocuments(): array + public static function provideQueryDocuments(): array { $expected = (object) ['x' => 1]; @@ -74,7 +74,7 @@ function (array $event) use ($expectedUpdate): void { ); } - public function provideReplacementDocumentLikePipeline(): array + public static function provideReplacementDocumentLikePipeline(): array { /* Note: this expected value differs from UpdateFunctionalTest because * FindAndModify is not affected by libmongoc's pipeline detection for @@ -251,7 +251,7 @@ public function testTypeMapOption(?array $typeMap, $expectedDocument): void $this->assertEquals($expectedDocument, $document); } - public function provideTypeMapOptionsAndExpectedDocument() + public static function provideTypeMapOptionsAndExpectedDocument() { return [ [ diff --git a/tests/Operation/FindAndModifyTest.php b/tests/Operation/FindAndModifyTest.php index 65676d289..a6049ed78 100644 --- a/tests/Operation/FindAndModifyTest.php +++ b/tests/Operation/FindAndModifyTest.php @@ -15,24 +15,24 @@ public function testConstructorOptionTypeChecks(array $options): void new FindAndModify($this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'arrayFilters' => $this->getInvalidArrayValues(), - 'bypassDocumentValidation' => $this->getInvalidBooleanValues(), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'collation' => $this->getInvalidDocumentValues(), - 'fields' => $this->getInvalidDocumentValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'new' => $this->getInvalidBooleanValues(), - 'query' => $this->getInvalidDocumentValues(), - 'remove' => $this->getInvalidBooleanValues(), - 'session' => $this->getInvalidSessionValues(), - 'sort' => $this->getInvalidDocumentValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'update' => $this->getInvalidUpdateValues(), - 'upsert' => $this->getInvalidBooleanValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'arrayFilters' => self::getInvalidArrayValues(), + 'bypassDocumentValidation' => self::getInvalidBooleanValues(), + 'codec' => self::getInvalidDocumentCodecValues(), + 'collation' => self::getInvalidDocumentValues(), + 'fields' => self::getInvalidDocumentValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'new' => self::getInvalidBooleanValues(), + 'query' => self::getInvalidDocumentValues(), + 'remove' => self::getInvalidBooleanValues(), + 'session' => self::getInvalidSessionValues(), + 'sort' => self::getInvalidDocumentValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'update' => self::getInvalidUpdateValues(), + 'upsert' => self::getInvalidBooleanValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Operation/FindFunctionalTest.php b/tests/Operation/FindFunctionalTest.php index 2b70a421b..9e36d664a 100644 --- a/tests/Operation/FindFunctionalTest.php +++ b/tests/Operation/FindFunctionalTest.php @@ -56,7 +56,7 @@ function (array $event) use ($expectedSort): void { ); } - public function provideModifierDocuments(): array + public static function provideModifierDocuments(): array { $expectedSort = (object) ['x' => 1]; @@ -168,7 +168,7 @@ public function testTypeMapOption(array $typeMap, array $expectedDocuments): voi $this->assertEquals($expectedDocuments, $cursor->toArray()); } - public function provideTypeMapOptionsAndExpectedDocuments() + public static function provideTypeMapOptionsAndExpectedDocuments() { return [ [ diff --git a/tests/Operation/FindOneAndDeleteTest.php b/tests/Operation/FindOneAndDeleteTest.php index c4cbda6a8..76f18bda4 100644 --- a/tests/Operation/FindOneAndDeleteTest.php +++ b/tests/Operation/FindOneAndDeleteTest.php @@ -24,10 +24,10 @@ public function testConstructorOptionTypeChecks(array $options): void new FindOneAndDelete($this->getDatabaseName(), $this->getCollectionName(), [], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'projection' => $this->getInvalidDocumentValues(), + return self::createOptionDataProvider([ + 'projection' => self::getInvalidDocumentValues(), ]); } diff --git a/tests/Operation/FindOneAndReplaceTest.php b/tests/Operation/FindOneAndReplaceTest.php index 33681f7d4..c71946ec7 100644 --- a/tests/Operation/FindOneAndReplaceTest.php +++ b/tests/Operation/FindOneAndReplaceTest.php @@ -59,12 +59,12 @@ public function testConstructorOptionTypeChecks(array $options): void new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), [], [], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'codec' => $this->getInvalidDocumentCodecValues(), - 'projection' => $this->getInvalidDocumentValues(), - 'returnDocument' => $this->getInvalidIntegerValues(true), + return self::createOptionDataProvider([ + 'codec' => self::getInvalidDocumentCodecValues(), + 'projection' => self::getInvalidDocumentValues(), + 'returnDocument' => self::getInvalidIntegerValues(true), ]); } @@ -75,9 +75,9 @@ public function testConstructorReturnDocumentOption($returnDocument): void new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), [], [], ['returnDocument' => $returnDocument]); } - public function provideInvalidConstructorReturnDocumentOptions() + public static function provideInvalidConstructorReturnDocumentOptions() { - return $this->wrapValuesForDataProvider([-1, 0, 3]); + return self::wrapValuesForDataProvider([-1, 0, 3]); } public function testExplainableCommandDocument(): void diff --git a/tests/Operation/FindOneAndUpdateTest.php b/tests/Operation/FindOneAndUpdateTest.php index f0917a856..54defcad6 100644 --- a/tests/Operation/FindOneAndUpdateTest.php +++ b/tests/Operation/FindOneAndUpdateTest.php @@ -42,11 +42,11 @@ public function testConstructorOptionTypeChecks(array $options): void new FindOneAndUpdate($this->getDatabaseName(), $this->getCollectionName(), [], ['$set' => ['x' => 1]], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'projection' => $this->getInvalidDocumentValues(), - 'returnDocument' => $this->getInvalidIntegerValues(), + return self::createOptionDataProvider([ + 'projection' => self::getInvalidDocumentValues(), + 'returnDocument' => self::getInvalidIntegerValues(), ]); } @@ -57,9 +57,9 @@ public function testConstructorReturnDocumentOption($returnDocument): void new FindOneAndUpdate($this->getDatabaseName(), $this->getCollectionName(), [], [], ['returnDocument' => $returnDocument]); } - public function provideInvalidConstructorReturnDocumentOptions() + public static function provideInvalidConstructorReturnDocumentOptions() { - return $this->wrapValuesForDataProvider([-1, 0, 3]); + return self::wrapValuesForDataProvider([-1, 0, 3]); } public function testExplainableCommandDocument(): void diff --git a/tests/Operation/FindOneFunctionalTest.php b/tests/Operation/FindOneFunctionalTest.php index 57e01f442..6ae0a28da 100644 --- a/tests/Operation/FindOneFunctionalTest.php +++ b/tests/Operation/FindOneFunctionalTest.php @@ -20,7 +20,7 @@ public function testTypeMapOption(array $typeMap, $expectedDocument): void $this->assertEquals($expectedDocument, $document); } - public function provideTypeMapOptionsAndExpectedDocument() + public static function provideTypeMapOptionsAndExpectedDocument() { return [ [ diff --git a/tests/Operation/FindTest.php b/tests/Operation/FindTest.php index 806b883ce..9e398650d 100644 --- a/tests/Operation/FindTest.php +++ b/tests/Operation/FindTest.php @@ -25,33 +25,33 @@ public function testConstructorOptionTypeChecks(array $options): void new Find($this->getDatabaseName(), $this->getCollectionName(), [], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'allowPartialResults' => $this->getInvalidBooleanValues(), - 'batchSize' => $this->getInvalidIntegerValues(), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'collation' => $this->getInvalidDocumentValues(), - 'cursorType' => $this->getInvalidIntegerValues(), - 'hint' => $this->getInvalidHintValues(), - 'limit' => $this->getInvalidIntegerValues(), - 'max' => $this->getInvalidDocumentValues(), - 'maxAwaitTimeMS' => $this->getInvalidIntegerValues(), - 'maxScan' => $this->getInvalidIntegerValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'min' => $this->getInvalidDocumentValues(), - 'modifiers' => $this->getInvalidDocumentValues(), - 'oplogReplay' => $this->getInvalidBooleanValues(), - 'projection' => $this->getInvalidDocumentValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'returnKey' => $this->getInvalidBooleanValues(), - 'session' => $this->getInvalidSessionValues(), - 'showRecordId' => $this->getInvalidBooleanValues(), - 'skip' => $this->getInvalidIntegerValues(), - 'snapshot' => $this->getInvalidBooleanValues(), - 'sort' => $this->getInvalidDocumentValues(), - 'typeMap' => $this->getInvalidArrayValues(), + return self::createOptionDataProvider([ + 'allowPartialResults' => self::getInvalidBooleanValues(), + 'batchSize' => self::getInvalidIntegerValues(), + 'codec' => self::getInvalidDocumentCodecValues(), + 'collation' => self::getInvalidDocumentValues(), + 'cursorType' => self::getInvalidIntegerValues(), + 'hint' => self::getInvalidHintValues(), + 'limit' => self::getInvalidIntegerValues(), + 'max' => self::getInvalidDocumentValues(), + 'maxAwaitTimeMS' => self::getInvalidIntegerValues(), + 'maxScan' => self::getInvalidIntegerValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'min' => self::getInvalidDocumentValues(), + 'modifiers' => self::getInvalidDocumentValues(), + 'oplogReplay' => self::getInvalidBooleanValues(), + 'projection' => self::getInvalidDocumentValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'returnKey' => self::getInvalidBooleanValues(), + 'session' => self::getInvalidSessionValues(), + 'showRecordId' => self::getInvalidBooleanValues(), + 'skip' => self::getInvalidIntegerValues(), + 'snapshot' => self::getInvalidBooleanValues(), + 'sort' => self::getInvalidDocumentValues(), + 'typeMap' => self::getInvalidArrayValues(), ]); } @@ -80,9 +80,9 @@ public function testConstructorCursorTypeOption($cursorType): void new Find($this->getDatabaseName(), $this->getCollectionName(), [], ['cursorType' => $cursorType]); } - public function provideInvalidConstructorCursorTypeOptions() + public static function provideInvalidConstructorCursorTypeOptions() { - return $this->wrapValuesForDataProvider([-1, 0, 4]); + return self::wrapValuesForDataProvider([-1, 0, 4]); } public function testExplainableCommandDocument(): void diff --git a/tests/Operation/InsertManyTest.php b/tests/Operation/InsertManyTest.php index ece556cae..52f32d2cf 100644 --- a/tests/Operation/InsertManyTest.php +++ b/tests/Operation/InsertManyTest.php @@ -38,14 +38,14 @@ public function testConstructorOptionTypeChecks(array $options): void new InsertMany($this->getDatabaseName(), $this->getCollectionName(), [['x' => 1]], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'bypassDocumentValidation' => $this->getInvalidBooleanValues(), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'ordered' => $this->getInvalidBooleanValues(true), - 'session' => $this->getInvalidSessionValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'bypassDocumentValidation' => self::getInvalidBooleanValues(), + 'codec' => self::getInvalidDocumentCodecValues(), + 'ordered' => self::getInvalidBooleanValues(true), + 'session' => self::getInvalidSessionValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Operation/InsertOneFunctionalTest.php b/tests/Operation/InsertOneFunctionalTest.php index 2075f0fc0..a3101b158 100644 --- a/tests/Operation/InsertOneFunctionalTest.php +++ b/tests/Operation/InsertOneFunctionalTest.php @@ -53,7 +53,7 @@ function (array $event) use ($expectedDocument): void { ); } - public function provideDocumentsWithIds(): array + public static function provideDocumentsWithIds(): array { $expectedDocument = (object) ['_id' => 1]; @@ -65,7 +65,7 @@ public function provideDocumentsWithIds(): array ]; } - public function provideDocumentsWithoutIds(): array + public static function provideDocumentsWithoutIds(): array { /* Note: _id placeholders must be replaced with generated ObjectIds. We * also clone the value for each data set since tests may need to modify diff --git a/tests/Operation/InsertOneTest.php b/tests/Operation/InsertOneTest.php index ad325cd0b..6f493d9d1 100644 --- a/tests/Operation/InsertOneTest.php +++ b/tests/Operation/InsertOneTest.php @@ -25,13 +25,13 @@ public function testConstructorOptionTypeChecks(array $options): void new InsertOne($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'bypassDocumentValidation' => $this->getInvalidBooleanValues(), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'session' => $this->getInvalidSessionValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'bypassDocumentValidation' => self::getInvalidBooleanValues(), + 'codec' => self::getInvalidDocumentCodecValues(), + 'session' => self::getInvalidSessionValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Operation/ListIndexesTest.php b/tests/Operation/ListIndexesTest.php index 7edda8ef3..690eb4bca 100644 --- a/tests/Operation/ListIndexesTest.php +++ b/tests/Operation/ListIndexesTest.php @@ -14,11 +14,11 @@ public function testConstructorOptionTypeChecks(array $options): void new ListIndexes($this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'session' => $this->getInvalidSessionValues(), + return self::createOptionDataProvider([ + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'session' => self::getInvalidSessionValues(), ]); } } diff --git a/tests/Operation/ListSearchIndexesTest.php b/tests/Operation/ListSearchIndexesTest.php index 23bc770ef..b07909351 100644 --- a/tests/Operation/ListSearchIndexesTest.php +++ b/tests/Operation/ListSearchIndexesTest.php @@ -20,11 +20,11 @@ public function testConstructorOptionTypeChecks(array $options): void new ListSearchIndexes($this->getDatabaseName(), $this->getCollectionName(), $options); } - public function provideInvalidConstructorOptions(): array + public static function provideInvalidConstructorOptions(): array { $options = []; - foreach ($this->getInvalidIntegerValues() as $value) { + foreach (self::getInvalidIntegerValues() as $value) { $options[][] = ['batchSize' => $value]; } diff --git a/tests/Operation/MapReduceFunctionalTest.php b/tests/Operation/MapReduceFunctionalTest.php index cc4084c71..08fbb9672 100644 --- a/tests/Operation/MapReduceFunctionalTest.php +++ b/tests/Operation/MapReduceFunctionalTest.php @@ -228,7 +228,7 @@ public function testTypeMapOptionWithInlineResults(?array $typeMap, array $expec $this->assertEquals($this->sortResults($expectedDocuments), $this->sortResults($results)); } - public function provideTypeMapOptionsAndExpectedDocuments() + public static function provideTypeMapOptionsAndExpectedDocuments() { return [ [ diff --git a/tests/Operation/MapReduceTest.php b/tests/Operation/MapReduceTest.php index 92e6881c1..8a18d2da2 100644 --- a/tests/Operation/MapReduceTest.php +++ b/tests/Operation/MapReduceTest.php @@ -25,9 +25,9 @@ public function testConstructorOutArgumentTypeCheck($out): void new MapReduce($this->getDatabaseName(), $this->getCollectionName(), $map, $reduce, $out); } - public function provideInvalidOutValues() + public static function provideInvalidOutValues() { - return $this->wrapValuesForDataProvider([123, 3.14, true]); + return self::wrapValuesForDataProvider([123, 3.14, true]); } /** @dataProvider provideDeprecatedOutValues */ @@ -41,7 +41,7 @@ public function testConstructorOutArgumentDeprecations($out): void }); } - public function provideDeprecatedOutValues(): array + public static function provideDeprecatedOutValues(): array { return [ 'nonAtomic:array' => [['nonAtomic' => false]], @@ -66,24 +66,24 @@ public function testConstructorOptionTypeChecks(array $options): void new MapReduce($this->getDatabaseName(), $this->getCollectionName(), $map, $reduce, $out, $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'bypassDocumentValidation' => $this->getInvalidBooleanValues(), - 'collation' => $this->getInvalidDocumentValues(), - 'finalize' => $this->getInvalidJavascriptValues(), - 'jsMode' => $this->getInvalidBooleanValues(), - 'limit' => $this->getInvalidIntegerValues(), - 'maxTimeMS' => $this->getInvalidIntegerValues(), - 'query' => $this->getInvalidDocumentValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(), - 'scope' => $this->getInvalidDocumentValues(), - 'session' => $this->getInvalidSessionValues(), - 'sort' => $this->getInvalidDocumentValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'verbose' => $this->getInvalidBooleanValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'bypassDocumentValidation' => self::getInvalidBooleanValues(), + 'collation' => self::getInvalidDocumentValues(), + 'finalize' => self::getInvalidJavascriptValues(), + 'jsMode' => self::getInvalidBooleanValues(), + 'limit' => self::getInvalidIntegerValues(), + 'maxTimeMS' => self::getInvalidIntegerValues(), + 'query' => self::getInvalidDocumentValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(), + 'scope' => self::getInvalidDocumentValues(), + 'session' => self::getInvalidSessionValues(), + 'sort' => self::getInvalidDocumentValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'verbose' => self::getInvalidBooleanValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Operation/ModifyCollectionTest.php b/tests/Operation/ModifyCollectionTest.php index dfa8d2584..8369d341e 100644 --- a/tests/Operation/ModifyCollectionTest.php +++ b/tests/Operation/ModifyCollectionTest.php @@ -21,12 +21,12 @@ public function testConstructorOptionTypeChecks(array $options): void new ModifyCollection($this->getDatabaseName(), $this->getCollectionName(), [], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } } diff --git a/tests/Operation/RenameCollectionTest.php b/tests/Operation/RenameCollectionTest.php index f1d0e15d5..a4e190652 100644 --- a/tests/Operation/RenameCollectionTest.php +++ b/tests/Operation/RenameCollectionTest.php @@ -20,13 +20,13 @@ public function testConstructorOptionTypeChecks(array $options): void ); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'dropTarget' => $this->getInvalidBooleanValues(), - 'session' => $this->getInvalidSessionValues(), - 'typeMap' => $this->getInvalidArrayValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'dropTarget' => self::getInvalidBooleanValues(), + 'session' => self::getInvalidSessionValues(), + 'typeMap' => self::getInvalidArrayValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } } diff --git a/tests/Operation/ReplaceOneTest.php b/tests/Operation/ReplaceOneTest.php index 73f659b85..dc6ef2c47 100644 --- a/tests/Operation/ReplaceOneTest.php +++ b/tests/Operation/ReplaceOneTest.php @@ -60,10 +60,10 @@ public function testConstructorOptionsTypeCheck($options): void new ReplaceOne($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], ['y' => 1], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'codec' => $this->getInvalidDocumentCodecValues(), + return self::createOptionDataProvider([ + 'codec' => self::getInvalidDocumentCodecValues(), ]); } diff --git a/tests/Operation/TestCase.php b/tests/Operation/TestCase.php index 386468ce2..f7906e650 100644 --- a/tests/Operation/TestCase.php +++ b/tests/Operation/TestCase.php @@ -77,7 +77,7 @@ public function provideEmptyUpdatePipelinesExcludingArray(): array public function provideInvalidUpdateValues(): array { - return $this->wrapValuesForDataProvider($this->getInvalidUpdateValues()); + return self::wrapValuesForDataProvider(self::getInvalidUpdateValues()); } protected function getInvalidUpdateValues(): array diff --git a/tests/Operation/UpdateFunctionalTest.php b/tests/Operation/UpdateFunctionalTest.php index e70331433..0541f8797 100644 --- a/tests/Operation/UpdateFunctionalTest.php +++ b/tests/Operation/UpdateFunctionalTest.php @@ -75,7 +75,7 @@ function (array $event) use ($expectedUpdate): void { ); } - public function provideReplacementDocumentLikePipeline(): array + public static function provideReplacementDocumentLikePipeline(): array { /* Note: libmongoc encodes this replacement document as a BSON array * because it resembles an update pipeline (see: CDRIVER-4658). */ diff --git a/tests/Operation/UpdateTest.php b/tests/Operation/UpdateTest.php index bf8d993ca..468bf00bf 100644 --- a/tests/Operation/UpdateTest.php +++ b/tests/Operation/UpdateTest.php @@ -31,17 +31,17 @@ public function testConstructorOptionTypeChecks(array $options): void new Update($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], ['y' => 1], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'arrayFilters' => $this->getInvalidArrayValues(), - 'bypassDocumentValidation' => $this->getInvalidBooleanValues(), - 'collation' => $this->getInvalidDocumentValues(), - 'hint' => $this->getInvalidHintValues(), - 'multi' => $this->getInvalidBooleanValues(), - 'session' => $this->getInvalidSessionValues(), - 'upsert' => $this->getInvalidBooleanValues(), - 'writeConcern' => $this->getInvalidWriteConcernValues(), + return self::createOptionDataProvider([ + 'arrayFilters' => self::getInvalidArrayValues(), + 'bypassDocumentValidation' => self::getInvalidBooleanValues(), + 'collation' => self::getInvalidDocumentValues(), + 'hint' => self::getInvalidHintValues(), + 'multi' => self::getInvalidBooleanValues(), + 'session' => self::getInvalidSessionValues(), + 'upsert' => self::getInvalidBooleanValues(), + 'writeConcern' => self::getInvalidWriteConcernValues(), ]); } diff --git a/tests/Operation/WatchFunctionalTest.php b/tests/Operation/WatchFunctionalTest.php index a7e0ae534..3f90bce9b 100644 --- a/tests/Operation/WatchFunctionalTest.php +++ b/tests/Operation/WatchFunctionalTest.php @@ -1064,7 +1064,7 @@ public function testTypeMapOption(array $typeMap, $expectedChangeDocument): void $this->assertMatchesDocument($expectedChangeDocument, $changeStream->current()); } - public function provideTypeMapOptionsAndExpectedChangeDocument() + public static function provideTypeMapOptionsAndExpectedChangeDocument() { /* Note: the "_id" and "ns" fields are purposefully omitted because the * resume token's value cannot be anticipated and the collection name, diff --git a/tests/Operation/WatchTest.php b/tests/Operation/WatchTest.php index fd97a1c5e..23eafbaab 100644 --- a/tests/Operation/WatchTest.php +++ b/tests/Operation/WatchTest.php @@ -39,22 +39,22 @@ public function testConstructorOptionTypeChecks(array $options): void new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $options); } - public function provideInvalidConstructorOptions() + public static function provideInvalidConstructorOptions() { - return $this->createOptionDataProvider([ - 'batchSize' => $this->getInvalidIntegerValues(), - 'codec' => $this->getInvalidDocumentCodecValues(), - 'collation' => $this->getInvalidDocumentValues(), - 'fullDocument' => $this->getInvalidStringValues(true), - 'fullDocumentBeforeChange' => $this->getInvalidStringValues(), - 'maxAwaitTimeMS' => $this->getInvalidIntegerValues(), - 'readConcern' => $this->getInvalidReadConcernValues(), - 'readPreference' => $this->getInvalidReadPreferenceValues(true), - 'resumeAfter' => $this->getInvalidDocumentValues(), - 'session' => $this->getInvalidSessionValues(), - 'startAfter' => $this->getInvalidDocumentValues(), - 'startAtOperationTime' => $this->getInvalidTimestampValues(), - 'typeMap' => $this->getInvalidArrayValues(), + return self::createOptionDataProvider([ + 'batchSize' => self::getInvalidIntegerValues(), + 'codec' => self::getInvalidDocumentCodecValues(), + 'collation' => self::getInvalidDocumentValues(), + 'fullDocument' => self::getInvalidStringValues(true), + 'fullDocumentBeforeChange' => self::getInvalidStringValues(), + 'maxAwaitTimeMS' => self::getInvalidIntegerValues(), + 'readConcern' => self::getInvalidReadConcernValues(), + 'readPreference' => self::getInvalidReadPreferenceValues(true), + 'resumeAfter' => self::getInvalidDocumentValues(), + 'session' => self::getInvalidSessionValues(), + 'startAfter' => self::getInvalidDocumentValues(), + 'startAtOperationTime' => self::getInvalidTimestampValues(), + 'typeMap' => self::getInvalidArrayValues(), ]); } diff --git a/tests/PedantryTest.php b/tests/PedantryTest.php index 0faf67c54..5c6b07eed 100644 --- a/tests/PedantryTest.php +++ b/tests/PedantryTest.php @@ -63,7 +63,7 @@ public function testMethodsAreOrderedAlphabeticallyByVisibility($className): voi $this->assertEquals($sortedMethods, $methods); } - public function provideProjectClassNames() + public static function provideProjectClassNames() { $classNames = []; $srcDir = realpath(__DIR__ . '/../src/'); diff --git a/tests/SpecTests/ClientSideEncryptionSpecTest.php b/tests/SpecTests/ClientSideEncryptionSpecTest.php index 001d78a84..8662a66f5 100644 --- a/tests/SpecTests/ClientSideEncryptionSpecTest.php +++ b/tests/SpecTests/ClientSideEncryptionSpecTest.php @@ -215,7 +215,7 @@ public function testClientSideEncryption(stdClass $test, ?array $runOn, array $d } } - public function provideTests() + public static function provideTests() { $testArgs = []; diff --git a/tests/SpecTests/DocumentsMatchConstraintTest.php b/tests/SpecTests/DocumentsMatchConstraintTest.php index f4959882d..283d05fe8 100644 --- a/tests/SpecTests/DocumentsMatchConstraintTest.php +++ b/tests/SpecTests/DocumentsMatchConstraintTest.php @@ -78,7 +78,7 @@ public function testBSONTypeAssertions($type, $value): void $this->assertResult(true, $constraint, ['x' => $value], 'Type matches'); } - public function provideBSONTypes() + public static function provideBSONTypes() { $undefined = Document::fromJSON('{ "x": {"$undefined": true} }')->toPHP()->x; $symbol = Document::fromJSON('{ "x": {"$symbol": "test"} }')->toPHP()->x; @@ -144,7 +144,7 @@ public function testErrorMessages($expectedMessagePart, DocumentsMatchConstraint } } - public function errorMessageProvider() + public static function errorMessageProvider() { return [ 'Root type mismatch' => [ diff --git a/tests/TestCase.php b/tests/TestCase.php index 53e46fb82..2ae4b47d0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -140,22 +140,22 @@ public function dataDescription(): string public function provideInvalidArrayValues(): array { - return $this->wrapValuesForDataProvider($this->getInvalidArrayValues()); + return self::wrapValuesForDataProvider(self::getInvalidArrayValues()); } public function provideInvalidDocumentValues(): array { - return $this->wrapValuesForDataProvider($this->getInvalidDocumentValues()); + return self::wrapValuesForDataProvider(self::getInvalidDocumentValues()); } public function provideInvalidIntegerValues(): array { - return $this->wrapValuesForDataProvider($this->getInvalidIntegerValues()); + return self::wrapValuesForDataProvider(self::getInvalidIntegerValues()); } public function provideInvalidStringValues(): array { - return $this->wrapValuesForDataProvider($this->getInvalidStringValues()); + return self::wrapValuesForDataProvider(self::getInvalidStringValues()); } protected function assertDeprecated(callable $execution): void @@ -175,7 +175,7 @@ protected function assertDeprecated(callable $execution): void $this->assertCount(1, $errors); } - protected function createOptionDataProvider(array $options): array + protected static function createOptionDataProvider(array $options): array { $data = []; @@ -206,7 +206,7 @@ protected function getCollectionName(): string /** * Return a list of invalid array values. */ - protected function getInvalidArrayValues(bool $includeNull = false): array + protected static function getInvalidArrayValues(bool $includeNull = false): array { return [123, 3.14, 'foo', true, new stdClass(), ...($includeNull ? [null] : [])]; } @@ -214,7 +214,7 @@ protected function getInvalidArrayValues(bool $includeNull = false): array /** * Return a list of invalid boolean values. */ - protected function getInvalidBooleanValues(bool $includeNull = false): array + protected static function getInvalidBooleanValues(bool $includeNull = false): array { return [123, 3.14, 'foo', [], new stdClass(), ...($includeNull ? [null] : [])]; } @@ -222,25 +222,25 @@ protected function getInvalidBooleanValues(bool $includeNull = false): array /** * Return a list of invalid document values. */ - protected function getInvalidDocumentValues(bool $includeNull = false): array + protected static function getInvalidDocumentValues(bool $includeNull = false): array { return [123, 3.14, 'foo', true, PackedArray::fromPHP([]), ...($includeNull ? [null] : [])]; } - protected function getInvalidObjectValues(bool $includeNull = false): array + protected static function getInvalidObjectValues(bool $includeNull = false): array { return [123, 3.14, 'foo', true, [], new stdClass(), ...($includeNull ? [null] : [])]; } - protected function getInvalidDocumentCodecValues(): array + protected static function getInvalidDocumentCodecValues(): array { - return [123, 3.14, 'foo', true, [], new stdClass(), $this->createMock(Codec::class)]; + return [123, 3.14, 'foo', true, [], new stdClass(), self::createStub(Codec::class)]; } /** * Return a list of invalid hint values. */ - protected function getInvalidHintValues() + protected static function getInvalidHintValues() { return [123, 3.14, true]; } @@ -248,7 +248,7 @@ protected function getInvalidHintValues() /** * Return a list of invalid integer values. */ - protected function getInvalidIntegerValues(bool $includeNull = false): array + protected static function getInvalidIntegerValues(bool $includeNull = false): array { return [3.14, 'foo', true, [], new stdClass(), ...($includeNull ? [null] : [])]; } @@ -256,7 +256,7 @@ protected function getInvalidIntegerValues(bool $includeNull = false): array /** * Return a list of invalid ReadPreference values. */ - protected function getInvalidReadConcernValues(bool $includeNull = false): array + protected static function getInvalidReadConcernValues(bool $includeNull = false): array { return [ 123, @@ -274,7 +274,7 @@ protected function getInvalidReadConcernValues(bool $includeNull = false): array /** * Return a list of invalid ReadPreference values. */ - protected function getInvalidReadPreferenceValues(bool $includeNull = false): array + protected static function getInvalidReadPreferenceValues(bool $includeNull = false): array { return [ 123, @@ -292,7 +292,7 @@ protected function getInvalidReadPreferenceValues(bool $includeNull = false): ar /** * Return a list of invalid Session values. */ - protected function getInvalidSessionValues(bool $includeNull = false): array + protected static function getInvalidSessionValues(bool $includeNull = false): array { return [ 123, @@ -311,7 +311,7 @@ protected function getInvalidSessionValues(bool $includeNull = false): array /** * Return a list of invalid string values. */ - protected function getInvalidStringValues(bool $includeNull = false): array + protected static function getInvalidStringValues(bool $includeNull = false): array { return [123, 3.14, true, [], new stdClass(), ...($includeNull ? [null] : [])]; } @@ -319,7 +319,7 @@ protected function getInvalidStringValues(bool $includeNull = false): array /** * Return a list of invalid WriteConcern values. */ - protected function getInvalidWriteConcernValues(bool $includeNull = false): array + protected static function getInvalidWriteConcernValues(bool $includeNull = false): array { return [ 123, diff --git a/tests/UnifiedSpecTests/Constraint/IsBsonTypeTest.php b/tests/UnifiedSpecTests/Constraint/IsBsonTypeTest.php index 7300ecd1a..248a989b3 100644 --- a/tests/UnifiedSpecTests/Constraint/IsBsonTypeTest.php +++ b/tests/UnifiedSpecTests/Constraint/IsBsonTypeTest.php @@ -33,7 +33,7 @@ public function testConstraint($type, $value): void $this->assertResult(true, new IsBsonType($type), $value, $this->dataName() . ' is ' . $type); } - public function provideTypes() + public static function provideTypes() { $undefined = Document::fromJSON('{ "x": {"$undefined": true} }')->toPHP()->x; $symbol = Document::fromJSON('{ "x": {"$symbol": "test"} }')->toPHP()->x; diff --git a/tests/UnifiedSpecTests/Constraint/MatchesTest.php b/tests/UnifiedSpecTests/Constraint/MatchesTest.php index 53a7643a4..472fdd1d1 100644 --- a/tests/UnifiedSpecTests/Constraint/MatchesTest.php +++ b/tests/UnifiedSpecTests/Constraint/MatchesTest.php @@ -182,7 +182,7 @@ public function testErrorMessages($expectedMessageRegex, Matches $constraint, $a } } - public function errorMessageProvider() + public static function errorMessageProvider() { return [ 'assertEquals: type check (root-level)' => [ @@ -262,7 +262,7 @@ public function testOperatorSyntaxValidation($expectedMessage, Matches $constrai $constraint->evaluate(['x' => 1], '', true); } - public function operatorErrorMessageProvider() + public static function operatorErrorMessageProvider() { return [ '$$exists type' => [