|
15 | 15 | use Symfony\Component\VarExporter\LazyProxyTrait; |
16 | 16 | use Symfony\Component\VarExporter\ProxyHelper; |
17 | 17 |
|
18 | | -/** |
19 | | - * @requires extension redis |
20 | | - */ |
21 | 18 | class RedisProxiesTest extends TestCase |
22 | 19 | { |
23 | 20 | /** |
| 21 | + * @requires extension redis < 6 |
| 22 | + * |
24 | 23 | * @testWith ["Redis"] |
25 | 24 | * ["RedisCluster"] |
26 | 25 | */ |
@@ -50,24 +49,31 @@ public function testRedis5Proxy($class) |
50 | 49 | } |
51 | 50 |
|
52 | 51 | /** |
| 52 | + * @requires extension redis |
| 53 | + * |
53 | 54 | * @testWith ["Redis", "redis"] |
54 | 55 | * ["RedisCluster", "redis_cluster"] |
55 | 56 | */ |
56 | 57 | public function testRedis6Proxy($class, $stub) |
57 | 58 | { |
58 | | - $this->markTestIncomplete('To be re-enabled when phpredis v6 becomes stable'); |
| 59 | + if (version_compare(phpversion('redis'), '6.0.0', '<')) { |
| 60 | + $this->markTestIncomplete('To be re-enabled when phpredis v6 becomes stable'); |
59 | 61 |
|
60 | | - $stub = file_get_contents("https://raw.githubusercontent.com/phpredis/phpredis/develop/{$stub}.stub.php"); |
61 | | - $stub = preg_replace('/^class /m', 'return; \0', $stub); |
62 | | - $stub = preg_replace('/^return; class ([a-zA-Z]++)/m', 'interface \1StubInterface', $stub, 1); |
63 | | - $stub = preg_replace('/^ public const .*/m', '', $stub); |
64 | | - eval(substr($stub, 5)); |
| 62 | + $stub = file_get_contents("https://raw.githubusercontent.com/phpredis/phpredis/develop/{$stub}.stub.php"); |
| 63 | + $stub = preg_replace('/^class /m', 'return; \0', $stub); |
| 64 | + $stub = preg_replace('/^return; class ([a-zA-Z]++)/m', 'interface \1StubInterface', $stub, 1); |
| 65 | + $stub = preg_replace('/^ public const .*/m', '', $stub); |
| 66 | + eval(substr($stub, 5)); |
| 67 | + $r = new \ReflectionClass($class.'StubInterface'); |
| 68 | + } else { |
| 69 | + $r = new \ReflectionClass($class); |
| 70 | + } |
65 | 71 |
|
66 | 72 | $proxy = file_get_contents(\dirname(__DIR__, 2)."/Traits/{$class}6Proxy.php"); |
67 | 73 | $proxy = substr($proxy, 0, 4 + strpos($proxy, '[];')); |
68 | 74 | $methods = []; |
69 | 75 |
|
70 | | - foreach ((new \ReflectionClass($class.'StubInterface'))->getMethods() as $method) { |
| 76 | + foreach ($r->getMethods() as $method) { |
71 | 77 | if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) { |
72 | 78 | continue; |
73 | 79 | } |
|
0 commit comments