Skip to content

Commit 690e925

Browse files
committed
Use RequiresPhpExtension
1 parent bfcd2d1 commit 690e925

4 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/Operation/WithTransaction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private function computeBackoffMs(int $transactionAttempt): int
207207

208208
private function getJitter(): float
209209
{
210-
if ($this->jitterGenerator) {
210+
if ($this->jitterGenerator === null) {
211211
return ($this->jitterGenerator)();
212212
}
213213

tests/SpecTests/ClientBackpressure/Prose1_OpRetryExponentialBackoffTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use MongoDB\Operation\WithTransaction;
99
use MongoDB\Tests\SpecTests\FunctionalTestCase;
1010
use MongoDB\Tests\UnifiedSpecTests\Util;
11+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1112

1213
use function microtime;
1314

@@ -16,6 +17,7 @@
1617
*
1718
* @see https://github.com/mongodb/specifications/blob/master/source/client-backpressure/tests/README.md
1819
*/
20+
#[RequiresPhpExtension('mongodb', '>= 2.3.0dev')]
1921
class Prose1_OpRetryExponentialBackoffTest extends FunctionalTestCase
2022
{
2123
public function testOperationRetryUsesExponentialBackoff(): void

tests/SpecTests/ClientBackpressure/Prose3_OverloadErrorMaxRetryTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
use MongoDB\Driver\Monitoring\CommandSubscriber;
99
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
1010
use MongoDB\Tests\SpecTests\FunctionalTestCase;
11+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1112

1213
/**
1314
* Prose test 3: Overload Errors are Retried a Maximum of MAX_RETRIES times
1415
*
1516
* @see https://github.com/mongodb/specifications/blob/master/source/client-backpressure/tests/README.md
1617
*/
18+
#[RequiresPhpExtension('mongodb', '>= 2.3.0dev')]
1719
class Prose3_OverloadErrorMaxRetryTest extends FunctionalTestCase
1820
{
1921
private const MAX_RETRIES = 5;

tests/SpecTests/TransactionsConvenientApi/Prose4_RetryBackoffIsEnforcedTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
use MongoDB\Operation\WithTransaction;
77
use MongoDB\Tests\SpecTests\FunctionalTestCase;
88
use MongoDB\Tests\UnifiedSpecTests\Util;
9+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
910

1011
use function microtime;
1112

1213
/** @see https://github.com/mongodb/specifications/tree/master/source/transactions-convenient-api/tests#retry-backoff-is-enforced */
14+
#[RequiresPhpExtension('mongodb', '>= 2.3.0dev')]
1315
class Prose4_RetryBackoffIsEnforcedTest extends FunctionalTestCase
1416
{
1517
public function testBackoffIsEnforced(): void
@@ -32,7 +34,7 @@ public function testBackoffIsEnforced(): void
3234
Util::setFixedJitter($operation, 0);
3335
$noBackoffTime = $this->runOperationWithTiming($operation, $session);
3436

35-
$this->setFixedJitter($operation, 1);
37+
Util::setFixedJitter($operation, 1);
3638
$withBackoffTime = $this->runOperationWithTiming($operation, $session);
3739

3840
self::assertEqualsWithDelta($noBackoffTime + 1.8, $withBackoffTime, 0.5);

0 commit comments

Comments
 (0)