diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4cd8756..5218a6e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: @@ -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 diff --git a/.gitignore b/.gitignore index 592d95b..d6a2742 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ build/ raw-tests/ vendor/ .php-cs-fixer.cache +.phpunit.cache .phpunit.result.cache composer.lock composer.phar diff --git a/composer.json b/composer.json index 9d74d62..11f9b82 100644 --- a/composer.json +++ b/composer.json @@ -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, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d5562b3..10cce0c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,10 @@ - - - src - + 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"> + @@ -30,4 +27,9 @@ + + + src + + diff --git a/tests/Debug/SessionCollectorTest.php b/tests/Debug/SessionCollectorTest.php index a653749..be5dbbe 100644 --- a/tests/Debug/SessionCollectorTest.php +++ b/tests/Debug/SessionCollectorTest.php @@ -161,61 +161,6 @@ public function testAutoRegenerateId() : void ); } - /** - * @return Generator> - */ - 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 * @@ -284,4 +229,59 @@ protected function unlock() : bool $this->collector->getContents() ); } + + /** + * @return Generator> + */ + 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), + ]; + } } diff --git a/tests/SaveHandlers/MemcachedHandlerTest.php b/tests/SaveHandlers/MemcachedHandlerTest.php index 6b5de1d..a45b875 100644 --- a/tests/SaveHandlers/MemcachedHandlerTest.php +++ b/tests/SaveHandlers/MemcachedHandlerTest.php @@ -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'), @@ -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