Skip to content

Commit

Permalink
More static functions
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Sep 14, 2024
1 parent 6de7408 commit 5bb47d7
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 118 deletions.
126 changes: 63 additions & 63 deletions tests/GridFS/BucketFunctionalTest.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/GridFS/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/GridFS/ReadableStreamFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Operation/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -34,7 +34,7 @@ public function provideFilterDocuments(): array
];
}

public function provideReplacementDocuments(): array
public static function provideReplacementDocuments(): array
{
$expected = (object) ['x' => 1];
$expectedEmpty = (object) [];
Expand All @@ -53,7 +53,7 @@ public function provideReplacementDocuments(): array
];
}

public function provideUpdateDocuments(): array
public static function provideUpdateDocuments(): array
{
$expected = (object) ['$set' => (object) ['x' => 1]];

Expand All @@ -65,7 +65,7 @@ public function provideUpdateDocuments(): array
];
}

public function provideUpdatePipelines(): array
public static function provideUpdatePipelines(): array
{
$expected = [(object) ['$set' => (object) ['x' => 1]]];

Expand Down
2 changes: 1 addition & 1 deletion tests/Operation/MapReduceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function provideInvalidConstructorOptions()
]);
}

private function getInvalidJavascriptValues()
private static function getInvalidJavascriptValues()
{
return [123, 3.14, 'foo', true, [], new stdClass(), new ObjectId()];
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Operation/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
abstract class TestCase extends BaseTestCase
{
public function provideReplacementDocuments(): array
public static function provideReplacementDocuments(): array
{
return [
'replacement:array' => [['x' => 1]],
Expand All @@ -29,7 +29,7 @@ public function provideReplacementDocuments(): array
];
}

public function provideUpdateDocuments(): array
public static function provideUpdateDocuments(): array
{
return [
'update:array' => [['$set' => ['x' => 1]]],
Expand All @@ -39,7 +39,7 @@ public function provideUpdateDocuments(): array
];
}

public function provideUpdatePipelines(): array
public static function provideUpdatePipelines(): array
{
return [
'pipeline:array' => [[['$set' => ['x' => 1]]]],
Expand All @@ -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
Expand All @@ -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. */
Expand All @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Operation/WatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testConstructorRejectsCodecAndTypemap(): void
new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $options);
}

private function getInvalidTimestampValues()
private static function getInvalidTimestampValues()
{
return [123, 3.14, 'foo', true, [], new stdClass()];
}
Expand Down
78 changes: 39 additions & 39 deletions tests/UnifiedSpecTests/UnifiedSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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 */
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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 */
Expand All @@ -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');
}

/**
Expand All @@ -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 */
Expand All @@ -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 */
Expand Down Expand Up @@ -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 */
Expand All @@ -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));
Expand Down

0 comments on commit 5bb47d7

Please sign in to comment.