Skip to content

Commit d311b21

Browse files
committed
minor symfony#52335 [Lock] Fix mongodb extension requirement in tests (GromNaN)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Lock] Fix mongodb extension requirement in tests | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT The MongoDB session store relies on `ext-mongodb`, not the legacy `ext-mongo`. Fix the PhpUnit requirement so the tests are not skipped: https://github.com/symfony/symfony/actions/runs/6668689428/job/18124800680#step:7:559 Commits ------- f9029cf [Lock] Fix mongodb extension requirement in tests
2 parents b2e372d + f9029cf commit d311b21

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use MongoDB\Client;
1515
use PHPUnit\Framework\MockObject\MockObject;
16+
use PHPUnit\Framework\SkippedTestSuiteError;
1617
use PHPUnit\Framework\TestCase;
1718
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler;
1819

@@ -32,13 +33,16 @@ class MongoDbSessionHandlerTest extends TestCase
3233
private $storage;
3334
public $options;
3435

35-
protected function setUp(): void
36+
public static function setUpBeforeClass(): void
3637
{
37-
parent::setUp();
38-
3938
if (!class_exists(Client::class)) {
40-
$this->markTestSkipped('The mongodb/mongodb package is required.');
39+
throw new SkippedTestSuiteError('The mongodb/mongodb package is required.');
4140
}
41+
}
42+
43+
protected function setUp(): void
44+
{
45+
parent::setUp();
4246

4347
$this->mongo = $this->getMockBuilder(Client::class)
4448
->disableOriginalConstructor()

src/Symfony/Component/Lock/Tests/Store/MongoDbStoreFactoryTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,30 @@
1111

1212
namespace Symfony\Component\Lock\Tests\Store;
1313

14+
use MongoDB\Collection;
15+
use MongoDB\Client;
16+
use PHPUnit\Framework\SkippedTestSuiteError;
1417
use PHPUnit\Framework\TestCase;
1518
use Symfony\Component\Lock\Store\MongoDbStore;
1619
use Symfony\Component\Lock\Store\StoreFactory;
1720

1821
/**
1922
* @author Alexandre Daubois <alex.daubois@gmail.com>
2023
*
21-
* @requires extension mongo
24+
* @requires extension mongodb
2225
*/
2326
class MongoDbStoreFactoryTest extends TestCase
2427
{
28+
public static function setupBeforeClass(): void
29+
{
30+
if (!class_exists(Client::class)) {
31+
throw new SkippedTestSuiteError('The mongodb/mongodb package is required.');
32+
}
33+
}
34+
2535
public function testCreateMongoDbCollectionStore()
2636
{
27-
$store = StoreFactory::createStore($this->createMock(\MongoDB\Collection::class));
37+
$store = StoreFactory::createStore($this->createMock(Collection::class));
2838

2939
$this->assertInstanceOf(MongoDbStore::class, $store);
3040
}

src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class MongoDbStoreTest extends AbstractStoreTestCase
3232

3333
public static function setupBeforeClass(): void
3434
{
35-
if (!class_exists(\MongoDB\Client::class)) {
35+
if (!class_exists(Client::class)) {
3636
throw new SkippedTestSuiteError('The mongodb/mongodb package is required.');
3737
}
3838

0 commit comments

Comments
 (0)