From f2cca3829d113e8aa4d83d921e2ec668137bd918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 13 Sep 2024 23:50:49 +0200 Subject: [PATCH] More static functions --- tests/GridFS/BucketFunctionalTest.php | 126 +++++++++--------- tests/GridFS/FunctionalTestCase.php | 2 +- tests/GridFS/ReadableStreamFunctionalTest.php | 4 +- tests/Operation/FunctionalTestCase.php | 8 +- tests/Operation/TestCase.php | 14 +- tests/UnifiedSpecTests/UnifiedSpecTest.php | 78 +++++------ 6 files changed, 116 insertions(+), 116 deletions(-) diff --git a/tests/GridFS/BucketFunctionalTest.php b/tests/GridFS/BucketFunctionalTest.php index 0e559d22d..2f2d126d4 100644 --- a/tests/GridFS/BucketFunctionalTest.php +++ b/tests/GridFS/BucketFunctionalTest.php @@ -106,7 +106,7 @@ public function testConstructorWithCodecAndTypeMapOptions(): void /** @dataProvider provideInputDataAndExpectedChunks */ public function testDelete($input, $expectedChunks): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream($input)); + $id = $this->bucket->uploadFromStream('filename', self::createStream($input)); $this->assertCollectionCount($this->filesCollection, 1); $this->assertCollectionCount($this->chunksCollection, $expectedChunks); @@ -142,7 +142,7 @@ public function testDeleteShouldRequireFileToExist(): void /** @dataProvider provideInputDataAndExpectedChunks */ public function testDeleteStillRemovesChunksIfFileDoesNotExist($input, $expectedChunks): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream($input)); + $id = $this->bucket->uploadFromStream('filename', self::createStream($input)); $this->assertCollectionCount($this->filesCollection, 1); $this->assertCollectionCount($this->chunksCollection, $expectedChunks); @@ -160,7 +160,7 @@ public function testDeleteStillRemovesChunksIfFileDoesNotExist($input, $expected public function testDownloadingFileWithMissingChunk(): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream('foobar')); + $id = $this->bucket->uploadFromStream('filename', self::createStream('foobar')); $this->chunksCollection->deleteOne(['files_id' => $id, 'n' => 0]); @@ -171,7 +171,7 @@ public function testDownloadingFileWithMissingChunk(): void public function testDownloadingFileWithUnexpectedChunkIndex(): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream('foobar')); + $id = $this->bucket->uploadFromStream('filename', self::createStream('foobar')); $this->chunksCollection->updateOne( ['files_id' => $id, 'n' => 0], @@ -185,7 +185,7 @@ public function testDownloadingFileWithUnexpectedChunkIndex(): void public function testDownloadingFileWithUnexpectedChunkSize(): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream('foobar')); + $id = $this->bucket->uploadFromStream('filename', self::createStream('foobar')); $this->chunksCollection->updateOne( ['files_id' => $id, 'n' => 0], @@ -200,8 +200,8 @@ public function testDownloadingFileWithUnexpectedChunkSize(): void /** @dataProvider provideInputDataAndExpectedChunks */ public function testDownloadToStream($input): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream($input)); - $destination = $this->createStream(); + $id = $this->bucket->uploadFromStream('filename', self::createStream($input)); + $destination = self::createStream(); $this->bucket->downloadToStream($id, $destination); $this->assertStreamContents($input, $destination); @@ -222,40 +222,40 @@ public static function provideInvalidStreamValues(): array public function testDownloadToStreamShouldRequireFileToExist(): void { $this->expectException(FileNotFoundException::class); - $this->bucket->downloadToStream('nonexistent-id', $this->createStream()); + $this->bucket->downloadToStream('nonexistent-id', self::createStream()); } public function testDownloadToStreamByName(): void { - $this->bucket->uploadFromStream('filename', $this->createStream('foo')); - $this->bucket->uploadFromStream('filename', $this->createStream('bar')); - $this->bucket->uploadFromStream('filename', $this->createStream('baz')); + $this->bucket->uploadFromStream('filename', self::createStream('foo')); + $this->bucket->uploadFromStream('filename', self::createStream('bar')); + $this->bucket->uploadFromStream('filename', self::createStream('baz')); - $destination = $this->createStream(); + $destination = self::createStream(); $this->bucket->downloadToStreamByName('filename', $destination); $this->assertStreamContents('baz', $destination); - $destination = $this->createStream(); + $destination = self::createStream(); $this->bucket->downloadToStreamByName('filename', $destination, ['revision' => -3]); $this->assertStreamContents('foo', $destination); - $destination = $this->createStream(); + $destination = self::createStream(); $this->bucket->downloadToStreamByName('filename', $destination, ['revision' => -2]); $this->assertStreamContents('bar', $destination); - $destination = $this->createStream(); + $destination = self::createStream(); $this->bucket->downloadToStreamByName('filename', $destination, ['revision' => -1]); $this->assertStreamContents('baz', $destination); - $destination = $this->createStream(); + $destination = self::createStream(); $this->bucket->downloadToStreamByName('filename', $destination, ['revision' => 0]); $this->assertStreamContents('foo', $destination); - $destination = $this->createStream(); + $destination = self::createStream(); $this->bucket->downloadToStreamByName('filename', $destination, ['revision' => 1]); $this->assertStreamContents('bar', $destination); - $destination = $this->createStream(); + $destination = self::createStream(); $this->bucket->downloadToStreamByName('filename', $destination, ['revision' => 2]); $this->assertStreamContents('baz', $destination); } @@ -270,10 +270,10 @@ public function testDownloadToStreamByNameShouldRequireDestinationStream($destin /** @dataProvider provideNonexistentFilenameAndRevision */ public function testDownloadToStreamByNameShouldRequireFilenameAndRevisionToExist($filename, $revision): void { - $this->bucket->uploadFromStream('filename', $this->createStream('foo')); - $this->bucket->uploadFromStream('filename', $this->createStream('bar')); + $this->bucket->uploadFromStream('filename', self::createStream('foo')); + $this->bucket->uploadFromStream('filename', self::createStream('bar')); - $destination = $this->createStream(); + $destination = self::createStream(); $this->expectException(FileNotFoundException::class); $this->bucket->downloadToStreamByName($filename, $destination, ['revision' => $revision]); } @@ -290,7 +290,7 @@ public static function provideNonexistentFilenameAndRevision() public function testDrop(): void { - $this->bucket->uploadFromStream('filename', $this->createStream('foobar')); + $this->bucket->uploadFromStream('filename', self::createStream('foobar')); $this->assertCollectionCount($this->filesCollection, 1); $this->assertCollectionCount($this->chunksCollection, 1); @@ -303,9 +303,9 @@ public function testDrop(): void public function testFind(): void { - $this->bucket->uploadFromStream('a', $this->createStream('foo')); - $this->bucket->uploadFromStream('b', $this->createStream('foobar')); - $this->bucket->uploadFromStream('c', $this->createStream('foobarbaz')); + $this->bucket->uploadFromStream('a', self::createStream('foo')); + $this->bucket->uploadFromStream('b', self::createStream('foobar')); + $this->bucket->uploadFromStream('c', self::createStream('foobarbaz')); $cursor = $this->bucket->find( ['length' => ['$lte' => 6]], @@ -329,7 +329,7 @@ public function testFind(): void public function testFindUsesTypeMap(): void { - $this->bucket->uploadFromStream('a', $this->createStream('foo')); + $this->bucket->uploadFromStream('a', self::createStream('foo')); $cursor = $this->bucket->find(); $fileDocument = current($cursor->toArray()); @@ -339,7 +339,7 @@ public function testFindUsesTypeMap(): void public function testFindUsesCodec(): void { - $this->bucket->uploadFromStream('a', $this->createStream('foo')); + $this->bucket->uploadFromStream('a', self::createStream('foo')); $cursor = $this->bucket->find([], ['codec' => new TestFileCodec()]); $fileDocument = current($cursor->toArray()); @@ -351,7 +351,7 @@ public function testFindUsesCodec(): void public function testFindInheritsBucketCodec(): void { $bucket = new Bucket($this->manager, $this->getDatabaseName(), ['codec' => new TestFileCodec()]); - $bucket->uploadFromStream('a', $this->createStream('foo')); + $bucket->uploadFromStream('a', self::createStream('foo')); $cursor = $bucket->find(); $fileDocument = current($cursor->toArray()); @@ -363,7 +363,7 @@ public function testFindInheritsBucketCodec(): void public function testFindResetsInheritedBucketCodec(): void { $bucket = new Bucket($this->manager, $this->getDatabaseName(), ['codec' => new TestFileCodec()]); - $bucket->uploadFromStream('a', $this->createStream('foo')); + $bucket->uploadFromStream('a', self::createStream('foo')); $cursor = $bucket->find([], ['codec' => null]); $fileDocument = current($cursor->toArray()); @@ -374,9 +374,9 @@ public function testFindResetsInheritedBucketCodec(): void public function testFindOne(): void { - $this->bucket->uploadFromStream('a', $this->createStream('foo')); - $this->bucket->uploadFromStream('b', $this->createStream('foobar')); - $this->bucket->uploadFromStream('c', $this->createStream('foobarbaz')); + $this->bucket->uploadFromStream('a', self::createStream('foo')); + $this->bucket->uploadFromStream('b', self::createStream('foobar')); + $this->bucket->uploadFromStream('c', self::createStream('foobarbaz')); $fileDocument = $this->bucket->findOne( ['length' => ['$lte' => 6]], @@ -396,9 +396,9 @@ public function testFindOne(): void public function testFindOneUsesCodec(): void { - $this->bucket->uploadFromStream('a', $this->createStream('foo')); - $this->bucket->uploadFromStream('b', $this->createStream('foobar')); - $this->bucket->uploadFromStream('c', $this->createStream('foobarbaz')); + $this->bucket->uploadFromStream('a', self::createStream('foo')); + $this->bucket->uploadFromStream('b', self::createStream('foobar')); + $this->bucket->uploadFromStream('c', self::createStream('foobarbaz')); $fileDocument = $this->bucket->findOne( ['length' => ['$lte' => 6]], @@ -417,9 +417,9 @@ public function testFindOneInheritsBucketCodec(): void { $bucket = new Bucket($this->manager, $this->getDatabaseName(), ['codec' => new TestFileCodec()]); - $bucket->uploadFromStream('a', $this->createStream('foo')); - $bucket->uploadFromStream('b', $this->createStream('foobar')); - $bucket->uploadFromStream('c', $this->createStream('foobarbaz')); + $bucket->uploadFromStream('a', self::createStream('foo')); + $bucket->uploadFromStream('b', self::createStream('foobar')); + $bucket->uploadFromStream('c', self::createStream('foobarbaz')); $fileDocument = $bucket->findOne( ['length' => ['$lte' => 6]], @@ -435,9 +435,9 @@ public function testFindOneResetsInheritedBucketCodec(): void { $bucket = new Bucket($this->manager, $this->getDatabaseName(), ['codec' => new TestFileCodec()]); - $bucket->uploadFromStream('a', $this->createStream('foo')); - $bucket->uploadFromStream('b', $this->createStream('foobar')); - $bucket->uploadFromStream('c', $this->createStream('foobarbaz')); + $bucket->uploadFromStream('a', self::createStream('foo')); + $bucket->uploadFromStream('b', self::createStream('foobar')); + $bucket->uploadFromStream('c', self::createStream('foobarbaz')); $fileDocument = $bucket->findOne( ['length' => ['$lte' => 6]], @@ -520,7 +520,7 @@ public function testGetFileDocumentForStreamUsesCodec(): void public function testGetFileDocumentForStreamWithReadableStream(): void { $metadata = ['foo' => 'bar']; - $id = $this->bucket->uploadFromStream('filename', $this->createStream('foobar'), ['metadata' => $metadata]); + $id = $this->bucket->uploadFromStream('filename', self::createStream('foobar'), ['metadata' => $metadata]); $stream = $this->bucket->openDownloadStream($id); $fileDocument = $this->bucket->getFileDocumentForStream($stream); @@ -550,9 +550,9 @@ public function testGetFileDocumentForStreamShouldRequireGridFSStreamResource($s $this->bucket->getFileDocumentForStream($stream); } - public function provideInvalidGridFSStreamValues() + public static function provideInvalidGridFSStreamValues(): array { - return self::wrapValuesForDataProvider(array_merge(self::getInvalidStreamValues(), [$this->createStream()])); + return self::wrapValuesForDataProvider(array_merge(self::getInvalidStreamValues(), [self::createStream()])); } public function testGetFileIdForStreamUsesTypeMap(): void @@ -567,7 +567,7 @@ public function testGetFileIdForStreamUsesTypeMap(): void public function testGetFileIdForStreamWithReadableStream(): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream('foobar')); + $id = $this->bucket->uploadFromStream('filename', self::createStream('foobar')); $stream = $this->bucket->openDownloadStream($id); $this->assertSameObjectId($id, $this->bucket->getFileIdForStream($stream)); @@ -598,7 +598,7 @@ public function testGetFilesCollection(): void /** @dataProvider provideInputDataAndExpectedChunks */ public function testOpenDownloadStream($input): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream($input)); + $id = $this->bucket->uploadFromStream('filename', self::createStream($input)); $this->assertStreamContents($input, $this->bucket->openDownloadStream($id)); } @@ -606,7 +606,7 @@ public function testOpenDownloadStream($input): void /** @dataProvider provideInputDataAndExpectedChunks */ public function testOpenDownloadStreamAndMultipleReadOperations($input): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream($input)); + $id = $this->bucket->uploadFromStream('filename', self::createStream($input)); $stream = $this->bucket->openDownloadStream($id); $buffer = ''; @@ -636,9 +636,9 @@ public function testOpenDownloadStreamByNameShouldRequireFilenameToExist(): void public function testOpenDownloadStreamByName(): void { - $this->bucket->uploadFromStream('filename', $this->createStream('foo')); - $this->bucket->uploadFromStream('filename', $this->createStream('bar')); - $this->bucket->uploadFromStream('filename', $this->createStream('baz')); + $this->bucket->uploadFromStream('filename', self::createStream('foo')); + $this->bucket->uploadFromStream('filename', self::createStream('bar')); + $this->bucket->uploadFromStream('filename', self::createStream('baz')); $this->assertStreamContents('baz', $this->bucket->openDownloadStreamByName('filename')); $this->assertStreamContents('foo', $this->bucket->openDownloadStreamByName('filename', ['revision' => -3])); @@ -652,8 +652,8 @@ public function testOpenDownloadStreamByName(): void /** @dataProvider provideNonexistentFilenameAndRevision */ public function testOpenDownloadStreamByNameShouldRequireFilenameAndRevisionToExist($filename, $revision): void { - $this->bucket->uploadFromStream('filename', $this->createStream('foo')); - $this->bucket->uploadFromStream('filename', $this->createStream('bar')); + $this->bucket->uploadFromStream('filename', self::createStream('foo')); + $this->bucket->uploadFromStream('filename', self::createStream('bar')); $this->expectException(FileNotFoundException::class); $this->bucket->openDownloadStreamByName($filename, ['revision' => $revision]); @@ -689,7 +689,7 @@ public function testOpenUploadStreamAndMultipleWriteOperations($input): void public function testRename(): void { - $id = $this->bucket->uploadFromStream('a', $this->createStream('foo')); + $id = $this->bucket->uploadFromStream('a', self::createStream('foo')); $this->bucket->rename($id, 'b'); $fileDocument = $this->filesCollection->findOne( @@ -703,7 +703,7 @@ public function testRename(): void public function testRenameShouldNotRequireFileToBeModified(): void { - $id = $this->bucket->uploadFromStream('a', $this->createStream('foo')); + $id = $this->bucket->uploadFromStream('a', self::createStream('foo')); $this->bucket->rename($id, 'a'); $fileDocument = $this->filesCollection->findOne( @@ -729,7 +729,7 @@ public function testUploadFromStream(): void 'metadata' => ['foo' => 'bar'], ]; - $id = $this->bucket->uploadFromStream('filename', $this->createStream('foobar'), $options); + $id = $this->bucket->uploadFromStream('filename', self::createStream('foobar'), $options); $this->assertCollectionCount($this->filesCollection, 1); $this->assertCollectionCount($this->chunksCollection, 3); @@ -749,8 +749,8 @@ public function testUploadFromStreamShouldRequireSourceStream($source): void public function testUploadingAnEmptyFile(): void { - $id = $this->bucket->uploadFromStream('filename', $this->createStream('')); - $destination = $this->createStream(); + $id = $this->bucket->uploadFromStream('filename', self::createStream('')); + $destination = self::createStream(); $this->bucket->downloadToStream($id, $destination); $this->assertStreamContents('', $destination); @@ -779,7 +779,7 @@ public function testUploadingAnEmptyFile(): void public function testDisableMD5(): void { $options = ['disableMD5' => true]; - $id = $this->bucket->uploadFromStream('filename', $this->createStream('data'), $options); + $id = $this->bucket->uploadFromStream('filename', self::createStream('data'), $options); $fileDocument = $this->filesCollection->findOne( ['_id' => $id], @@ -793,7 +793,7 @@ public function testDisableMD5OptionInConstructor(): void $options = ['disableMD5' => true]; $this->bucket = new Bucket($this->manager, $this->getDatabaseName(), $options); - $id = $this->bucket->uploadFromStream('filename', $this->createStream('data')); + $id = $this->bucket->uploadFromStream('filename', self::createStream('data')); $fileDocument = $this->filesCollection->findOne( ['_id' => $id], @@ -804,7 +804,7 @@ public function testDisableMD5OptionInConstructor(): void public function testUploadingFirstFileCreatesIndexes(): void { - $this->bucket->uploadFromStream('filename', $this->createStream('foo')); + $this->bucket->uploadFromStream('filename', self::createStream('foo')); $this->assertIndexExists($this->filesCollection->getCollectionName(), 'filename_1_uploadDate_1'); $this->assertIndexExists($this->chunksCollection->getCollectionName(), 'files_id_1_n_1', function (IndexInfo $info): void { @@ -817,7 +817,7 @@ public function testExistingIndexIsReused(): void $this->filesCollection->createIndex(['filename' => 1.0, 'uploadDate' => 1], ['name' => 'test']); $this->chunksCollection->createIndex(['files_id' => 1.0, 'n' => 1], ['name' => 'test', 'unique' => true]); - $this->bucket->uploadFromStream('filename', $this->createStream('foo')); + $this->bucket->uploadFromStream('filename', self::createStream('foo')); $this->assertIndexNotExists($this->filesCollection->getCollectionName(), 'filename_1_uploadDate_1'); $this->assertIndexNotExists($this->chunksCollection->getCollectionName(), 'files_id_1_n_1'); @@ -825,7 +825,7 @@ public function testExistingIndexIsReused(): void public function testDownloadToStreamFails(): void { - $this->bucket->uploadFromStream('filename', $this->createStream('foo'), ['_id' => ['foo' => 'bar']]); + $this->bucket->uploadFromStream('filename', self::createStream('foo'), ['_id' => ['foo' => 'bar']]); $this->expectException(StreamException::class); $this->expectExceptionMessageMatches('#^Downloading file from "gridfs://.*/.*/.*" to "php://temp" failed. GridFS identifier: "{ "_id" : { "foo" : "bar" } }"$#'); @@ -834,7 +834,7 @@ public function testDownloadToStreamFails(): void public function testDownloadToStreamByNameFails(): void { - $this->bucket->uploadFromStream('filename', $this->createStream('foo')); + $this->bucket->uploadFromStream('filename', self::createStream('foo')); $this->expectException(StreamException::class); $this->expectExceptionMessageMatches('#^Downloading file from "gridfs://.*/.*/.*" to "php://temp" failed. GridFS filename: "filename"$#'); diff --git a/tests/GridFS/FunctionalTestCase.php b/tests/GridFS/FunctionalTestCase.php index 1508fef68..d010ca929 100644 --- a/tests/GridFS/FunctionalTestCase.php +++ b/tests/GridFS/FunctionalTestCase.php @@ -53,7 +53,7 @@ protected function assertStreamContents(string $expectedContents, $stream): void * * @return resource */ - protected function createStream(string $data = '') + protected static function createStream(string $data = '') { $stream = fopen('php://temp', 'w+b'); fwrite($stream, $data); diff --git a/tests/GridFS/ReadableStreamFunctionalTest.php b/tests/GridFS/ReadableStreamFunctionalTest.php index 9916059c2..600181fbb 100644 --- a/tests/GridFS/ReadableStreamFunctionalTest.php +++ b/tests/GridFS/ReadableStreamFunctionalTest.php @@ -111,10 +111,10 @@ public static function provideFileIdAndExpectedBytes() ]; } - public function provideFilteredFileIdAndExpectedBytes() + public static function provideFilteredFileIdAndExpectedBytes() { return array_filter( - $this->provideFileIdAndExpectedBytes(), + self::provideFileIdAndExpectedBytes(), fn (array $args) => $args[1] > 0, ); } diff --git a/tests/Operation/FunctionalTestCase.php b/tests/Operation/FunctionalTestCase.php index c07a35712..98e05c3cb 100644 --- a/tests/Operation/FunctionalTestCase.php +++ b/tests/Operation/FunctionalTestCase.php @@ -22,7 +22,7 @@ public function setUp(): void $this->dropCollection($this->getDatabaseName(), $this->getCollectionName()); } - public function provideFilterDocuments(): array + public static function provideFilterDocuments(): array { $expected = (object) ['x' => 1]; @@ -34,7 +34,7 @@ public function provideFilterDocuments(): array ]; } - public function provideReplacementDocuments(): array + public static function provideReplacementDocuments(): array { $expected = (object) ['x' => 1]; $expectedEmpty = (object) []; @@ -53,7 +53,7 @@ public function provideReplacementDocuments(): array ]; } - public function provideUpdateDocuments(): array + public static function provideUpdateDocuments(): array { $expected = (object) ['$set' => (object) ['x' => 1]]; @@ -65,7 +65,7 @@ public function provideUpdateDocuments(): array ]; } - public function provideUpdatePipelines(): array + public static function provideUpdatePipelines(): array { $expected = [(object) ['$set' => (object) ['x' => 1]]]; diff --git a/tests/Operation/TestCase.php b/tests/Operation/TestCase.php index f7906e650..4bb5c5cec 100644 --- a/tests/Operation/TestCase.php +++ b/tests/Operation/TestCase.php @@ -13,7 +13,7 @@ */ abstract class TestCase extends BaseTestCase { - public function provideReplacementDocuments(): array + public static function provideReplacementDocuments(): array { return [ 'replacement:array' => [['x' => 1]], @@ -29,7 +29,7 @@ public function provideReplacementDocuments(): array ]; } - public function provideUpdateDocuments(): array + public static function provideUpdateDocuments(): array { return [ 'update:array' => [['$set' => ['x' => 1]]], @@ -39,7 +39,7 @@ public function provideUpdateDocuments(): array ]; } - public function provideUpdatePipelines(): array + public static function provideUpdatePipelines(): array { return [ 'pipeline:array' => [[['$set' => ['x' => 1]]]], @@ -48,7 +48,7 @@ public function provideUpdatePipelines(): array ]; } - public function provideEmptyUpdatePipelines(): array + public static function provideEmptyUpdatePipelines(): array { /* Empty update pipelines are accepted by the update and findAndModify * commands (as NOPs); however, they are not supported for updates in @@ -65,7 +65,7 @@ public function provideEmptyUpdatePipelines(): array ]; } - public function provideEmptyUpdatePipelinesExcludingArray(): array + public static function provideEmptyUpdatePipelinesExcludingArray(): array { /* This data provider is used for replace operations, which accept empty * arrays as replacement documents for BC. */ @@ -75,12 +75,12 @@ public function provideEmptyUpdatePipelinesExcludingArray(): array ]; } - public function provideInvalidUpdateValues(): array + public static function provideInvalidUpdateValues(): array { return self::wrapValuesForDataProvider(self::getInvalidUpdateValues()); } - protected function getInvalidUpdateValues(): array + protected static function getInvalidUpdateValues(): array { return [123, 3.14, 'foo', true]; } diff --git a/tests/UnifiedSpecTests/UnifiedSpecTest.php b/tests/UnifiedSpecTests/UnifiedSpecTest.php index e07e04f43..6b6031948 100644 --- a/tests/UnifiedSpecTests/UnifiedSpecTest.php +++ b/tests/UnifiedSpecTests/UnifiedSpecTest.php @@ -234,9 +234,9 @@ public function testAtlasDataLake(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideAtlasDataLakeTests() + public static function provideAtlasDataLakeTests(): Generator { - return $this->provideTests(__DIR__ . '/atlas-data-lake/*.json'); + return self::provideTests(__DIR__ . '/atlas-data-lake/*.json'); } /** @@ -248,9 +248,9 @@ public function testChangeStreams(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideChangeStreamsTests() + public static function provideChangeStreamsTests(): Generator { - return $this->provideTests(__DIR__ . '/change-streams/*.json'); + return self::provideTests(__DIR__ . '/change-streams/*.json'); } /** @@ -263,9 +263,9 @@ public function testClientSideEncryption(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideClientSideEncryptionTests() + public static function provideClientSideEncryptionTests(): Generator { - return $this->provideTests(__DIR__ . '/client-side-encryption/*.json'); + return self::provideTests(__DIR__ . '/client-side-encryption/*.json'); } /** @@ -277,9 +277,9 @@ public function testCollectionManagement(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideCollectionManagementTests() + public static function provideCollectionManagementTests(): Generator { - return $this->provideTests(__DIR__ . '/collection-management/*.json'); + return self::provideTests(__DIR__ . '/collection-management/*.json'); } /** @@ -291,9 +291,9 @@ public function testCommandMonitoring(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideCommandMonitoringTests() + public static function provideCommandMonitoringTests(): Generator { - return $this->provideTests(__DIR__ . '/command-monitoring/*.json'); + return self::provideTests(__DIR__ . '/command-monitoring/*.json'); } /** @@ -305,9 +305,9 @@ public function testCrud(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideCrudTests() + public static function provideCrudTests(): Generator { - return $this->provideTests(__DIR__ . '/crud/*.json'); + return self::provideTests(__DIR__ . '/crud/*.json'); } /** @@ -319,9 +319,9 @@ public function testGridFS(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideGridFSTests() + public static function provideGridFSTests(): Generator { - return $this->provideTests(__DIR__ . '/gridfs/*.json'); + return self::provideTests(__DIR__ . '/gridfs/*.json'); } /** @@ -333,9 +333,9 @@ public function testLoadBalancers(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideLoadBalancers() + public static function provideLoadBalancers(): Generator { - return $this->provideTests(__DIR__ . '/load-balancers/*.json'); + return self::provideTests(__DIR__ . '/load-balancers/*.json'); } /** @dataProvider provideReadWriteConcernTests */ @@ -344,9 +344,9 @@ public function testReadWriteConcern(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideReadWriteConcernTests() + public static function provideReadWriteConcernTests(): Generator { - return $this->provideTests(__DIR__ . '/read-write-concern/*.json'); + return self::provideTests(__DIR__ . '/read-write-concern/*.json'); } /** @@ -358,9 +358,9 @@ public function testRetryableReads(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideRetryableReadsTests() + public static function provideRetryableReadsTests(): Generator { - return $this->provideTests(__DIR__ . '/retryable-reads/*.json'); + return self::provideTests(__DIR__ . '/retryable-reads/*.json'); } /** @@ -372,9 +372,9 @@ public function testRetryableWrites(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideRetryableWritesTests() + public static function provideRetryableWritesTests(): Generator { - return $this->provideTests(__DIR__ . '/retryable-writes/*.json'); + return self::provideTests(__DIR__ . '/retryable-writes/*.json'); } /** @@ -386,9 +386,9 @@ public function testRunCommand(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideRunCommandTests() + public static function provideRunCommandTests(): Generator { - return $this->provideTests(__DIR__ . '/run-command/*.json'); + return self::provideTests(__DIR__ . '/run-command/*.json'); } /** @@ -400,9 +400,9 @@ public function testSessions(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideSessionsTests() + public static function provideSessionsTests(): Generator { - return $this->provideTests(__DIR__ . '/sessions/*.json'); + return self::provideTests(__DIR__ . '/sessions/*.json'); } /** @@ -414,9 +414,9 @@ public function testTransactions(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideTransactionsTests() + public static function provideTransactionsTests(): Generator { - return $this->provideTests(__DIR__ . '/transactions/*.json'); + return self::provideTests(__DIR__ . '/transactions/*.json'); } /** @dataProvider provideTransactionsConvenientApiTests */ @@ -425,9 +425,9 @@ public function testTransactionsConvenientApi(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideTransactionsConvenientApiTests() + public static function provideTransactionsConvenientApiTests(): Generator { - return $this->provideTests(__DIR__ . '/transactions-convenient-api/*.json'); + return self::provideTests(__DIR__ . '/transactions-convenient-api/*.json'); } /** @@ -440,9 +440,9 @@ public function testVersionedApi(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideVersionedApiTests() + public static function provideVersionedApiTests(): Generator { - return $this->provideTests(__DIR__ . '/versioned-api/*.json'); + return self::provideTests(__DIR__ . '/versioned-api/*.json'); } /** @dataProvider providePassingTests */ @@ -451,9 +451,9 @@ public function testPassingTests(UnifiedTestCase $test): void self::$runner->run($test); } - public function providePassingTests() + public static function providePassingTests(): Generator { - yield from $this->provideTests(__DIR__ . '/valid-pass/*.json'); + yield from self::provideTests(__DIR__ . '/valid-pass/*.json'); } /** @dataProvider provideFailingTests */ @@ -489,9 +489,9 @@ public function testFailingTests(UnifiedTestCase $test): void $this->assertTrue($failed, 'Expected test to throw an exception'); } - public function provideFailingTests() + public static function provideFailingTests(): Generator { - yield from $this->provideTests(__DIR__ . '/valid-fail/*.json'); + yield from self::provideTests(__DIR__ . '/valid-fail/*.json'); } /** @dataProvider provideIndexManagementTests */ @@ -508,12 +508,12 @@ public function testIndexManagement(UnifiedTestCase $test): void self::$runner->run($test); } - public function provideIndexManagementTests() + public static function provideIndexManagementTests(): Generator { - yield from $this->provideTests(__DIR__ . '/index-management/*.json'); + yield from self::provideTests(__DIR__ . '/index-management/*.json'); } - private function provideTests(string $pattern): Generator + private static function provideTests(string $pattern): Generator { foreach (glob($pattern) as $filename) { $group = basename(dirname($filename));