Skip to content

Commit d7aed71

Browse files
committed
PHPLIB-462: Fix PHPUnit hook methods for different versions
1 parent 1c74f44 commit d7aed71

23 files changed

+97
-30
lines changed

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 || ^8.3"
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/" },

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/Collection/CrudSpecFunctionalTest.php

Lines changed: 4 additions & 1 deletion
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

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/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: 5 additions & 2 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;

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/FunctionalTestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
use MongoDB\Collection;
66
use MongoDB\GridFS\Bucket;
77
use MongoDB\Tests\FunctionalTestCase as BaseFunctionalTestCase;
8+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
89

910
/**
1011
* Base class for GridFS functional tests.
1112
*/
1213
abstract class FunctionalTestCase extends BaseFunctionalTestCase
1314
{
15+
use SetUpTearDownTrait;
16+
1417
protected $bucket;
1518
protected $chunksCollection;
1619
protected $filesCollection;
1720

18-
public function setUp()
21+
private function doSetUp()
1922
{
2023
parent::setUp();
2124

tests/GridFS/ReadableStreamFunctionalTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
use MongoDB\GridFS\Exception\CorruptFileException;
1010
use MongoDB\Tests\CommandObserver;
1111
use stdClass;
12+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1213

1314
/**
1415
* Functional tests for the internal ReadableStream class.
1516
*/
1617
class ReadableStreamFunctionalTest extends FunctionalTestCase
1718
{
19+
use SetUpTearDownTrait;
20+
1821
private $collectionWrapper;
1922

20-
public function setUp()
23+
private function doSetUp()
2124
{
2225
parent::setUp();
2326

tests/GridFS/SpecFunctionalTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use IteratorIterator;
1414
use LogicException;
1515
use MultipleIterator;
16+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1617

1718
/**
1819
* GridFS spec functional tests.
@@ -21,10 +22,12 @@
2122
*/
2223
class SpecFunctionalTest extends FunctionalTestCase
2324
{
25+
use SetUpTearDownTrait;
26+
2427
private $expectedChunksCollection;
2528
private $expectedFilesCollection;
2629

27-
public function setUp()
30+
private function doSetUp()
2831
{
2932
parent::setUp();
3033

0 commit comments

Comments
 (0)