Skip to content

Commit

Permalink
Merge branch '5.4' into 6.3
Browse files Browse the repository at this point in the history
* 5.4:
  [Lock] Fix mongodb extension requirement in tests
  • Loading branch information
fabpot committed Oct 28, 2023
2 parents 0cef1e4 + d311b21 commit b41d545
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use MongoDB\Client;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\SkippedTestSuiteError;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler;

Expand All @@ -32,13 +33,16 @@ class MongoDbSessionHandlerTest extends TestCase
private $storage;
public $options;

protected function setUp(): void
public static function setUpBeforeClass(): void
{
parent::setUp();

if (!class_exists(Client::class)) {
$this->markTestSkipped('The mongodb/mongodb package is required.');
throw new SkippedTestSuiteError('The mongodb/mongodb package is required.');
}
}

protected function setUp(): void
{
parent::setUp();

$this->mongo = $this->getMockBuilder(Client::class)
->disableOriginalConstructor()
Expand Down
14 changes: 12 additions & 2 deletions src/Symfony/Component/Lock/Tests/Store/MongoDbStoreFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,30 @@

namespace Symfony\Component\Lock\Tests\Store;

use MongoDB\Collection;
use MongoDB\Client;
use PHPUnit\Framework\SkippedTestSuiteError;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Lock\Store\MongoDbStore;
use Symfony\Component\Lock\Store\StoreFactory;

/**
* @author Alexandre Daubois <[email protected]>
*
* @requires extension mongo
* @requires extension mongodb
*/
class MongoDbStoreFactoryTest extends TestCase
{
public static function setupBeforeClass(): void
{
if (!class_exists(Client::class)) {
throw new SkippedTestSuiteError('The mongodb/mongodb package is required.');
}
}

public function testCreateMongoDbCollectionStore()
{
$store = StoreFactory::createStore($this->createMock(\MongoDB\Collection::class));
$store = StoreFactory::createStore($this->createMock(Collection::class));

$this->assertInstanceOf(MongoDbStore::class, $store);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MongoDbStoreTest extends AbstractStoreTestCase

public static function setupBeforeClass(): void
{
if (!class_exists(\MongoDB\Client::class)) {
if (!class_exists(Client::class)) {
throw new SkippedTestSuiteError('The mongodb/mongodb package is required.');
}

Expand Down

0 comments on commit b41d545

Please sign in to comment.