Skip to content

Commit

Permalink
Support phpunit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Dec 16, 2023
1 parent 3ea0156 commit ade5cb9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 35 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
"require-dev": {
"ext-pdo_sqlite": "*",
"ext-redis": "*",
"doctrine/annotations": "^1.13",
"doctrine/annotations": "^1.13 || ^2.0",
"doctrine/coding-standard": "^12.0",
"friendsofphp/proxy-manager-lts": "^1.0.6",
"monolog/monolog": "*",
"phpunit/phpunit": "^8.5.32 || ^9.5.28",
"phpunit/phpunit": "^9.5.28 || ^10",
"predis/predis": "^2.0",
"seec/phpunit-consecutive-params": "dev-master",
"symfony/browser-kit": "^4.4 || ^5.3 || ^6.0 || ^7.0",
"symfony/cache": "^4.4 || ^5.3 || ^6.0 || ^7.0",
"symfony/console": "^4.4 || ^5.3 || ^6.0 || ^7.0",
"symfony/dom-crawler": "^4.4 || ^5.3 || ^6.0 || ^7.0",
"symfony/filesystem": "^4.4 || ^5.3 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^6.0 || ^7.0",
"symfony/profiler-pack": "^1.0",
"symfony/stopwatch": "^4.4 || ^5.3 || ^6.0 || ^7.0",
"symfony/twig-bundle": "^4.4 || ^5.3 || ^6.0 || ^7.0",
Expand Down
26 changes: 10 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<env name="SHELL_VERBOSITY" value="-1" />
</php>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>

<testsuites>
<testsuite name="RedisBundle Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="-1"/>
<env name="SHELL_VERBOSITY" value="-1"/>
</php>
<testsuites>
<testsuite name="RedisBundle Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
4 changes: 2 additions & 2 deletions tests/DependencyInjection/Configuration/RedisDsnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class RedisDsnTest extends TestCase
{
/** @return list<list<string>> */
public function hostValues(): array
public static function hostValues(): array
{
return [
['redis://localhost', 'localhost'],
Expand Down Expand Up @@ -108,7 +108,7 @@ public function testSocket(string $dsn, string $socket): void
}

/** @return list<array{0: string, 1:bool}> */
public function tlsValues(): array
public static function tlsValues(): array
{
return [
['redis://localhost', false],
Expand Down
35 changes: 22 additions & 13 deletions tests/Factory/PhpredisClientFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Redis;
use RedisCluster;
use Relay\Relay;
use SEEC\PhpUnit\Helper\ConsecutiveParams;
use Snc\RedisBundle\Factory\PhpredisClientFactory;
use Snc\RedisBundle\Logger\RedisCallInterceptor;
use Snc\RedisBundle\Logger\RedisLogger;
Expand All @@ -23,6 +24,8 @@

class PhpredisClientFactoryTest extends TestCase
{
use ConsecutiveParams;

private MockObject $logger;
private RedisLogger $redisLogger;

Expand Down Expand Up @@ -56,9 +59,9 @@ public function testCreateMinimalConfig(): void
/** @requires extension relay */
public function testCreateRelay(): void
{
$this->logger->method('debug')->withConsecutive(
$this->logger->method('debug')->with(...$this->withConsecutive(

Check failure on line 62 in tests/Factory/PhpredisClientFactoryTest.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm

InvalidArgument

tests/Factory/PhpredisClientFactoryTest.php:62:49: InvalidArgument: Method PHPUnit\Framework\MockObject\Builder\InvocationMocker::with called with unpacked iterable iterable<mixed, mixed> with invalid key (must be int) (see https://psalm.dev/004)
[$this->stringContains('Executing command "CONNECT localhost 6379 5 <null>')],
);
));

$client = (new PhpredisClientFactory(new RedisCallInterceptor($this->redisLogger)))
->create(Relay::class, ['redis://localhost:6379'], ['connection_timeout' => 5], 'default', true);
Expand Down Expand Up @@ -109,10 +112,12 @@ public function testCreateMinimalClusterConfig(): void
*/
public function testCreateSentinelConfig(string $sentinelClass, string $outputClass): void
{
$this->logger->method('debug')->withConsecutive(
$this->logger->method('debug')->with(...$this->withConsecutive(

Check failure on line 115 in tests/Factory/PhpredisClientFactoryTest.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm

InvalidArgument

tests/Factory/PhpredisClientFactoryTest.php:115:49: InvalidArgument: Method PHPUnit\Framework\MockObject\Builder\InvocationMocker::with called with unpacked iterable iterable<mixed, mixed> with invalid key (must be int) (see https://psalm.dev/004)
[$this->stringContains('Executing command "CONNECT 127.0.0.1 6379 5 <null>')],
['Executing command "AUTH sncredis"'],
);
['Executing command "GETTIMEOUT"'],
['Executing command "GETAUTH"'],
));
$factory = new PhpredisClientFactory(new RedisCallInterceptor($this->redisLogger));

$client = $factory->create(
Expand Down Expand Up @@ -171,11 +176,13 @@ public function testCreateFullConfig(): void

public function testDsnConfig(): void
{
$this->logger->method('debug')->withConsecutive(
$this->logger->method('debug')->with(...$this->withConsecutive(

Check failure on line 179 in tests/Factory/PhpredisClientFactoryTest.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm

InvalidArgument

tests/Factory/PhpredisClientFactoryTest.php:179:49: InvalidArgument: Method PHPUnit\Framework\MockObject\Builder\InvocationMocker::with called with unpacked iterable iterable<mixed, mixed> with invalid key (must be int) (see https://psalm.dev/004)
[$this->stringContains('Executing command "CONNECT localhost 6379 5')],
['Executing command "AUTH sncredis"'],
['Executing command "SELECT 2"'],
);
['Executing command "GETDBNUM"'],
['Executing command "GETAUTH"'],
));

$factory = new PhpredisClientFactory(new RedisCallInterceptor($this->redisLogger));

Expand All @@ -201,11 +208,13 @@ public function testDsnConfig(): void

public function testDsnConfigWithUsername(): void
{
$this->logger->method('debug')->withConsecutive(
$this->logger->method('debug')->with(...$this->withConsecutive(

Check failure on line 211 in tests/Factory/PhpredisClientFactoryTest.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm

InvalidArgument

tests/Factory/PhpredisClientFactoryTest.php:211:49: InvalidArgument: Method PHPUnit\Framework\MockObject\Builder\InvocationMocker::with called with unpacked iterable iterable<mixed, mixed> with invalid key (must be int) (see https://psalm.dev/004)
[$this->stringContains('Executing command "CONNECT localhost 7099 5')],
['Executing command "AUTH snc_redis snc_password"'],
['Executing command "SELECT 0"'],
);
['Executing command "GETDBNUM"'],
['Executing command "GETAUTH"'],
));

$factory = new PhpredisClientFactory(new RedisCallInterceptor($this->redisLogger));

Expand Down Expand Up @@ -290,7 +299,7 @@ public function testLoadSerializationTypeFail(): void
}

/** @return list<array{0: string, 1: Redis::SERIALIZER_*}> */
public function serializationTypes(): array
public static function serializationTypes(): array
{
return [
['default', Redis::SERIALIZER_NONE],
Expand All @@ -302,14 +311,14 @@ public function serializationTypes(): array

public function testMethodsWithVariadicParameters(): void
{
$this->logger->method('debug')->withConsecutive(
$this->logger->method('debug')->with(...$this->withConsecutive(

Check failure on line 314 in tests/Factory/PhpredisClientFactoryTest.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm

InvalidArgument

tests/Factory/PhpredisClientFactoryTest.php:314:49: InvalidArgument: Method PHPUnit\Framework\MockObject\Builder\InvocationMocker::with called with unpacked iterable iterable<mixed, mixed> with invalid key (must be int) (see https://psalm.dev/004)
[$this->stringContains('Executing command "CONNECT localhost 6379 5')],
['Executing command "AUTH sncredis"'],
['Executing command "SELECT 2"'],
['Executing command "RAWCOMMAND scan fleet cursor 0 limit 10"'],
['Executing command "HDEL foo bar"'],
['Executing command "UNLINK bar baz"'],
);
));

$factory = new PhpredisClientFactory(new RedisCallInterceptor($this->redisLogger));

Expand All @@ -335,14 +344,14 @@ public function testMethodsWithVariadicParameters(): void

public function testMethodWithPassByRefArgument(): void
{
$this->logger->method('debug')->withConsecutive(
$this->logger->method('debug')->with(...$this->withConsecutive(

Check failure on line 347 in tests/Factory/PhpredisClientFactoryTest.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm

InvalidArgument

tests/Factory/PhpredisClientFactoryTest.php:347:49: InvalidArgument: Method PHPUnit\Framework\MockObject\Builder\InvocationMocker::with called with unpacked iterable iterable<mixed, mixed> with invalid key (must be int) (see https://psalm.dev/004)
[$this->stringContains('Executing command "CONNECT localhost 6379 5')],
['Executing command "AUTH sncredis"'],
['Executing command "SELECT 2"'],
['Executing command "SSCAN set 1 <null> 0"'],
['Executing command "SET mykey myvalue <null>"'],
['Executing command "SCAN <null> <null> ' . (version_compare(phpversion('redis'), '6', '<') ? '' : '0 ') . '<null>"'],
);
));

$factory = new PhpredisClientFactory(new RedisCallInterceptor($this->redisLogger));

Expand Down
2 changes: 1 addition & 1 deletion tests/Factory/PredisParametersFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class PredisParametersFactoryTest extends TestCase
{
/** @return array<array{0: string, 1: class-string, 2: array<string, mixed>, 3: array<string, mixed>}> */
public function createDp(): array
public static function createDp(): array
{
return [
[
Expand Down

0 comments on commit ade5cb9

Please sign in to comment.