Skip to content

Commit 7880bcd

Browse files
committed
Merge pull request #665
2 parents 9074847 + e0c6531 commit 7880bcd

35 files changed

+191
-113
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ vendor/
66
# PHPUnit
77
phpunit.phar
88
phpunit.xml
9+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ env:
2121
- COMPOSER_OPTIONS=
2222

2323
jobs:
24-
allow_failures:
25-
- php: "7.4snapshot"
26-
2724
include:
2825

2926
- stage: Smoke Testing

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"ext-mongodb": "^1.6"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^5.7.27 || ^6.4"
19+
"phpunit/phpunit": "^5.7.27 || ^6.4 || ^8.3",
20+
"symfony/phpunit-bridge": "^4.4@dev"
2021
},
2122
"autoload": {
2223
"psr-4": { "MongoDB\\": "src/" },

phpunit.xml.dist

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
<phpunit
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.3/phpunit.xsd"
6-
backupGlobals="false"
7-
backupStaticAttributes="false"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.3/phpunit.xsd"
6+
beStrictAboutOutputDuringTests="true"
7+
beStrictAboutChangesToGlobalState="true"
88
colors="true"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
12-
stopOnFailure="false"
13-
syntaxCheck="false"
149
bootstrap="tests/bootstrap.php"
1510
>
1611

tests/ClientFunctionalTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
use MongoDB\Driver\BulkWrite;
77
use MongoDB\Driver\Command;
88
use MongoDB\Model\DatabaseInfo;
9+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
910

1011
/**
1112
* Functional tests for the Client class.
1213
*/
1314
class ClientFunctionalTest extends FunctionalTestCase
1415
{
16+
use SetUpTearDownTrait;
17+
1518
private $client;
1619

17-
public function setUp()
20+
private function doSetUp()
1821
{
1922
parent::setUp();
2023

tests/ClientTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testSelectCollectionInheritsOptions()
6767
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
6868
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
6969
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
70-
$this->assertInternalType('array', $debug['typeMap']);
70+
$this->assertIsArray($debug['typeMap']);
7171
$this->assertSame(['root' => 'array'], $debug['typeMap']);
7272
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
7373
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -90,7 +90,7 @@ public function testSelectCollectionPassesOptions()
9090
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
9191
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
9292
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
93-
$this->assertInternalType('array', $debug['typeMap']);
93+
$this->assertIsArray($debug['typeMap']);
9494
$this->assertSame(['root' => 'array'], $debug['typeMap']);
9595
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
9696
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -129,7 +129,7 @@ public function testSelectDatabaseInheritsOptions()
129129
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
130130
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
131131
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
132-
$this->assertInternalType('array', $debug['typeMap']);
132+
$this->assertIsArray($debug['typeMap']);
133133
$this->assertSame(['root' => 'array'], $debug['typeMap']);
134134
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
135135
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -152,7 +152,7 @@ public function testSelectDatabasePassesOptions()
152152
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
153153
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
154154
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
155-
$this->assertInternalType('array', $debug['typeMap']);
155+
$this->assertIsArray($debug['typeMap']);
156156
$this->assertSame(['root' => 'array'], $debug['typeMap']);
157157
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
158158
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());

tests/Collection/CollectionFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public function testWithOptionsInheritsOptions()
262262
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
263263
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
264264
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
265-
$this->assertInternalType('array', $debug['typeMap']);
265+
$this->assertIsArray($debug['typeMap']);
266266
$this->assertSame(['root' => 'array'], $debug['typeMap']);
267267
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
268268
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -284,7 +284,7 @@ public function testWithOptionsPassesOptions()
284284
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
285285
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
286286
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
287-
$this->assertInternalType('array', $debug['typeMap']);
287+
$this->assertIsArray($debug['typeMap']);
288288
$this->assertSame(['root' => 'array'], $debug['typeMap']);
289289
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
290290
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());

tests/Collection/CrudSpecFunctionalTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use IteratorIterator;
1212
use LogicException;
1313
use MultipleIterator;
14+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1415

1516
/**
1617
* CRUD spec functional tests.
@@ -19,9 +20,11 @@
1920
*/
2021
class CrudSpecFunctionalTest extends FunctionalTestCase
2122
{
23+
use SetUpTearDownTrait;
24+
2225
private $expectedCollection;
2326

24-
public function setUp()
27+
private function doSetUp()
2528
{
2629
parent::setUp();
2730

@@ -297,7 +300,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
297300
break;
298301

299302
case 'bulkWrite':
300-
$this->assertInternalType('array', $expectedResult);
303+
$this->assertIsArray($expectedResult);
301304
$this->assertInstanceOf(\MongoDB\BulkWriteResult::class, $actualResult);
302305

303306
if (isset($expectedResult['deletedCount'])) {
@@ -354,7 +357,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
354357

355358
case 'deleteMany':
356359
case 'deleteOne':
357-
$this->assertInternalType('array', $expectedResult);
360+
$this->assertIsArray($expectedResult);
358361
$this->assertInstanceOf(\MongoDB\DeleteResult::class, $actualResult);
359362

360363
if (isset($expectedResult['deletedCount'])) {
@@ -372,7 +375,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
372375
break;
373376

374377
case 'insertMany':
375-
$this->assertInternalType('array', $expectedResult);
378+
$this->assertIsArray($expectedResult);
376379
$this->assertInstanceOf(\MongoDB\InsertManyResult::class, $actualResult);
377380

378381
if (isset($expectedResult['insertedCount'])) {
@@ -388,7 +391,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
388391
break;
389392

390393
case 'insertOne':
391-
$this->assertInternalType('array', $expectedResult);
394+
$this->assertIsArray($expectedResult);
392395
$this->assertInstanceOf(\MongoDB\InsertOneResult::class, $actualResult);
393396

394397
if (isset($expectedResult['insertedCount'])) {
@@ -406,7 +409,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
406409
case 'replaceOne':
407410
case 'updateMany':
408411
case 'updateOne':
409-
$this->assertInternalType('array', $expectedResult);
412+
$this->assertIsArray($expectedResult);
410413
$this->assertInstanceOf(\MongoDB\UpdateResult::class, $actualResult);
411414

412415
if (isset($expectedResult['matchedCount'])) {

tests/Collection/FunctionalTestCase.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
use MongoDB\Collection;
66
use MongoDB\Driver\WriteConcern;
77
use MongoDB\Tests\FunctionalTestCase as BaseFunctionalTestCase;
8+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
89

910
/**
1011
* Base class for Collection functional tests.
1112
*/
1213
abstract class FunctionalTestCase extends BaseFunctionalTestCase
1314
{
15+
use SetUpTearDownTrait;
16+
1417
protected $collection;
1518

16-
public function setUp()
19+
private function doSetUp()
1720
{
1821
parent::setUp();
1922

@@ -22,7 +25,7 @@ public function setUp()
2225
$this->dropCollection();
2326
}
2427

25-
public function tearDown()
28+
private function doTearDown()
2629
{
2730
if ($this->hasFailed()) {
2831
return;

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+
}

0 commit comments

Comments
 (0)