Skip to content

Commit

Permalink
Upgrade phpunit to version ^10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Jan 11, 2024
1 parent adaa18b commit 23f45ef
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
DB_HOST: 127.0.0.1
MEMCACHED_HOST: 127.0.0.1
REDIS_HOST: 127.0.0.1
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit

- name: Upload coverage results to Coveralls
env:
Expand Down Expand Up @@ -136,4 +136,4 @@ jobs:
DB_HOST: 127.0.0.1
MEMCACHED_HOST: 127.0.0.1
REDIS_HOST: 127.0.0.1
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build/
raw-tests/
vendor/
.php-cs-fixer.cache
.phpunit.cache
.phpunit.result.cache
composer.lock
composer.phar
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"jetbrains/phpstorm-attributes": "^1.0",
"phpmd/phpmd": "^2.13",
"phpstan/phpstan": "^1.5",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^10.5"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
18 changes: 10 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false"
bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false"
stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
bootstrap="vendor/autoload.php" colors="true" stopOnError="false" stopOnFailure="false"
stopOnIncomplete="false" stopOnSkipped="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache">
<coverage>
<report>
<clover outputFile="build/coverage/clover.xml"/>
<html outputDirectory="build/coverage"/>
Expand All @@ -30,4 +27,9 @@
<env name="DB_TABLE" value="Sessions"/>
<env name="XDEBUG_MODE" value="coverage"/>
</php>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
110 changes: 55 additions & 55 deletions tests/Debug/SessionCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,61 +161,6 @@ public function testAutoRegenerateId() : void
);
}

/**
* @return Generator<array<SaveHandler>>
*/
public function saveHandlerProvider() : Generator
{
$directory = \sys_get_temp_dir() . '/sessions';
if (!\is_dir($directory)) {
\mkdir($directory);
}
yield [
new FilesHandler([
'directory' => $directory,
]),
];
yield [
new MemcachedHandler([
'servers' => [
[
'host' => \getenv('MEMCACHED_HOST'),
],
[
// @phpstan-ignore-next-line
'host' => \gethostbyname(\getenv('MEMCACHED_HOST')),
],
],
]),
];
yield [
new RedisHandler([
'host' => \getenv('REDIS_HOST'),
]),
];
$config = [
'username' => \getenv('DB_USERNAME'),
'password' => \getenv('DB_PASSWORD'),
'schema' => \getenv('DB_SCHEMA'),
'host' => \getenv('DB_HOST'),
'port' => \getenv('DB_PORT'),
'table' => \getenv('DB_TABLE'),
];
$database = new Database($config);
$database->dropTable($config['table'])->ifExists()->run(); // @phpstan-ignore-line
// @phpstan-ignore-next-line
$database->createTable($config['table'])
->definition(static function (TableDefinition $definition) : void {
$definition->column('id')->varchar(128)->primaryKey();
$definition->column('timestamp')->timestamp();
$definition->column('data')->blob();
$definition->index('timestamp')->key('timestamp');
})->run();
yield [
new DatabaseHandler($config),
];
}

/**
* @dataProvider saveHandlerProvider
*
Expand Down Expand Up @@ -284,4 +229,59 @@ protected function unlock() : bool
$this->collector->getContents()
);
}

/**
* @return Generator<array<SaveHandler>>
*/
public static function saveHandlerProvider() : Generator
{
$directory = \sys_get_temp_dir() . '/sessions';
if (!\is_dir($directory)) {
\mkdir($directory);
}
yield [
new FilesHandler([
'directory' => $directory,
]),
];
yield [
new MemcachedHandler([
'servers' => [
[
'host' => \getenv('MEMCACHED_HOST'),
],
[
// @phpstan-ignore-next-line
'host' => \gethostbyname(\getenv('MEMCACHED_HOST')),
],
],
]),
];
yield [
new RedisHandler([
'host' => \getenv('REDIS_HOST'),
]),
];
$config = [
'username' => \getenv('DB_USERNAME'),
'password' => \getenv('DB_PASSWORD'),
'schema' => \getenv('DB_SCHEMA'),
'host' => \getenv('DB_HOST'),
'port' => \getenv('DB_PORT'),
'table' => \getenv('DB_TABLE'),
];
$database = new Database($config);
$database->dropTable($config['table'])->ifExists()->run(); // @phpstan-ignore-line
// @phpstan-ignore-next-line
$database->createTable($config['table'])
->definition(static function (TableDefinition $definition) : void {
$definition->column('id')->varchar(128)->primaryKey();
$definition->column('timestamp')->timestamp();
$definition->column('data')->blob();
$definition->index('timestamp')->key('timestamp');
})->run();
yield [
new DatabaseHandler($config),
];
}
}
8 changes: 5 additions & 3 deletions tests/SaveHandlers/MemcachedHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ public function testRepeatedServer() : void
public function testInvalidOption() : void
{
$this->session->stop();
$this->expectWarning();
$this->expectWarningMessage('Memcached::setOptions(): invalid configuration option');
(new MemcachedHandler([
@(new MemcachedHandler([
'servers' => [
[
'host' => \getenv('MEMCACHED_HOST'),
Expand All @@ -110,6 +108,10 @@ public function testInvalidOption() : void
'foo' => 'bar',
],
], $this->logger))->open('', 'session_id');
self::assertSame(
'Memcached::setOptions(): invalid configuration option',
\error_get_last()['message']
);
}

public function testFailToRead() : void
Expand Down

0 comments on commit 23f45ef

Please sign in to comment.