diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a60db8d..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: @@ -85,7 +85,7 @@ jobs: composer global require php-coveralls/php-coveralls php-coveralls --coverage_clover=build/logs/clover.xml -v - tests-last: + tests-latest: runs-on: ubuntu-22.04 timeout-minutes: 10 @@ -114,7 +114,7 @@ jobs: ports: - 6379:6379 - name: PHP 8.2 - Last + name: PHP Latest steps: - name: Checkout @@ -123,7 +123,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: latest tools: composer coverage: xdebug @@ -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/.gitlab-ci.yml b/.gitlab-ci.yml index c0218bc..12205a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,8 +37,8 @@ test:php: - build/docs/ coverage: '/^\s*Lines:\s*\d+.\d+\%/' -test:php-last: - image: registry.gitlab.com/aplus-framework/images/base:3 +test:php-latest: + image: registry.gitlab.com/aplus-framework/images/base:latest stage: test timeout: 10 minutes cache: 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/docker-compose.yml b/docker-compose.yml index 28af029..8540a79 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,9 +11,9 @@ services: - memcached - redis tty: true - package-last: - image: registry.gitlab.com/aplus-framework/images/package:3 - container_name: package-session-last + package-latest: + image: registry.gitlab.com/aplus-framework/images/package:latest + container_name: package-session-latest working_dir: /package volumes: - .:/package diff --git a/guide/index.rst b/guide/index.rst index b924990..81eff2d 100644 --- a/guide/index.rst +++ b/guide/index.rst @@ -441,5 +441,5 @@ The more you use it, the more you will learn. .. note:: Did you find something wrong? Be sure to let us know about it with an - `issue `_. + `issue `_. Thank you! 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/src/Session.php b/src/Session.php index 10648db..469691f 100644 --- a/src/Session.php +++ b/src/Session.php @@ -260,6 +260,7 @@ public function destroyCookie() : bool throw new RuntimeException('Could not get the session name'); } $params = \session_get_cookie_params(); + // @phpstan-ignore-next-line return \setcookie($name, '', [ 'expires' => 0, 'path' => $params['path'], 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