Skip to content

Commit 89ca718

Browse files
committed
PHPLIB-462: Add compatibility traits for the TestCase class
1 parent 368368e commit 89ca718

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/Compat/PolyfillAssertTrait.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace MongoDB\Tests\Compat;
4+
5+
use PHPUnit\Framework\Assert;
6+
use ReflectionClass;
7+
use Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait as SymfonyPolyfillAssertTrait;
8+
9+
$r = new ReflectionClass(Assert::class);
10+
if (! $r->hasMethod('assertEqualsWithDelta')) {
11+
/**
12+
* @internal
13+
*/
14+
trait PolyfillAssertTrait
15+
{
16+
use SymfonyPolyfillAssertTrait;
17+
}
18+
} else {
19+
/**
20+
* @internal
21+
*/
22+
trait PolyfillAssertTrait
23+
{
24+
}
25+
}

tests/TestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use MongoDB\Driver\WriteConcern;
88
use MongoDB\Model\BSONArray;
99
use MongoDB\Model\BSONDocument;
10+
use MongoDB\Tests\Compat\PolyfillAssertTrait;
1011
use PHPUnit\Framework\TestCase as BaseTestCase;
1112
use InvalidArgumentException;
1213
use ReflectionClass;
@@ -15,6 +16,8 @@
1516

1617
abstract class TestCase extends BaseTestCase
1718
{
19+
use PolyfillAssertTrait;
20+
1821
/**
1922
* Return the connection URI.
2023
*

0 commit comments

Comments
 (0)