|
12 | 12 | namespace Symfony\Component\Semaphore\Tests\Store;
|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 |
| -use Symfony\Component\Cache\Traits\RedisProxy; |
16 | 15 | use Symfony\Component\Semaphore\Store\RedisStore;
|
17 | 16 | use Symfony\Component\Semaphore\Store\StoreFactory;
|
18 | 17 |
|
19 | 18 | /**
|
20 | 19 | * @author Jérémy Derussé <jeremy@derusse.com>
|
21 |
| - * |
22 |
| - * @requires extension redis |
23 | 20 | */
|
24 | 21 | class StoreFactoryTest extends TestCase
|
25 | 22 | {
|
26 |
| - public function testCreateRedisStore() |
| 23 | + /** |
| 24 | + * @dataProvider validConnections |
| 25 | + */ |
| 26 | + public function testCreateStore($connection, string $expectedStoreClass) |
27 | 27 | {
|
28 |
| - $store = StoreFactory::createStore($this->createMock(\Redis::class)); |
| 28 | + $store = StoreFactory::createStore($connection); |
29 | 29 |
|
30 |
| - $this->assertInstanceOf(RedisStore::class, $store); |
| 30 | + $this->assertInstanceOf($expectedStoreClass, $store); |
31 | 31 | }
|
32 | 32 |
|
33 |
| - public function testCreateRedisProxyStore() |
| 33 | + public static function validConnections(): \Generator |
34 | 34 | {
|
35 |
| - if (!class_exists(RedisProxy::class)) { |
36 |
| - $this->markTestSkipped(); |
37 |
| - } |
| 35 | + yield [new \Predis\Client(), RedisStore::class]; |
38 | 36 |
|
39 |
| - $store = StoreFactory::createStore($this->createMock(RedisProxy::class)); |
40 |
| - |
41 |
| - $this->assertInstanceOf(RedisStore::class, $store); |
42 |
| - } |
43 |
| - |
44 |
| - public function testCreateRedisAsDsnStore() |
45 |
| - { |
46 |
| - if (!class_exists(RedisProxy::class)) { |
47 |
| - $this->markTestSkipped(); |
| 37 | + if (class_exists(\Redis::class)) { |
| 38 | + yield [new \Redis(), RedisStore::class]; |
48 | 39 | }
|
49 |
| - |
50 |
| - $store = StoreFactory::createStore('redis://localhost'); |
51 |
| - |
52 |
| - $this->assertInstanceOf(RedisStore::class, $store); |
53 |
| - } |
54 |
| - |
55 |
| - public function testCreatePredisStore() |
56 |
| - { |
57 |
| - if (!class_exists(\Predis\Client::class)) { |
58 |
| - $this->markTestSkipped(); |
| 40 | + if (class_exists(\Redis::class) && class_exists(AbstractAdapter::class)) { |
| 41 | + yield ['redis://localhost', RedisStore::class]; |
| 42 | + yield ['redis://localhost?lazy=1', RedisStore::class]; |
| 43 | + yield ['redis://localhost?redis_cluster=1', RedisStore::class]; |
| 44 | + yield ['redis://localhost?redis_cluster=1&lazy=1', RedisStore::class]; |
| 45 | + yield ['redis:?host[localhost]&host[localhost:6379]&redis_cluster=1', RedisStore::class]; |
59 | 46 | }
|
60 |
| - |
61 |
| - $store = StoreFactory::createStore(new \Predis\Client()); |
62 |
| - |
63 |
| - $this->assertInstanceOf(RedisStore::class, $store); |
64 | 47 | }
|
65 | 48 | }
|
0 commit comments