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

tests/Database/DatabaseFunctionalTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testCommandAppliesTypeMapToCursor()
111111
$commandResult = current($cursor->toArray());
112112

113113
$this->assertCommandSucceeded($commandResult);
114-
$this->assertInternalType('array', $commandResult);
114+
$this->assertIsArray($commandResult);
115115
$this->assertArrayHasKey('ismaster', $commandResult);
116116
$this->assertTrue($commandResult['ismaster']);
117117
}
@@ -207,7 +207,7 @@ public function testSelectCollectionInheritsOptions()
207207
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
208208
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
209209
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
210-
$this->assertInternalType('array', $debug['typeMap']);
210+
$this->assertIsArray($debug['typeMap']);
211211
$this->assertSame(['root' => 'array'], $debug['typeMap']);
212212
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
213213
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -229,7 +229,7 @@ public function testSelectCollectionPassesOptions()
229229
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
230230
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
231231
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
232-
$this->assertInternalType('array', $debug['typeMap']);
232+
$this->assertIsArray($debug['typeMap']);
233233
$this->assertSame(['root' => 'array'], $debug['typeMap']);
234234
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
235235
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -303,7 +303,7 @@ public function testWithOptionsInheritsOptions()
303303
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
304304
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
305305
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
306-
$this->assertInternalType('array', $debug['typeMap']);
306+
$this->assertIsArray($debug['typeMap']);
307307
$this->assertSame(['root' => 'array'], $debug['typeMap']);
308308
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
309309
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -325,7 +325,7 @@ public function testWithOptionsPassesOptions()
325325
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
326326
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
327327
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
328-
$this->assertInternalType('array', $debug['typeMap']);
328+
$this->assertIsArray($debug['typeMap']);
329329
$this->assertSame(['root' => 'array'], $debug['typeMap']);
330330
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
331331
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());

tests/Database/FunctionalTestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44

55
use MongoDB\Database;
66
use MongoDB\Tests\FunctionalTestCase as BaseFunctionalTestCase;
7+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
78

89
/**
910
* Base class for Database functional tests.
1011
*/
1112
abstract class FunctionalTestCase extends BaseFunctionalTestCase
1213
{
14+
use SetUpTearDownTrait;
15+
1316
protected $database;
1417

15-
public function setUp()
18+
private function doSetUp()
1619
{
1720
parent::setUp();
1821

tests/DocumentationExamplesTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use MongoDB\Driver\WriteConcern;
1212
use MongoDB\Driver\Exception\ConnectionTimeoutException;
1313
use MongoDB\Operation\DropCollection;
14+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1415

1516
/**
1617
* Documentation examples to be parsed for inclusion in the MongoDB manual.
@@ -21,14 +22,16 @@
2122
*/
2223
class DocumentationExamplesTest extends FunctionalTestCase
2324
{
24-
public function setUp()
25+
use SetUpTearDownTrait;
26+
27+
private function doSetUp()
2528
{
2629
parent::setUp();
2730

2831
$this->dropCollection();
2932
}
3033

31-
public function tearDown()
34+
private function doTearDown()
3235
{
3336
if ($this->hasFailed()) {
3437
return;
@@ -495,7 +498,7 @@ public function testExample_38_41()
495498

496499
$this->assertSame(2, $insertManyResult->getInsertedCount());
497500
foreach ($insertManyResult->getInsertedIds() as $id) {
498-
$this->assertInternalType('int', $id);
501+
$this->assertIsInt($id);
499502
}
500503
$this->assertInventoryCount(2);
501504

tests/FunctionalTestCase.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,26 @@
1515
use MongoDB\Operation\DropCollection;
1616
use InvalidArgumentException;
1717
use stdClass;
18+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1819
use UnexpectedValueException;
1920

2021
abstract class FunctionalTestCase extends TestCase
2122
{
23+
use SetUpTearDownTrait;
24+
2225
protected $manager;
2326

2427
private $configuredFailPoints = [];
2528

26-
public function setUp()
29+
private function doSetUp()
2730
{
2831
parent::setUp();
2932

3033
$this->manager = new Manager(static::getUri());
3134
$this->configuredFailPoints = [];
3235
}
3336

34-
public function tearDown()
37+
private function doTearDown()
3538
{
3639
$this->disableFailPoints();
3740

tests/GridFS/BucketFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public function testOpenDownloadStreamAndMultipleReadOperations($input)
502502
$expectedReadLength = min(4096, strlen($input) - strlen($buffer));
503503
$buffer .= $read = fread($stream, 4096);
504504

505-
$this->assertInternalType('string', $read);
505+
$this->assertIsString($read);
506506
$this->assertEquals($expectedReadLength, strlen($read));
507507
}
508508

0 commit comments

Comments
 (0)