8000 [Lock] Fix mongodb extension requirement in tests by GromNaN · Pull Request #52335 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Lock] Fix mongodb extension requirement in tests #52335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 <alex.daubois@gmail.com>
*
* @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