8000 [Cache] Fix test failure related to Redis6Proxy on appveyor · symfony/symfony@fb8f9ff · GitHub
[go: up one dir, main page]

Skip to content

Commit fb8f9ff

Browse files
[Cache] Fix test failure related to Redis6Proxy on appveyor
1 parent c5982aa commit fb8f9ff

File tree

7 files changed

+25
-148
lines changed
  • 7 files changed

    +25
    -148
    lines changed

    src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php

    Lines changed: 8 additions & 52 deletions
    Original file line numberDiff line numberDiff line change
    @@ -19,15 +19,16 @@
    1919
    class RedisProxiesTest extends TestCase
    2020
    {
    2121
    /**
    22-
    * @requires extension redis < 6
    22+
    * @requires extension redis
    2323
    *
    2424
    * @testWith ["Redis"]
    2525
    * ["RedisCluster"]
    2626
    */
    27-
    public function testRedis5Proxy($class)
    27+
    public function testRedisProxy($class)
    2828
    {
    29-
    $proxy = file_get_contents(\dirname(__DIR__, 2)."/Traits/{$class}5Proxy.php");
    30-
    $proxy = substr($proxy, 0, 4 + strpos($proxy, '[];'));
    29+
    $version = version_compare(phpversion('redis'), '6', '>') ? '6' : '5';
    30+
    $proxy = file_get_contents(\dirname(__DIR__, 2)."/Traits/{$class}{$version}Proxy.php");
    31+
    $expected = substr($proxy, 0, 4 + strpos($proxy, '[];'));
    3132
    $methods = [];
    3233

    3334
    foreach ((new \ReflectionClass($class))->getMethods() as $method) {
    @@ -44,9 +45,10 @@ public function testRedis5Proxy($class)
    4445
    }
    4546

    4647
    uksort($methods, 'strnatcmp');
    47-
    $proxy .= implode('', $methods)."}\n";
    48+
    $expected .= implode('', $methods)."}\n";
    49+
    $proxy = str_replace('#[\SensitiveParameter] ', '', $proxy);
    4850

    49-
    $this->assertStringEqualsFile(\dirname(__DIR__, 2)."/Traits/{$class}5Proxy.php", $proxy);
    51+
    $this->assertSame($expected, $proxy);
    5052
    }
    5153

    5254
    /**
    @@ -77,50 +79,4 @@ public function testRelayProxy()
    7779

    7880
    $this->assertStringEqualsFile(\dirname(__DIR__, 2).'/Traits/RelayProxy.php', $proxy);
    7981
    }
    80-
    81-
    /**
    82-
    * @requires extension openssl
    83-
    *
    84-
    * @testWith ["Redis", "redis"]
    85-
    * ["RedisCluster", "redis_cluster"]
    86-
    */
    87-
    public function testRedis6Proxy($class, $stub)
    88-
    {
    89-
    if (version_compare(phpversion('redis'), '6.0.2', '>')) {
    90-
    $stub = file_get_contents("https://raw.githubusercontent.com/phpredis/phpredis/develop/{$stub}.stub.php");
    91-
    } else {
    92-
    $stub = file_get_contents("https://raw.githubusercontent.com/phpredis/phpredis/6.0.2/{$stub}.stub.php");
    93-
    }
    94-
    95-
    $stub = preg_replace('/^class /m', 'return; \0', $stub);
    96-
    $stub = preg_replace('/^return; class ([a-zA-Z]++)/m', 'interface \1StubInterface', $stub, 1);
    97-
    $stub = preg_replace('/^ public const .*/m', '', $stub);
    98-
    eval(substr($stub, 5));
    99-
    100-
    $this->assertEquals(self::dumpMethods(new \ReflectionClass($class.'StubInterface')), self::dumpMethods(new \ReflectionClass(sprintf('Symfony\Component\Cache\Traits\%s6Proxy', $class))));
    101-
    }
    102-
    103-
    private static function dumpMethods(\ReflectionClass $class): string
    104-
    {
    105-
    $methods = [];
    106-
    107-
    foreach ($class->getMethods() as $method) {
    108-
    if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) {
    109-
    continue;
    110-
    }
    111-
    112-
    $return = $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
    113-
    $signature = ProxyHelper::exportSignature($method, false, $args);
    114-
    $methods[] = "\n ".str_replace('timeout = 0.0', 'timeout = 0', $signature)."\n".<<<EOPHP
    115-
    {
    116-
    {$return}(\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args});
    117-
    }
    118-
    119-
    EOPHP;
    120-
    }
    121-
    122-
    usort($methods, 'strnatcmp');
    123-
    124-
    return implode("\n", $methods);
    125-
    }
    12682
    }

    src/Symfony/Component/Cache/Traits/Redis5Proxy.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -81,7 +81,7 @@ public function append($key, $value)
    8181
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->append(...\func_get_args());
    8282
    }
    8383

    84-
    public function auth($auth)
    84+
    public function auth(#[\SensitiveParameter] $auth)
    8585
    {
    8686
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->auth(...\func_get_args());
    8787
    }

    src/Symfony/Component/Cache/Traits/Redis6Proxy.php

    Lines changed: 10 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -28,7 +28,6 @@ class Redis6Proxy extends \Redis implements ResetInterface, LazyObjectInterface
    2828
    use LazyProxyTrait {
    2929
    resetLazyObject as reset;
    3030
    }
    31-
    use Redis6ProxyTrait;
    3231

    3332
    private const LAZY_OBJECT_PROPERTY_SCOPES = [];
    3433

    @@ -227,6 +226,11 @@ public function discard(): \Redis|bool
    227226
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->discard(...\func_get_args());
    228227
    }
    229228

    229+
    public function dump($key): \Redis|string
    230+
    {
    231+
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dump(...\func_get_args());
    232+
    }
    233+
    230234
    public function echo($str): \Redis|false|string
    231235
    {
    232236
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->echo(...\func_get_args());
    @@ -647,6 +651,11 @@ public function ltrim($key, $start, $end): \Redis|bool
    647651
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ltrim(...\func_get_args());
    648652
    }
    649653

    654+
    public function mget($keys): \Redis|array
    655+
    {
    656+
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mget(...\func_get_args());
    657+
    }
    658+
    650659
    public function migrate($host, $port, $key, $dstdb, $timeout, $copy = false, $replace = false, #[\SensitiveParameter] $credentials = null): \Redis|bool
    651660
    {
    652661
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->migrate(...\func_get_args());

    src/Symfony/Component/Cache/Traits/Redis6ProxyTrait.php

    Lines changed: 0 additions & 51 deletions
    This file was deleted.

    src/Symfony/Component/Cache/Traits/RedisCluster5Proxy.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -31,7 +31,7 @@ class RedisCluster5Proxy extends \RedisCluster implements ResetInterface, LazyOb
    3131

    3232
    private const LAZY_OBJECT_PROPERTY_SCOPES = [];
    3333

    34-
    public function __construct($name, $seeds = null, $timeout = null, $read_timeout = null, $persistent = null, $auth = null)
    34+
    public function __construct($name, $seeds = null, $timeout = null, $read_timeout = null, $persistent = null, #[\SensitiveParameter] $auth = null)
    3535
    {
    3636
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->__construct(...\func_get_args());
    3737
    }

    src/Symfony/Component/Cache/Traits/RedisCluster6Proxy.php

    Lines changed: 5 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -28,7 +28,6 @@ class RedisCluster6Proxy extends \RedisCluster implements ResetInterface, LazyOb
    2828
    use LazyProxyTrait {
    2929
    resetLazyObject as reset;
    3030
    }
    31-
    use RedisCluster6ProxyTrait;
    3231

    3332
    private const LAZY_OBJECT_PROPERTY_SCOPES = [];
    3433

    @@ -657,6 +656,11 @@ public function pttl($key): \RedisCluster|false|int
    657656
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pttl(...\func_get_args());
    658657
    }
    659658

    659+
    public function publish($channel, $message): \RedisCluster|bool
    660+
    {
    661+
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->publish(...\func_get_args());
    662+
    }
    663+
    660664
    public function pubsub($key_or_address, ...$values): mixed
    661665
    {
    662666
    return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pubsub(...\func_get_args());

    src/Symfony/Component/Cache/Traits/RedisCluster6ProxyTrait.php

    Lines changed: 0 additions & 41 deletions
    This file was deleted.

    0 commit comments

    Comments
     (0)
    0