Skip to content

Commit f5aec2d

Browse files
Merge branch '5.4' into 6.2
* 5.4: [FrameworkBundle] Improve error message in MicroKernelTrait when using deprecated configureRoutes(RouteCollectionBuilder) with symfony/routing >= 6.0 Add warning about Symfony 5.2 changing pcntl_async_signals [Tests] Fix static calls and Mock var annotation [FrameworkBundle] Fix checkboxes check assertions [Notifier][WebProfilerBundle] Ignore messages whose `getNotification` returns `null` [HttpClient] Fix over-encoding of URL parts to match browser's behavior Fix Psalm job [HttpClient] Fix data collector [Tests] Migrate tests to static data providers [Semaphore] Fix test Fix: Split and clean up tests Remove unused data provider add Sender to the list of bypassed headers
2 parents 7e2aa3f + 4072090 commit f5aec2d

File tree

4 files changed

+118
-12
lines changed

4 files changed

+118
-12
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock\Tests\Store;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Lock\Store\MongoDbStore;
16+
use Symfony\Component\Lock\Store\StoreFactory;
17+
18+
/**
19+
* @author Alexandre Daubois <alex.daubois@gmail.com>
20+
*
21+
* @requires extension mongo
22+
*/
23+
class MongoDbStoreFactoryTest extends TestCase
24+
{
25+
public function testCreateMongoDbCollectionStore()
26+
{
27+
$store = StoreFactory::createStore($this->createMock(\MongoDB\Collection::class));
28+
29+
$this->assertInstanceOf(MongoDbStore::class, $store);
30+
}
31+
32+
public function testCreateMongoDbCollectionStoreAsDsn()
33+
{
34+
$store = StoreFactory::createStore('mongodb://localhost/test?collection=lock');
35+
36+
$this->assertInstanceOf(MongoDbStore::class, $store);
37+
}
38+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock\Tests\Store;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Cache\Traits\RedisProxy;
16+
use Symfony\Component\Lock\Store\RedisStore;
17+
use Symfony\Component\Lock\Store\StoreFactory;
18+
19+
/**
20+
* @author Alexandre Daubois <alex.daubois@gmail.com>
21+
*/
22+
class RedisProxyStoreFactoryTest extends TestCase
23+
{
24+
public function testCreateStore()
25+
{
26+
if (!class_exists(RedisProxy::class)) {
27+
$this->markTestSkipped();
28+
}
29+
30+
$store = StoreFactory::createStore($this->createMock(RedisProxy::class));
31+
32+
$this->assertInstanceOf(RedisStore::class, $store);
33+
}
34+
}

Tests/Store/StoreFactoryTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@
2020
use Symfony\Component\Lock\Store\FlockStore;
2121
use Symfony\Component\Lock\Store\InMemoryStore;
2222
use Symfony\Component\Lock\Store\MemcachedStore;
23-
use Symfony\Component\Lock\Store\MongoDbStore;
2423
use Symfony\Component\Lock\Store\PdoStore;
2524
use Symfony\Component\Lock\Store\PostgreSqlStore;
2625
use Symfony\Component\Lock\Store\RedisStore;
2726
use Symfony\Component\Lock\Store\SemaphoreStore;
2827
use Symfony\Component\Lock\Store\StoreFactory;
29-
use Symfony\Component\Lock\Store\ZookeeperStore;
3028

3129
/**
3230
* @author Jérémy Derussé <jeremy@derusse.com>
@@ -43,7 +41,7 @@ public function testCreateStore($connection, string $expectedStoreClass)
4341
$this->assertInstanceOf($expectedStoreClass, $store);
4442
}
4543

46-
public function validConnections()
44+
public static function validConnections(): \Generator
4745
{
4846
if (class_exists(\Redis::class)) {
4947
yield [new \Redis(), RedisStore::class];
@@ -52,15 +50,6 @@ public function validConnections()
5250
if (class_exists(\Memcached::class)) {
5351
yield [new \Memcached(), MemcachedStore::class];
5452
}
55-
if (class_exists(\MongoDB\Collection::class)) {
56-
yield [$this->createMock(\MongoDB\Collection::class), MongoDbStore::class];
57-
yield ['mongodb://localhost/test?collection=lock', MongoDbStore::class];
58-
}
59-
if (class_exists(\Zookeeper::class)) {
60-
yield [$this->createMock(\Zookeeper::class), ZookeeperStore::class];
61-
yield ['zookeeper://localhost:2181', ZookeeperStore::class];
62-
yield ['zookeeper://localhost01,localhost02:2181', ZookeeperStore::class];
63-
}
6453
if (\extension_loaded('sysvsem')) {
6554
yield ['semaphore', SemaphoreStore::class];
6655
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock\Tests\Store;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Lock\Store\StoreFactory;
16+
use Symfony\Component\Lock\Store\ZookeeperStore;
17+
18+
/**
19+
* @author Alexandre Daubois <alex.daubois@gmail.com>
20+
*
21+
* @requires extension zookeeper
22+
*/
23+
class ZookeeperStoreFactoryTest extends TestCase
24+
{
25+
public function testCreateZooKeeperStore()
26+
{
27+
$store = StoreFactory::createStore($this->createMock(\Zookeeper::class));
28+
29+
$this->assertInstanceOf(ZookeeperStore::class, $store);
30+
}
31+
32+
public function testCreateZooKeeperStoreAsDsn()
33+
{
34+
$store = StoreFactory::createStore('zookeeper://localhost:2181');
35+
36+
$this->assertInstanceOf(ZookeeperStore::class, $store);
37+
}
38+
39+
public function testCreateZooKeeperStoreWithMultipleHosts()
40+
{
41+
$store = StoreFactory::createStore('zookeeper://localhost01,localhost02:2181');
42+
43+
$this->assertInstanceOf(ZookeeperStore::class, $store);
44+
}
45+
}

0 commit comments

Comments
 (0)