From 2103fcac53eb9409c82bf01d141495fbc204f32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Br=C3=BCckner?= Date: Wed, 4 Dec 2024 09:06:25 +0100 Subject: [PATCH 1/2] Refactor navigation and headings for clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplified the navigation structure in mkdocs.yml and revised document headings for better consistency and readability. The changes improve how the HTTP client sections are organized and presented in the documentation, facilitating easier navigation and comprehension for users. Signed-off-by: Frank Brückner --- docs/book/client/adapters.md | 2 +- docs/book/client/advanced.md | 2 +- docs/book/client/intro.md | 2 +- docs/book/client/static.md | 2 +- docs/book/request.md | 2 +- docs/book/response.md | 2 +- mkdocs.yml | 19 +++++++++---------- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/docs/book/client/adapters.md b/docs/book/client/adapters.md index 8c4acadc..2693941f 100644 --- a/docs/book/client/adapters.md +++ b/docs/book/client/adapters.md @@ -1,4 +1,4 @@ -# HTTP Client Connection Adapters +# Connection Adapters `Laminas\Http\Client` is based on a connection adapter design. The connection adapter is the object in charge of performing the actual connection to the server, as well as writing requests and reading diff --git a/docs/book/client/advanced.md b/docs/book/client/advanced.md index 1beec7f5..165a7f67 100644 --- a/docs/book/client/advanced.md +++ b/docs/book/client/advanced.md @@ -1,4 +1,4 @@ -# HTTP Client Advanced Usage +# Advanced Usage ## HTTP redirections diff --git a/docs/book/client/intro.md b/docs/book/client/intro.md index 9f92ad94..9f880d8a 100644 --- a/docs/book/client/intro.md +++ b/docs/book/client/intro.md @@ -1,4 +1,4 @@ -# HTTP Client +# Introduction `Laminas\Http\Client` provides an interface for performing Hyper-Text Transfer Protocol (HTTP) requests. `Laminas\Http\Client` supports all basic features diff --git a/docs/book/client/static.md b/docs/book/client/static.md index f833157c..71d944d0 100644 --- a/docs/book/client/static.md +++ b/docs/book/client/static.md @@ -1,4 +1,4 @@ -# HTTP Client - Static Usage +# Static Usage laminas-http provides another client implementation, `Laminas\Http\ClientStatic`, a static HTTP client which exposes a simplified API for quickly performing one-off `GET` diff --git a/docs/book/request.md b/docs/book/request.md index e391a013..6ef98661 100644 --- a/docs/book/request.md +++ b/docs/book/request.md @@ -1,4 +1,4 @@ -# The Request Class +# Request `Laminas\Http\Request` is responsible for providing a fluent API that allows a developer to interact with all the various parts of an HTTP request. diff --git a/docs/book/response.md b/docs/book/response.md index 241ad9e5..16a563f1 100644 --- a/docs/book/response.md +++ b/docs/book/response.md @@ -1,4 +1,4 @@ -# The Response Class +# Response `Laminas\Http\Response` is responsible for providing a fluent API that allows a developer to interact with all the various parts of an HTTP response. diff --git a/mkdocs.yml b/mkdocs.yml index 9f9a1e64..943b1057 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -3,16 +3,15 @@ site_dir: docs/html nav: - Home: index.md - Introduction: intro.md - - Reference: - - Request: request.md - - Response: response.md - - Headers: headers.md - - Client: - - Intro: client/intro.md - - Adapters: client/adapters.md - - "Static Client": client/static.md - - "Cookie Persistence": client/cookies.md - - Advanced: client/advanced.md + - Request: request.md + - Response: response.md + - Headers: headers.md + - "HTTP Client": + - Introduction: client/intro.md + - "Connection Adapters": client/adapters.md + - "Static Usage": client/static.md + - "Client Cookies": client/cookies.md + - "Advanced Usage": client/advanced.md site_name: laminas-http site_description: HTTP message and header abstractions, and HTTP client implementation. (Not a PSR-7 implementation; see Diactoros for PSR-7 support. repo_url: 'https://github.com/laminas/laminas-http' From a389e80540ecef509742c99d58ef6ef44036ba79 Mon Sep 17 00:00:00 2001 From: fezfez Date: Thu, 21 Nov 2024 23:23:16 +0100 Subject: [PATCH 2/2] clean clean clean clean Signed-off-by: fezfez clean Signed-off-by: fezfez clean Signed-off-by: fezfez clean Signed-off-by: fezfez --- composer.json | 4 +- composer.lock | 692 ++++++++---------- phpcs.xml.dist | 4 + phpunit.xml.dist | 24 +- src/Client.php | 2 - src/Client/Adapter/Proxy.php | 1 - src/Header/Accept.php | 1 - src/Header/ContentTransferEncoding.php | 2 +- src/Header/ContentType.php | 1 - src/Header/SetCookie.php | 1 - src/PhpEnvironment/RemoteAddress.php | 1 - src/PhpEnvironment/Response.php | 1 - test/Client/Adapter/CurlTest.php | 15 +- test/Client/CommonHttpTests.php | 159 ++-- test/Client/CurlTest.php | 97 ++- test/Client/ProxyAdapterTest.php | 26 +- test/Client/SocketKeepaliveTest.php | 6 +- test/Client/SocketPersistentTest.php | 6 +- test/Client/SocketTest.php | 70 +- test/Client/StaticClientTest.php | 28 +- test/Client/StaticTest.php | 97 ++- test/Client/TestAdapterTest.php | 48 +- test/Client/UseCaseTest.php | 24 +- test/ClientTest.php | 112 ++- test/CookiesTest.php | 6 +- test/Header/AcceptCharsetTest.php | 29 +- test/Header/AcceptEncodingTest.php | 29 +- test/Header/AcceptLanguageTest.php | 31 +- test/Header/AcceptRangesTest.php | 20 +- test/Header/AcceptTest.php | 78 +- test/Header/AgeTest.php | 21 +- test/Header/AllowTest.php | 43 +- test/Header/AuthenticationInfoTest.php | 20 +- test/Header/AuthorizationTest.php | 20 +- test/Header/CacheControlTest.php | 27 +- test/Header/ConnectionTest.php | 21 +- test/Header/ContentDispositionTest.php | 20 +- test/Header/ContentEncodingTest.php | 20 +- test/Header/ContentLanguageTest.php | 20 +- test/Header/ContentLengthTest.php | 22 +- test/Header/ContentLocationTest.php | 16 +- test/Header/ContentMD5Test.php | 20 +- test/Header/ContentRangeTest.php | 20 +- .../ContentSecurityPolicyReportOnlyTest.php | 2 +- test/Header/ContentSecurityPolicyTest.php | 66 +- test/Header/ContentTransferEncodingTest.php | 20 +- test/Header/ContentTypeTest.php | 57 +- test/Header/CookieTest.php | 35 +- test/Header/DateTest.php | 34 +- test/Header/EtagTest.php | 20 +- test/Header/ExpectTest.php | 20 +- test/Header/ExpiresTest.php | 17 +- test/Header/FeaturePolicyTest.php | 27 +- test/Header/FromTest.php | 20 +- test/Header/GenericHeaderTest.php | 46 +- test/Header/HeaderValueTest.php | 37 +- test/Header/HostTest.php | 20 +- test/Header/IfMatchTest.php | 20 +- test/Header/IfModifiedSinceTest.php | 15 +- test/Header/IfNoneMatchTest.php | 20 +- test/Header/IfRangeTest.php | 20 +- test/Header/IfUnmodifiedSinceTest.php | 15 +- test/Header/KeepAliveTest.php | 20 +- test/Header/LastModifiedTest.php | 15 +- test/Header/LocationTest.php | 39 +- test/Header/MaxForwardsTest.php | 20 +- test/Header/OriginTest.php | 24 +- test/Header/PragmaTest.php | 20 +- test/Header/ProxyAuthenticateTest.php | 20 +- test/Header/ProxyAuthorizationTest.php | 20 +- test/Header/RangeTest.php | 20 +- test/Header/RefererTest.php | 20 +- test/Header/RefreshTest.php | 20 +- test/Header/RetryAfterTest.php | 16 +- test/Header/ServerTest.php | 20 +- test/Header/SetCookieTest.php | 127 ++-- test/Header/TETest.php | 20 +- test/Header/TrailerTest.php | 20 +- test/Header/TransferEncodingTest.php | 20 +- test/Header/UpgradeTest.php | 20 +- test/Header/UserAgentTest.php | 20 +- test/Header/VaryTest.php | 20 +- test/Header/ViaTest.php | 20 +- test/Header/WWWAuthenticateTest.php | 20 +- test/Header/WarningTest.php | 20 +- test/HeaderTest.php | 51 +- test/HeadersTest.php | 74 +- .../PhpEnvironment/Assets/MockHeadersSent.php | 7 + test/PhpEnvironment/RemoteAddressTest.php | 16 +- test/PhpEnvironment/RequestTest.php | 82 +-- test/PhpEnvironment/ResponseTest.php | 24 +- test/RequestTest.php | 116 +-- test/Response/ResponseStreamTest.php | 20 +- test/ResponseTest.php | 143 ++-- 94 files changed, 1555 insertions(+), 1975 deletions(-) create mode 100644 test/PhpEnvironment/Assets/MockHeadersSent.php diff --git a/composer.json b/composer.json index ecdc3403..06d7e441 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,8 @@ }, "require-dev": { "ext-curl": "*", - "laminas/laminas-coding-standard": "~2.4.0", - "phpunit/phpunit": "^9.6.21" + "laminas/laminas-coding-standard": "^3.0.1", + "phpunit/phpunit": "^10.5.38" }, "suggest": { "paragonie/certainty": "For automated management of cacert.pem" diff --git a/composer.lock b/composer.lock index 0f82a112..ec44b143 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "af6aefd1177315bae305df5d9d995d6b", + "content-hash": "fbd9d551c62de9bd6990961c456521ee", "packages": [ { "name": "brick/varexporter", @@ -784,35 +784,38 @@ "packages-dev": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", "shasum": "" }, "require": { "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", + "php": ">=5.4", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -828,7 +831,7 @@ }, { "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", @@ -852,104 +855,31 @@ "tests" ], "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" - }, - "time": "2022-02-04T12:51:07+00:00" - }, - { - "name": "doctrine/instantiator", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", - "shasum": "" - }, - "require": { - "php": "^8.1" - }, - "require-dev": { - "doctrine/coding-standard": "^11", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.9.4", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5.27", - "vimeo/psalm": "^5.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2022-12-30T00:23:10+00:00" + "time": "2023-01-05T11:28:13+00:00" }, { "name": "laminas/laminas-coding-standard", - "version": "2.4.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-coding-standard.git", - "reference": "eb076dd86aa93dd424856b150c9b6f76c1fdfabc" + "reference": "ac809f5b27f0b22d0c1ec0cbc78cb67f92bfebcb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/eb076dd86aa93dd424856b150c9b6f76c1fdfabc", - "reference": "eb076dd86aa93dd424856b150c9b6f76c1fdfabc", + "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/ac809f5b27f0b22d0c1ec0cbc78cb67f92bfebcb", + "reference": "ac809f5b27f0b22d0c1ec0cbc78cb67f92bfebcb", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", "php": "^7.4 || ^8.0", - "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.6", - "webimpress/coding-standard": "^1.2" - }, - "conflict": { - "phpstan/phpdoc-parser": ">=1.6.0" + "slevomat/coding-standard": "^8.15.0", + "squizlabs/php_codesniffer": "^3.10", + "webimpress/coding-standard": "^1.3" }, "type": "phpcodesniffer-standard", "autoload": { @@ -981,7 +911,7 @@ "type": "community_bridge" } ], - "time": "2022-08-24T17:45:47+00:00" + "time": "2024-10-16T09:23:09+00:00" }, { "name": "myclabs/deep-copy", @@ -1163,25 +1093,28 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.5.1", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "981cc368a216c988e862a75e526b6076987d1b50" + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/981cc368a216c988e862a75e526b6076987d1b50", - "reference": "981cc368a216c988e862a75e526b6076987d1b50", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" @@ -1201,22 +1134,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.5.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" }, - "time": "2022-05-05T11:32:40+00:00" + "time": "2024-10-13T11:25:22+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.32", + "version": "10.1.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" + "reference": "7e308268858ed6baedc8704a304727d20bc07c77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", - "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77", + "reference": "7e308268858ed6baedc8704a304727d20bc07c77", "shasum": "" }, "require": { @@ -1224,18 +1157,18 @@ "ext-libxml": "*", "ext-xmlwriter": "*", "nikic/php-parser": "^4.19.1 || ^5.1.0", - "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.6", - "phpunit/php-text-template": "^2.0.4", - "sebastian/code-unit-reverse-lookup": "^2.0.3", - "sebastian/complexity": "^2.0.3", - "sebastian/environment": "^5.1.5", - "sebastian/lines-of-code": "^1.0.4", - "sebastian/version": "^3.0.2", + "php": ">=8.1", + "phpunit/php-file-iterator": "^4.1.0", + "phpunit/php-text-template": "^3.0.1", + "sebastian/code-unit-reverse-lookup": "^3.0.0", + "sebastian/complexity": "^3.2.0", + "sebastian/environment": "^6.1.0", + "sebastian/lines-of-code": "^2.0.2", + "sebastian/version": "^4.0.1", "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.6" + "phpunit/phpunit": "^10.1" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -1244,7 +1177,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "9.2.x-dev" + "dev-main": "10.1.x-dev" } }, "autoload": { @@ -1273,7 +1206,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.16" }, "funding": [ { @@ -1281,32 +1214,32 @@ "type": "github" } ], - "time": "2024-08-22T04:23:01+00:00" + "time": "2024-08-22T04:31:57+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.6", + "version": "4.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1333,7 +1266,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" }, "funding": [ { @@ -1341,28 +1275,28 @@ "type": "github" } ], - "time": "2021-12-02T12:48:52+00:00" + "time": "2023-08-31T06:24:48+00:00" }, { "name": "phpunit/php-invoker", - "version": "3.1.1", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { "ext-pcntl": "*", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "suggest": { "ext-pcntl": "*" @@ -1370,7 +1304,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1396,7 +1330,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" }, "funding": [ { @@ -1404,32 +1338,32 @@ "type": "github" } ], - "time": "2020-09-28T05:58:55+00:00" + "time": "2023-02-03T06:56:09+00:00" }, { "name": "phpunit/php-text-template", - "version": "2.0.4", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1455,7 +1389,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" }, "funding": [ { @@ -1463,32 +1398,32 @@ "type": "github" } ], - "time": "2020-10-26T05:33:50+00:00" + "time": "2023-08-31T14:07:24+00:00" }, { "name": "phpunit/php-timer", - "version": "5.0.3", + "version": "6.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1514,7 +1449,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" }, "funding": [ { @@ -1522,24 +1457,23 @@ "type": "github" } ], - "time": "2020-10-26T13:16:10+00:00" + "time": "2023-02-03T06:57:52+00:00" }, { "name": "phpunit/phpunit", - "version": "9.6.21", + "version": "10.5.38", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa" + "reference": "a86773b9e887a67bc53efa9da9ad6e3f2498c132" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", - "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a86773b9e887a67bc53efa9da9ad6e3f2498c132", + "reference": "a86773b9e887a67bc53efa9da9ad6e3f2498c132", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -1549,27 +1483,26 @@ "myclabs/deep-copy": "^1.12.0", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", - "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.32", - "phpunit/php-file-iterator": "^3.0.6", - "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.4", - "phpunit/php-timer": "^5.0.3", - "sebastian/cli-parser": "^1.0.2", - "sebastian/code-unit": "^1.0.8", - "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.6", - "sebastian/environment": "^5.1.5", - "sebastian/exporter": "^4.0.6", - "sebastian/global-state": "^5.0.7", - "sebastian/object-enumerator": "^4.0.4", - "sebastian/resource-operations": "^3.0.4", - "sebastian/type": "^3.2.1", - "sebastian/version": "^3.0.2" + "php": ">=8.1", + "phpunit/php-code-coverage": "^10.1.16", + "phpunit/php-file-iterator": "^4.1.0", + "phpunit/php-invoker": "^4.0.0", + "phpunit/php-text-template": "^3.0.1", + "phpunit/php-timer": "^6.0.0", + "sebastian/cli-parser": "^2.0.1", + "sebastian/code-unit": "^2.0.0", + "sebastian/comparator": "^5.0.3", + "sebastian/diff": "^5.1.1", + "sebastian/environment": "^6.1.0", + "sebastian/exporter": "^5.1.2", + "sebastian/global-state": "^6.0.2", + "sebastian/object-enumerator": "^5.0.0", + "sebastian/recursion-context": "^5.0.0", + "sebastian/type": "^4.0.0", + "sebastian/version": "^4.0.1" }, "suggest": { - "ext-soap": "To be able to generate mocks based on WSDL files", - "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + "ext-soap": "To be able to generate mocks based on WSDL files" }, "bin": [ "phpunit" @@ -1577,7 +1510,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.6-dev" + "dev-main": "10.5-dev" } }, "autoload": { @@ -1609,7 +1542,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.38" }, "funding": [ { @@ -1625,32 +1558,32 @@ "type": "tidelift" } ], - "time": "2024-09-19T10:50:18+00:00" + "time": "2024-10-28T13:06:21+00:00" }, { "name": "sebastian/cli-parser", - "version": "1.0.2", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", - "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "2.0-dev" } }, "autoload": { @@ -1673,7 +1606,8 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" + "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.1" }, "funding": [ { @@ -1681,32 +1615,32 @@ "type": "github" } ], - "time": "2024-03-02T06:27:43+00:00" + "time": "2024-03-02T07:12:49+00:00" }, { "name": "sebastian/code-unit", - "version": "1.0.8", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "2.0-dev" } }, "autoload": { @@ -1729,7 +1663,7 @@ "homepage": "https://github.com/sebastianbergmann/code-unit", "support": { "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" }, "funding": [ { @@ -1737,32 +1671,32 @@ "type": "github" } ], - "time": "2020-10-26T13:08:54+00:00" + "time": "2023-02-03T06:58:43+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "2.0.3", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1784,7 +1718,7 @@ "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "support": { "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" }, "funding": [ { @@ -1792,34 +1726,36 @@ "type": "github" } ], - "time": "2020-09-28T05:30:19+00:00" + "time": "2023-02-03T06:59:15+00:00" }, { "name": "sebastian/comparator", - "version": "4.0.8", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + "reference": "a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e", + "reference": "a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/diff": "^4.0", - "sebastian/exporter": "^4.0" + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/diff": "^5.0", + "sebastian/exporter": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -1858,7 +1794,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.3" }, "funding": [ { @@ -1866,33 +1803,33 @@ "type": "github" } ], - "time": "2022-09-14T12:41:17+00:00" + "time": "2024-10-18T14:56:07+00:00" }, { "name": "sebastian/complexity", - "version": "2.0.3", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" + "reference": "68ff824baeae169ec9f2137158ee529584553799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", - "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", "shasum": "" }, "require": { "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.2-dev" } }, "autoload": { @@ -1915,7 +1852,8 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" }, "funding": [ { @@ -1923,33 +1861,33 @@ "type": "github" } ], - "time": "2023-12-22T06:19:30+00:00" + "time": "2023-12-21T08:37:17+00:00" }, { "name": "sebastian/diff", - "version": "4.0.6", + "version": "5.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", - "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e", + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3", - "symfony/process": "^4.2 || ^5" + "phpunit/phpunit": "^10.0", + "symfony/process": "^6.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -1981,7 +1919,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1" }, "funding": [ { @@ -1989,27 +1928,27 @@ "type": "github" } ], - "time": "2024-03-02T06:30:58+00:00" + "time": "2024-03-02T07:15:17+00:00" }, { "name": "sebastian/environment", - "version": "5.1.5", + "version": "6.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + "reference": "8074dbcd93529b357029f5cc5058fd3e43666984" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", - "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984", + "reference": "8074dbcd93529b357029f5cc5058fd3e43666984", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "suggest": { "ext-posix": "*" @@ -2017,7 +1956,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.1-dev" + "dev-main": "6.1-dev" } }, "autoload": { @@ -2036,7 +1975,7 @@ } ], "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", + "homepage": "https://github.com/sebastianbergmann/environment", "keywords": [ "Xdebug", "environment", @@ -2044,7 +1983,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/6.1.0" }, "funding": [ { @@ -2052,34 +1992,34 @@ "type": "github" } ], - "time": "2023-02-03T06:03:51+00:00" + "time": "2024-03-23T08:47:14+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.6", + "version": "5.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" + "reference": "955288482d97c19a372d3f31006ab3f37da47adf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", - "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/955288482d97c19a372d3f31006ab3f37da47adf", + "reference": "955288482d97c19a372d3f31006ab3f37da47adf", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/recursion-context": "^4.0" + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/recursion-context": "^5.0" }, "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -2121,7 +2061,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.2" }, "funding": [ { @@ -2129,38 +2070,35 @@ "type": "github" } ], - "time": "2024-03-02T06:33:00+00:00" + "time": "2024-03-02T07:17:12+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.7", + "version": "6.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" + "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", - "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-uopz": "*" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -2179,13 +2117,14 @@ } ], "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", + "homepage": "https://www.github.com/sebastianbergmann/global-state", "keywords": [ "global state" ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.2" }, "funding": [ { @@ -2193,33 +2132,33 @@ "type": "github" } ], - "time": "2024-03-02T06:35:11+00:00" + "time": "2024-03-02T07:19:19+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.4", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", - "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", "shasum": "" }, "require": { "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "2.0-dev" } }, "autoload": { @@ -2242,7 +2181,8 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" }, "funding": [ { @@ -2250,34 +2190,34 @@ "type": "github" } ], - "time": "2023-12-22T06:20:34+00:00" + "time": "2023-12-21T08:38:20+00:00" }, { "name": "sebastian/object-enumerator", - "version": "4.0.4", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -2299,7 +2239,7 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" }, "funding": [ { @@ -2307,32 +2247,32 @@ "type": "github" } ], - "time": "2020-10-26T13:12:34+00:00" + "time": "2023-02-03T07:08:32+00:00" }, { "name": "sebastian/object-reflector", - "version": "2.0.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -2354,7 +2294,7 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" }, "funding": [ { @@ -2362,32 +2302,32 @@ "type": "github" } ], - "time": "2020-10-26T13:14:26+00:00" + "time": "2023-02-03T07:06:18+00:00" }, { "name": "sebastian/recursion-context", - "version": "4.0.5", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" + "reference": "05909fb5bc7df4c52992396d0116aed689f93712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", - "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", + "reference": "05909fb5bc7df4c52992396d0116aed689f93712", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -2417,61 +2357,7 @@ "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-02-03T06:07:39+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "3.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", - "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" }, "funding": [ { @@ -2479,32 +2365,32 @@ "type": "github" } ], - "time": "2024-03-14T16:00:52+00:00" + "time": "2023-02-03T07:05:40+00:00" }, { "name": "sebastian/type", - "version": "3.2.1", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", - "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -2527,7 +2413,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" }, "funding": [ { @@ -2535,29 +2421,29 @@ "type": "github" } ], - "time": "2023-02-03T06:13:03+00:00" + "time": "2023-02-03T07:10:45+00:00" }, { "name": "sebastian/version", - "version": "3.0.2", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c6c1022351a901512170118436c764e473f6de8c" + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", - "reference": "c6c1022351a901512170118436c764e473f6de8c", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -2580,7 +2466,7 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" }, "funding": [ { @@ -2588,46 +2474,46 @@ "type": "github" } ], - "time": "2020-09-28T06:39:44+00:00" + "time": "2023-02-07T11:34:05+00:00" }, { "name": "slevomat/coding-standard", - "version": "7.2.1", + "version": "8.15.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90" + "reference": "7d1d957421618a3803b593ec31ace470177d7817" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7d1d957421618a3803b593ec31ace470177d7817", + "reference": "7d1d957421618a3803b593ec31ace470177d7817", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.5.1", - "squizlabs/php_codesniffer": "^3.6.2" + "phpstan/phpdoc-parser": "^1.23.1", + "squizlabs/php_codesniffer": "^3.9.0" }, "require-dev": { - "phing/phing": "2.17.3", + "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.4.10|1.7.1", - "phpstan/phpstan-deprecation-rules": "1.0.0", - "phpstan/phpstan-phpunit": "1.0.0|1.1.1", - "phpstan/phpstan-strict-rules": "1.2.3", - "phpunit/phpunit": "7.5.20|8.5.21|9.5.20" + "phpstan/phpstan": "1.10.60", + "phpstan/phpstan-deprecation-rules": "1.1.4", + "phpstan/phpstan-phpunit": "1.3.16", + "phpstan/phpstan-strict-rules": "1.5.2", + "phpunit/phpunit": "8.5.21|9.6.8|10.5.11" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "7.x-dev" + "dev-master": "8.x-dev" } }, "autoload": { "psr-4": { - "SlevomatCodingStandard\\": "SlevomatCodingStandard" + "SlevomatCodingStandard\\": "SlevomatCodingStandard/" } }, "notification-url": "https://packagist.org/downloads/", @@ -2635,9 +2521,13 @@ "MIT" ], "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "keywords": [ + "dev", + "phpcs" + ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/7.2.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.15.0" }, "funding": [ { @@ -2649,7 +2539,7 @@ "type": "tidelift" } ], - "time": "2022-05-25T10:58:12+00:00" + "time": "2024-03-09T15:20:58+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -2839,7 +2729,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 9161a46b..527d930e 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -16,6 +16,7 @@ src test */_files/* + test/PhpEnvironment/Assets/* @@ -23,4 +24,7 @@ src/ + + src/PhpEnvironment/Response.php + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5bd7b56f..5632bce8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,17 @@ - - - - ./src - - + ./test/ @@ -39,4 +46,9 @@ + + + ./src + + diff --git a/src/Client.php b/src/Client.php index 2d144102..e5a33529 100644 --- a/src/Client.php +++ b/src/Client.php @@ -488,7 +488,6 @@ public function setRawBody($body) /** * Set the POST parameters * - * @param array $post * @return $this */ public function setParameterPost(array $post) @@ -500,7 +499,6 @@ public function setParameterPost(array $post) /** * Set the GET parameters * - * @param array $query * @return $this */ public function setParameterGet(array $query) diff --git a/src/Client/Adapter/Proxy.php b/src/Client/Adapter/Proxy.php index 313f9dba..24507962 100644 --- a/src/Client/Adapter/Proxy.php +++ b/src/Client/Adapter/Proxy.php @@ -234,7 +234,6 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '' * @param string $host * @param int $port * @param string $httpVer - * @param array $headers * @throws AdapterException\RuntimeException */ protected function connectHandshake($host, $port = 443, $httpVer = '1.1', array &$headers = []) diff --git a/src/Header/Accept.php b/src/Header/Accept.php index cb1a494f..d7dac3b1 100644 --- a/src/Header/Accept.php +++ b/src/Header/Accept.php @@ -43,7 +43,6 @@ public function toString() * * @param string $type * @param int|float $priority - * @param array $params * @return $this */ public function addMediaType($type, $priority = 1, array $params = []) diff --git a/src/Header/ContentTransferEncoding.php b/src/Header/ContentTransferEncoding.php index d4a9453c..bc273903 100644 --- a/src/Header/ContentTransferEncoding.php +++ b/src/Header/ContentTransferEncoding.php @@ -6,7 +6,7 @@ use function strtolower; /** - * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 @todo find section + * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 \@todo find section * * @throws Exception\InvalidArgumentException */ diff --git a/src/Header/ContentType.php b/src/Header/ContentType.php index f6210afa..58c634ae 100644 --- a/src/Header/ContentType.php +++ b/src/Header/ContentType.php @@ -189,7 +189,6 @@ public function getMediaType() /** * Set additional content-type parameters * - * @param array $parameters * @return $this */ public function setParameters(array $parameters) diff --git a/src/Header/SetCookie.php b/src/Header/SetCookie.php index c615a488..0ca04a95 100644 --- a/src/Header/SetCookie.php +++ b/src/Header/SetCookie.php @@ -775,7 +775,6 @@ public function toString() } /** - * @param array $headers * @return string * @throws Exception\RuntimeException */ diff --git a/src/PhpEnvironment/RemoteAddress.php b/src/PhpEnvironment/RemoteAddress.php index ae4948b9..25fff35b 100644 --- a/src/PhpEnvironment/RemoteAddress.php +++ b/src/PhpEnvironment/RemoteAddress.php @@ -70,7 +70,6 @@ public function getUseProxy() /** * Set list of trusted proxy addresses * - * @param array $trustedProxies * @return $this */ public function setTrustedProxies(array $trustedProxies) diff --git a/src/PhpEnvironment/Response.php b/src/PhpEnvironment/Response.php index 16ebe90b..bdd5fcf6 100644 --- a/src/PhpEnvironment/Response.php +++ b/src/PhpEnvironment/Response.php @@ -8,7 +8,6 @@ use function call_user_func; use function header; -use function headers_sent; /** * HTTP Response for current PHP environment diff --git a/test/Client/Adapter/CurlTest.php b/test/Client/Adapter/CurlTest.php index 07b81c66..fcddd203 100644 --- a/test/Client/Adapter/CurlTest.php +++ b/test/Client/Adapter/CurlTest.php @@ -6,6 +6,7 @@ use Laminas\Http\Client\Adapter\Curl; use Laminas\Uri\Uri; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use function curl_getinfo; @@ -16,8 +17,7 @@ final class CurlTest extends TestCase { - /** @var Curl */ - private $adapter; + private Curl $adapter; protected function setUp(): void { @@ -28,7 +28,7 @@ protected function setUp(): void /** * @return iterable */ - public function floatHttpVersions(): iterable + public static function floatHttpVersions(): iterable { yield 'HTTP 1.0' => [CURL_HTTP_VERSION_1_0, 1.0]; yield 'HTTP 1.1' => [CURL_HTTP_VERSION_1_1, 1.1]; @@ -37,7 +37,7 @@ public function floatHttpVersions(): iterable /** * @return iterable */ - public function httpVersions(): iterable + public static function httpVersions(): iterable { yield 'HTTP 1.0' => [CURL_HTTP_VERSION_1_0, '1.0']; yield 'HTTP 1.1' => [CURL_HTTP_VERSION_1_1, '1.1']; @@ -46,9 +46,8 @@ public function httpVersions(): iterable /** * NOTE: This test is only needed for BC compatibility. The {@see \Laminas\Http\Client\Adapter\AdapterInterface} * has a default for "string" but "float" was used in {@see Curl::write()} due to the lack of strict types. - * - * @dataProvider floatHttpVersions */ + #[DataProvider('floatHttpVersions')] public function testWriteCanHandleFloatHttpVersion(int $expectedCurlOption, float $version): void { $this->adapter->connect('example.org'); @@ -58,9 +57,7 @@ public function testWriteCanHandleFloatHttpVersion(int $expectedCurlOption, floa self::assertEquals($expectedCurlOption, curl_getinfo($handle, CURLINFO_HTTP_VERSION)); } - /** - * @dataProvider httpVersions - */ + #[DataProvider('httpVersions')] public function testWriteCanHandleStringHttpVersion(int $expectedCurlOption, string $version): void { $this->adapter->connect('example.org'); diff --git a/test/Client/CommonHttpTests.php b/test/Client/CommonHttpTests.php index 1074e9aa..977a940b 100644 --- a/test/Client/CommonHttpTests.php +++ b/test/Client/CommonHttpTests.php @@ -11,6 +11,8 @@ use Laminas\Http\Request; use Laminas\Http\Response\Stream; use Laminas\Stdlib\Parameters; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use stdClass; @@ -58,10 +60,9 @@ * * You can also set the proper constant in your test configuration file to * point to the right place. - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] abstract class CommonHttpTests extends TestCase { /** @@ -108,7 +109,7 @@ protected function setUp(): void $this->baseuri .= '/'; } - $name = $this->getName(); + $name = $this->nameWithDataSet(); if (($pos = strpos($name, ' ')) !== false) { $name = substr($name, 0, $pos); } @@ -139,7 +140,7 @@ protected function tearDown(): void // Simple request tests /** @psalm-return array */ - public function methodProvider(): array + public static function methodProvider(): array { return [ [Request::METHOD_GET], @@ -153,11 +154,9 @@ public function methodProvider(): array /** * Test simple requests - * - * @dataProvider methodProvider - * @param string $method */ - public function testSimpleRequests($method) + #[DataProvider('methodProvider')] + public function testSimpleRequests(string $method): void { $this->client->setMethod($method); $res = $this->client->send(); @@ -167,7 +166,7 @@ public function testSimpleRequests($method) /** * Test we can get the last request as string */ - public function testGetLastRawRequest() + public function testGetLastRawRequest(): void { $this->client->setUri($this->baseuri . 'testHeaders.php'); $this->client->setParameterGet(['someinput' => 'somevalue']); @@ -191,14 +190,11 @@ public function testGetLastRawRequest() /** * GET and POST parameters tests */ - /** * Test we can properly send GET parameters - * - * @dataProvider parameterArrayProvider - * @param array $params */ - public function testGetData(array $params) + #[DataProvider('parameterArrayProvider')] + public function testGetData(array $params): void { $this->client->setUri($this->client->getUri() . '?name=Arthur'); $this->client->setParameterGet($params); @@ -209,11 +205,9 @@ public function testGetData(array $params) /** * Test we can properly send POST parameters with * application/x-www-form-urlencoded content type - * - * @dataProvider parameterArrayProvider - * @param array $params */ - public function testPostDataUrlEncoded(array $params) + #[DataProvider('parameterArrayProvider')] + public function testPostDataUrlEncoded(array $params): void { $this->client->setUri($this->baseuri . 'testPostData.php'); $this->client->setEncType(HTTPClient::ENC_URLENCODED); @@ -229,11 +223,9 @@ public function testPostDataUrlEncoded(array $params) /** * Test we can properly send PATCH parameters with * application/x-www-form-urlencoded content type - * - * @dataProvider parameterArrayProvider - * @param array $params */ - public function testPatchData(array $params) + #[DataProvider('parameterArrayProvider')] + public function testPatchData(array $params): void { $client = $this->client; $client->setUri($this->baseuri . 'testPatchData.php'); @@ -250,11 +242,9 @@ public function testPatchData(array $params) /** * Test we can properly send DELETE parameters with * application/x-www-form-urlencoded content type - * - * @dataProvider parameterArrayProvider - * @param array $params */ - public function testDeleteData(array $params) + #[DataProvider('parameterArrayProvider')] + public function testDeleteData(array $params): void { $client = $this->client; $client->setUri($this->baseuri . 'testDeleteData.php'); @@ -271,11 +261,9 @@ public function testDeleteData(array $params) /** * Test we can properly send OPTIONS parameters with * application/x-www-form-urlencoded content type - * - * @dataProvider parameterArrayProvider - * @param array $params */ - public function testOptionsData(array $params) + #[DataProvider('parameterArrayProvider')] + public function testOptionsData(array $params): void { $client = $this->client; $client->setUri($this->baseuri . 'testOptionsData.php'); @@ -292,11 +280,9 @@ public function testOptionsData(array $params) /** * Test we can properly send POST parameters with * multipart/form-data content type - * - * @dataProvider parameterArrayProvider - * @param array $params */ - public function testPostDataMultipart(array $params) + #[DataProvider('parameterArrayProvider')] + public function testPostDataMultipart(array $params): void { $this->client->setUri($this->baseuri . 'testPostData.php'); $this->client->setEncType(HTTPClient::ENC_FORMDATA); @@ -309,7 +295,7 @@ public function testPostDataMultipart(array $params) /** * Test using raw HTTP POST data */ - public function testRawPostData() + public function testRawPostData(): void { $data = 'Chuck Norris never wet his bed as a child. The bed wet itself out of fear.'; @@ -323,7 +309,7 @@ public function testRawPostData() /** * Make sure we can reset the parameters between consecutive requests */ - public function testResetParameters() + public function testResetParameters(): void { $params = [ 'quest' => 'To seek the holy grail', @@ -365,7 +351,7 @@ public function testResetParameters() /** * Test parameters get reset when we unset them */ - public function testParameterUnset() + public function testParameterUnset(): void { $this->client->setUri($this->baseuri . 'testResetParameters.php'); @@ -406,7 +392,7 @@ public function testParameterUnset() /** * Make sure we can set a single header */ - public function testHeadersSingle() + public function testHeadersSingle(): void { $this->client->setUri($this->baseuri . 'testHeaders.php'); @@ -435,7 +421,7 @@ public function testHeadersSingle() /** * Test we can set an array of headers */ - public function testHeadersArray() + public function testHeadersArray(): void { $this->client->setUri($this->baseuri . 'testHeaders.php'); @@ -468,7 +454,7 @@ public function testHeadersArray() /** * Test we can set a set of values for one header */ - public function testMultipleHeader() + public function testMultipleHeader(): void { $this->client->setUri($this->baseuri . 'testHeaders.php'); $headers = [ @@ -510,7 +496,7 @@ public function testMultipleHeader() /** * Test the client properly redirects in default mode */ - public function testRedirectDefault() + public function testRedirectDefault(): void { $this->client->setUri($this->baseuri . 'testRedirections.php'); @@ -531,10 +517,9 @@ public function testRedirectDefault() /** * @link https://getlaminas.org/issues/browse/Laminas-122 - * - * @group Laminas-4136 */ - public function testRedirectPersistsCookies() + #[Group('Laminas-4136')] + public function testRedirectPersistsCookies(): void { $this->client->setUri($this->baseuri . 'testRedirections.php'); @@ -567,7 +552,7 @@ public function testRedirectPersistsCookies() /** * Make sure the client properly redirects in strict mode */ - public function testRedirectStrict() + public function testRedirectStrict(): void { $this->client->setUri($this->baseuri . 'testRedirections.php'); @@ -592,7 +577,7 @@ public function testRedirectStrict() /** * Make sure redirections stop when limit is exceeded */ - public function testMaxRedirectsExceeded() + public function testMaxRedirectsExceeded(): void { $this->client->setUri($this->baseuri . 'testRedirections.php'); @@ -635,7 +620,7 @@ public function testMaxRedirectsExceeded() /** * Test we can properly redirect to an absolute path (not full URI) */ - public function testAbsolutePathRedirect() + public function testAbsolutePathRedirect(): void { $this->client->setUri($this->baseuri . 'testRelativeRedirections.php'); $this->client->setParameterGet(['redirect' => 'abpath']); @@ -657,7 +642,7 @@ public function testAbsolutePathRedirect() /** * Test we can properly redirect to a relative path */ - public function testRelativePathRedirect() + public function testRelativePathRedirect(): void { $this->client->setUri($this->baseuri . 'testRelativeRedirections.php'); $this->client->setParameterGet(['redirect' => 'relpath']); @@ -684,7 +669,7 @@ public function testRelativePathRedirect() /** * Test we can properly use Basic HTTP authentication */ - public function testHttpAuthBasic() + public function testHttpAuthBasic(): void { $this->client->setUri($this->baseuri . 'testHttpAuth.php'); $this->client->setParameterGet([ @@ -708,7 +693,7 @@ public function testHttpAuthBasic() * Test that we can properly use Basic HTTP authentication by specifying username and password * in the URI */ - public function testHttpAuthBasicWithCredentialsInUri() + public function testHttpAuthBasicWithCredentialsInUri(): void { $uri = str_replace('http://', 'http://%s:%s@', $this->baseuri) . 'testHttpAuth.php'; @@ -738,7 +723,7 @@ public function testHttpAuthBasicWithCredentialsInUri() /** * Test we can set string cookies with no jar */ - public function testCookiesStringNoJar() + public function testCookiesStringNoJar(): void { $this->client->setUri($this->baseuri . 'testCookies.php'); @@ -761,7 +746,7 @@ public function testCookiesStringNoJar() /** * Make sure we can set an array of object cookies */ - public function testSetCookieObjectArray() + public function testSetCookieObjectArray(): void { $this->client->setUri($this->baseuri . 'testCookies.php'); $refuri = $this->client->getUri(); @@ -785,7 +770,7 @@ public function testSetCookieObjectArray() /** * Make sure we can set an array of string cookies */ - public function testSetCookieStringArray() + public function testSetCookieStringArray(): void { $this->client->setUri($this->baseuri . 'testCookies.php'); @@ -812,7 +797,7 @@ public function testSetCookieStringArray() /** * Test we can upload raw data as a file */ - public function testUploadRawData() + public function testUploadRawData(): void { if (! ini_get('file_uploads')) { $this->markTestSkipped('File uploads disabled.'); @@ -832,7 +817,7 @@ public function testUploadRawData() /** * Test we can upload an existing file */ - public function testUploadLocalFile() + public function testUploadLocalFile(): void { if (! ini_get('file_uploads')) { $this->markTestSkipped('File uploads disabled.'); @@ -849,7 +834,7 @@ public function testUploadLocalFile() $this->assertEquals($body, $res->getBody(), 'Response body does not include expected upload parameters'); } - public function testUploadLocalDetectMime() + public function testUploadLocalDetectMime(): void { if (! ini_get('file_uploads')) { $this->markTestSkipped('File uploads disabled.'); @@ -889,7 +874,7 @@ public function testUploadLocalDetectMime() ); } - public function testUploadNameWithSpecialChars() + public function testUploadNameWithSpecialChars(): void { if (! ini_get('file_uploads')) { $this->markTestSkipped('File uploads disabled.'); @@ -906,7 +891,7 @@ public function testUploadNameWithSpecialChars() $this->assertEquals($body, $res->getBody(), 'Response body does not include expected upload parameters'); } - public function testStaticLargeFileDownload() + public function testStaticLargeFileDownload(): void { $this->client->setUri($this->baseuri . 'staticFile.jpg'); @@ -922,7 +907,7 @@ public function testStaticLargeFileDownload() * * @link https://getlaminas.org/issues/browse/Laminas-5744 */ - public function testMultipleFilesWithSameFormNameLaminas5744() + public function testMultipleFilesWithSameFormNameLaminas5744(): void { if (! ini_get('file_uploads')) { $this->markTestSkipped('File uploads disabled.'); @@ -953,10 +938,9 @@ public function testMultipleFilesWithSameFormNameLaminas5744() /** * Test that lines that might be evaluated as boolean false do not break * the reading prematurely. - * - * @group Laminas-4238 */ - public function testLaminas4238FalseLinesInResponse() + #[Group('Laminas-4238')] + public function testLaminas4238FalseLinesInResponse(): void { $this->client->setUri($this->baseuri . 'Laminas4238-zerolineresponse.txt'); @@ -965,7 +949,7 @@ public function testLaminas4238FalseLinesInResponse() $this->assertEquals($expected, $got); } - public function testStreamResponse() + public function testStreamResponse(): void { if (! $this->client->getAdapter() instanceof Adapter\StreamInterface) { $this->markTestSkipped('Current adapter does not support streaming'); @@ -990,7 +974,7 @@ public function testStreamResponse() $this->assertEquals($expected, $fileRead, 'Downloaded file does not seem to match!'); } - public function testStreamResponseBody() + public function testStreamResponseBody(): void { $this->markTestSkipped('To check with the new Laminas implementation'); @@ -1012,7 +996,7 @@ public function testStreamResponseBody() $this->assertEquals($expected, $body, 'Downloaded stream does not seem to match!'); } - public function testStreamResponseNamed() + public function testStreamResponseNamed(): void { if (! $this->client->getAdapter() instanceof Adapter\StreamInterface) { $this->markTestSkipped('Current adapter does not support streaming'); @@ -1038,7 +1022,7 @@ public function testStreamResponseNamed() $this->assertEquals($expected, $fileRead, 'Downloaded file does not seem to match!'); } - public function testStreamRequest() + public function testStreamRequest(): void { if (! $this->client->getAdapter() instanceof Adapter\StreamInterface) { $this->markTestSkipped('Current adapter does not support streaming'); @@ -1058,7 +1042,7 @@ public function testStreamRequest() * * @link https://getlaminas.org/issues/browse/Laminas-9404 */ - public function testLaminas9404DoubleContentLengthHeader() + public function testLaminas9404DoubleContentLengthHeader(): void { $this->client->setUri($this->baseuri . 'Laminas9404-doubleContentLength.php'); $expect = filesize(__DIR__ . '/_files/Laminas9404-doubleContentLength.php'); @@ -1077,12 +1061,9 @@ public function testLaminas9404DoubleContentLengthHeader() $this->assertEquals($expect, strlen($response->getBody())); } - /** - * @group Laminas-78 - * @dataProvider parameterArrayProvider - * @param array $params - */ - public function testContentTypeAdditionlInfo(array $params) + #[DataProvider('parameterArrayProvider')] + #[Group('Laminas-78')] + public function testContentTypeAdditionlInfo(array $params): void { $contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; @@ -1102,11 +1083,9 @@ public function testContentTypeAdditionlInfo(array $params) ); } - /** - * @group 2774 - * @group 2745 - */ - public function testUsesProvidedArgSeparator() + #[Group('2774')] + #[Group('2745')] + public function testUsesProvidedArgSeparator(): void { $this->client->setArgSeparator(';'); $request = new Request(); @@ -1119,21 +1098,16 @@ public function testUsesProvidedArgSeparator() /** * Internal helper function to get the contents of test files - * - * @param string $file - * @return string */ - private function getTestFileContents($file) + private function getTestFileContents(string $file): string { return file_get_contents(__DIR__ . '/_files/' . $file); } /** * Data provider for complex, nesting parameter arrays - * - * @return array */ - public static function parameterArrayProvider() + public static function parameterArrayProvider(): array { return [ [ @@ -1169,15 +1143,12 @@ public static function parameterArrayProvider() /** * Data provider for invalid configuration containers - * - * @return array */ - public static function invalidConfigProvider() + public static function invalidConfigProvider(): array { return [ [false], ['foobar'], - ['foo' => 'bar'], [null], [new stdClass()], [55], @@ -1186,10 +1157,8 @@ public static function invalidConfigProvider() /** * Get an URI that does not accept HTTP connections. - * - * @return string */ - protected function getNotRespondingUri() + protected function getNotRespondingUri(): string { $notRespondingUri = getenv('TESTS_LAMINAS_HTTP_CLIENT_NOTRESPONDINGURI'); if (! $notRespondingUri) { @@ -1202,7 +1171,7 @@ protected function getNotRespondingUri() /** * Check connecttimeout/timeout: invalid URIs should timeout after 'connecttimeout' seconds. */ - public function testConnectTimeout1() + public function testConnectTimeout1(): void { $connectTimeout = 1; $executeTimeout = 5; @@ -1235,7 +1204,7 @@ public function testConnectTimeout1() /** * Check connecttimeout/timeout: valid but slow URIs should timeout after 'timeout' seconds. */ - public function testConnectTimeout2() + public function testConnectTimeout2(): void { $connectTimeout = 1; $executeTimeout = 2; diff --git a/test/Client/CurlTest.php b/test/Client/CurlTest.php index 0c5ac903..8327d65c 100644 --- a/test/Client/CurlTest.php +++ b/test/Client/CurlTest.php @@ -13,6 +13,8 @@ use Laminas\Http\Client\Adapter\Exception\RuntimeException; use Laminas\Http\Client\Adapter\Exception\TimeoutException; use Laminas\Stdlib\ErrorHandler; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use ValueError; use function base64_encode; @@ -52,10 +54,9 @@ * * You can also set the proper constand in your test configuration file to * point to the right place. - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] class CurlTest extends CommonHttpTests { /** @@ -82,7 +83,7 @@ protected function setUp(): void /** * Test that we can set a valid configuration array with some options */ - public function testConfigSetAsArray() + public function testConfigSetAsArray(): void { $config = [ 'timeout' => 500, @@ -102,7 +103,7 @@ public function testConfigSetAsArray() * * @link https://framework.zend.com/issues/browse/ZEND-5577 */ - public function testConfigSetAsTraversable() + public function testConfigSetAsTraversable(): void { $config = new ArrayObject([ 'timeout' => 400, @@ -119,7 +120,7 @@ public function testConfigSetAsTraversable() } /** @psalm-return array */ - public function provideValidTimeoutConfig(): array + public static function provideValidTimeoutConfig(): array { return [ 'integer' => [10], @@ -127,11 +128,8 @@ public function provideValidTimeoutConfig(): array ]; } - /** - * @dataProvider provideValidTimeoutConfig - * @param int|string $timeout - */ - public function testPassValidTimeout($timeout) + #[DataProvider('provideValidTimeoutConfig')] + public function testPassValidTimeout(int|string $timeout): void { $adapter = new Adapter\Curl(); $adapter->setOptions(['timeout' => $timeout]); @@ -139,7 +137,7 @@ public function testPassValidTimeout($timeout) $adapter->connect('getlaminas.org'); } - public function testThrowInvalidArgumentExceptionOnNonIntegerAndNonNumericStringTimeout() + public function testThrowInvalidArgumentExceptionOnNonIntegerAndNonNumericStringTimeout(): void { $adapter = new Adapter\Curl(); $adapter->setOptions(['timeout' => 'timeout']); @@ -152,11 +150,9 @@ public function testThrowInvalidArgumentExceptionOnNonIntegerAndNonNumericString /** * Check that an exception is thrown when trying to set invalid config - * - * @dataProvider invalidConfigProvider - * @param mixed $config */ - public function testSetConfigInvalidConfig($config) + #[DataProvider('invalidConfigProvider')] + public function testSetConfigInvalidConfig(mixed $config): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Array or Traversable object expected'); @@ -164,7 +160,7 @@ public function testSetConfigInvalidConfig($config) $this->adapter->setOptions($config); } - public function testSettingInvalidCurlOption() + public function testSettingInvalidCurlOption(): void { $config = [ 'adapter' => Curl::class, @@ -189,7 +185,7 @@ public function testSettingInvalidCurlOption() } } - public function testRedirectWithGetOnly() + public function testRedirectWithGetOnly(): void { $this->client->setUri($this->baseuri . 'testRedirections.php'); @@ -214,7 +210,7 @@ public function testRedirectWithGetOnly() * Set CURLOPT_FOLLOWLOCATION = false for this type of request and let the Laminas_Http_Client handle redirects * in his own loop. */ - public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout() + public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout(): void { $adapter = new Adapter\Curl(); $this->client->setAdapter($adapter); @@ -238,10 +234,9 @@ public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout( /** * @link https://getlaminas.org/issues/browse/Laminas-3758 - * - * @group Laminas-3758 */ - public function testPutFileContentWithHttpClient() + #[Group('Laminas-3758')] + public function testPutFileContentWithHttpClient(): void { // Method 1: Using the binary string of a file to PUT $this->client->setUri($this->baseuri . 'testRawPostData.php'); @@ -255,10 +250,9 @@ public function testPutFileContentWithHttpClient() /** * @link https://getlaminas.org/issues/browse/Laminas-3758 - * - * @group Laminas-3758 */ - public function testPutFileHandleWithHttpClient() + #[Group('Laminas-3758')] + public function testPutFileHandleWithHttpClient(): void { $this->client->setUri($this->baseuri . 'testRawPostData.php'); $putFileContents = file_get_contents(__DIR__ . '/_files/staticFile.jpg'); @@ -281,7 +275,7 @@ public function testPutFileHandleWithHttpClient() $this->assertEquals(gzcompress($putFileContents), gzcompress($this->client->getResponse()->getBody())); } - public function testWritingAndNotConnectedWithCurlHandleThrowsException() + public function testWritingAndNotConnectedWithCurlHandleThrowsException(): void { $adapter = new Adapter\Curl(); $this->expectException(RuntimeException::class); @@ -289,14 +283,14 @@ public function testWritingAndNotConnectedWithCurlHandleThrowsException() $adapter->write('GET', 'someUri'); } - public function testSetConfigIsNotArray() + public function testSetConfigIsNotArray(): void { $adapter = new Adapter\Curl(); $this->expectException(InvalidArgumentException::class); $adapter->setOptions('foo'); } - public function testSetCurlOptions() + public function testSetCurlOptions(): void { $adapter = new Adapter\Curl(); @@ -309,10 +303,8 @@ public function testSetCurlOptions() ); } - /** - * @group 4213 - */ - public function testSetOptionsMergesCurlOptions() + #[Group('4213')] + public function testSetOptionsMergesCurlOptions(): void { $adapter = new Adapter\Curl(); @@ -333,7 +325,7 @@ public function testSetOptionsMergesCurlOptions() ); } - public function testWorkWithProxyConfiguration() + public function testWorkWithProxyConfiguration(): void { $adapter = new Adapter\Curl(); $adapter->setOptions([ @@ -357,7 +349,7 @@ public function testWorkWithProxyConfiguration() ); } - public function testSslVerifyPeerCanSetOverOption() + public function testSslVerifyPeerCanSetOverOption(): void { $adapter = new Adapter\Curl(); $adapter->setOptions([ @@ -376,10 +368,8 @@ public function testSslVerifyPeerCanSetOverOption() ); } - /** - * @group Laminas-7040 - */ - public function testGetCurlHandle() + #[Group('Laminas-7040')] + public function testGetCurlHandle(): void { $adapter = new Adapter\Curl(); $adapter->setOptions(['timeout' => 2, 'maxredirects' => 1]); @@ -391,10 +381,8 @@ public function testGetCurlHandle() } } - /** - * @group Laminas-9857 - */ - public function testHeadRequest() + #[Group('Laminas-9857')] + public function testHeadRequest(): void { $this->client->setUri($this->baseuri . 'testRawPostData.php'); $adapter = new Adapter\Curl(); @@ -404,7 +392,7 @@ public function testHeadRequest() $this->assertEquals('', $this->client->getResponse()->getBody()); } - public function testHeadRequestWithContentLengthHeader() + public function testHeadRequestWithContentLengthHeader(): void { $this->client->setUri($this->baseuri . 'testHeadMethod.php'); $adapter = new Adapter\Curl(); @@ -414,7 +402,7 @@ public function testHeadRequestWithContentLengthHeader() $this->assertEquals('', $this->client->getResponse()->getBody()); } - public function testAuthorizeHeader() + public function testAuthorizeHeader(): void { // We just need someone to talk to $this->client->setUri($this->baseuri . 'testHttpAuth.php'); @@ -444,10 +432,8 @@ public function testAuthorizeHeader() ); } - /** - * @group 4555 - */ - public function testResponseDoesNotDoubleDecodeGzippedBody() + #[Group('4555')] + public function testResponseDoesNotDoubleDecodeGzippedBody(): void { $this->client->setUri($this->baseuri . 'testCurlGzipData.php'); $adapter = new Adapter\Curl(); @@ -462,7 +448,7 @@ public function testResponseDoesNotDoubleDecodeGzippedBody() $this->assertEquals('Success', $this->client->getResponse()->getBody()); } - public function testSetCurlOptPostFields() + public function testSetCurlOptPostFields(): void { $this->client->setUri($this->baseuri . 'testRawPostData.php'); $adapter = new Adapter\Curl(); @@ -481,10 +467,9 @@ public function testSetCurlOptPostFields() * @see https://github.com/zendframework/zend-http/pull/53 * * Note: The headers stored in Laminas7683-chunked.php are case insensitive - * - * @group Laminas-7683 */ - public function testNoCaseSensitiveHeaderName() + #[Group('Laminas-7683')] + public function testNoCaseSensitiveHeaderName(): void { $this->client->setUri($this->baseuri . 'Laminas7683-chunked.php'); @@ -504,7 +489,7 @@ public function testNoCaseSensitiveHeaderName() $this->assertFalse($headers->has('Content-Encoding')); } - public function testSslCaPathAndFileConfig() + public function testSslCaPathAndFileConfig(): void { $adapter = new Adapter\Curl(); $options = [ @@ -518,7 +503,7 @@ public function testSslCaPathAndFileConfig() $this->assertEquals($options['sslcafile'], $config['sslcafile']); } - public function testTimeout() + public function testTimeout(): void { $this->client ->setUri($this->baseuri . 'testTimeout.php') @@ -537,7 +522,7 @@ public function testTimeout() $this->assertNotNull($timeoutException); } - public function testTimeoutWithStream() + public function testTimeoutWithStream(): void { $this->client ->setOptions([ @@ -561,7 +546,7 @@ public function testTimeoutWithStream() /** * @see https://github.com/zendframework/zend-http/pull/184 */ - public function testMustRemoveProxyConnectionEstablishedLine() + public function testMustRemoveProxyConnectionEstablishedLine(): void { $proxy = getenv('TESTS_LAMINAS_HTTP_CLIENT_HTTP_PROXY'); if (! $proxy) { diff --git a/test/Client/ProxyAdapterTest.php b/test/Client/ProxyAdapterTest.php index e42a1dae..be62b3e0 100644 --- a/test/Client/ProxyAdapterTest.php +++ b/test/Client/ProxyAdapterTest.php @@ -8,6 +8,7 @@ use Laminas\Http\Client\Adapter\Proxy; use Laminas\Http\Client\Adapter\Socket; use Laminas\Http\Request; +use PHPUnit\Framework\Attributes\Group; use function array_keys; use function explode; @@ -25,17 +26,14 @@ * proxy server, which can access TESTS_LAMINAS_HTTP_CLIENT_BASEURI. * * See phpunit.xml.dist for more information. - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] class ProxyAdapterTest extends SocketTest { - /** @var string */ - protected $host; + protected string $host; - /** @var int */ - protected $port; + protected int $port; protected function setUp(): void { @@ -86,7 +84,7 @@ protected function setUp(): void /** * Test that when no proxy is set the adapter falls back to direct connection */ - public function testFallbackToSocket() + public function testFallbackToSocket(): void { $this->adapter->setOptions([ 'proxy_host' => null, @@ -105,14 +103,14 @@ public function testFallbackToSocket() ); } - public function testGetLastRequest() + public function testGetLastRequest(): void { // This test will never work for the proxy adapter (and shouldn't!) // because the proxy server modifies the request which is sent back in // the TRACE response } - public function testDefaultConfig() + public function testDefaultConfig(): void { $config = $this->adapter->getConfig(); $this->assertEquals(true, $config['sslverifypeer']); @@ -125,7 +123,7 @@ public function testDefaultConfig() * as issue is not present from command line using curl: * curl -IL https://getlaminas.org -x 127.0.0.1:8081 */ - public function testUsesProvidedArgSeparator() + public function testUsesProvidedArgSeparator(): void { $this->client->setOptions(['sslverifypeername' => false]); @@ -138,7 +136,7 @@ public function testUsesProvidedArgSeparator() * Response contains path, not the absolute URI, * also Connection: close header is in the different place. */ - public function testGetLastRawRequest() + public function testGetLastRawRequest(): void { $this->client->setUri($this->baseuri . 'testHeaders.php'); $this->client->setParameterGet(['someinput' => 'somevalue']); @@ -179,7 +177,7 @@ public function testGetLastRawRequest() /** * Test that the proxy keys normalised by the client are correctly converted to what the proxy adapter expects. */ - public function testProxyKeysCorrectlySetInProxyAdapter() + public function testProxyKeysCorrectlySetInProxyAdapter(): void { $adapterConfig = $this->adapter->getConfig(); $adapterHost = $adapterConfig['proxy_host']; @@ -189,7 +187,7 @@ public function testProxyKeysCorrectlySetInProxyAdapter() $this->assertSame($this->port, $adapterPort); } - public function testProxyHasAllSocketConfigs() + public function testProxyHasAllSocketConfigs(): void { $socket = new Socket(); $socketConfig = $socket->getConfig(); diff --git a/test/Client/SocketKeepaliveTest.php b/test/Client/SocketKeepaliveTest.php index 480110ee..9fcf8283 100644 --- a/test/Client/SocketKeepaliveTest.php +++ b/test/Client/SocketKeepaliveTest.php @@ -5,6 +5,7 @@ namespace LaminasTest\Http\Client; use Laminas\Http\Client\Adapter\Socket; +use PHPUnit\Framework\Attributes\Group; /** * This Testsuite includes all Laminas_Http_Client that require a working web @@ -18,10 +19,9 @@ * * You can also set the proper constand in your test configuration file to * point to the right place. - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] class SocketKeepaliveTest extends SocketTest { /** diff --git a/test/Client/SocketPersistentTest.php b/test/Client/SocketPersistentTest.php index 38ae9d89..7d6b5968 100644 --- a/test/Client/SocketPersistentTest.php +++ b/test/Client/SocketPersistentTest.php @@ -5,6 +5,7 @@ namespace LaminasTest\Http\Client; use Laminas\Http\Client\Adapter\Socket; +use PHPUnit\Framework\Attributes\Group; /** * This Testsuite includes all Laminas_Http_Client that require a working web @@ -18,10 +19,9 @@ * * You can also set the proper constand in your test configuration file to * point to the right place. - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] class SocketPersistentTest extends SocketTest { /** diff --git a/test/Client/SocketTest.php b/test/Client/SocketTest.php index a8470472..5bfb5ca8 100644 --- a/test/Client/SocketTest.php +++ b/test/Client/SocketTest.php @@ -10,6 +10,9 @@ use Laminas\Http\Client\Adapter\Exception\RuntimeException; use Laminas\Http\Client\Adapter\Socket; use Laminas\Uri\Uri; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use stdClass; use function fopen; @@ -31,10 +34,9 @@ * * You can also set the proper constant in your test configuration file to * point to the right place. - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] class SocketTest extends CommonHttpTests { /** @@ -49,13 +51,11 @@ class SocketTest extends CommonHttpTests /** * Off-line common adapter tests */ - /** * Test that we can set a valid configuration array with some options - * - * @group ZHC001 */ - public function testConfigSetAsArray() + #[Group('ZHC001')] + public function testConfigSetAsArray(): void { $config = [ 'timeout' => 500, @@ -70,7 +70,7 @@ public function testConfigSetAsArray() } } - public function testDefaultConfig() + public function testDefaultConfig(): void { $config = $this->adapter->getConfig(); $this->assertEquals(true, $config['sslverifypeer']); @@ -78,7 +78,7 @@ public function testDefaultConfig() $this->assertEquals(true, $config['sslverifypeername']); } - public function testConnectingViaSslEnforcesDefaultSslOptionsOnContext() + public function testConnectingViaSslEnforcesDefaultSslOptionsOnContext(): void { $config = ['timeout' => 30]; $this->adapter->setOptions($config); @@ -95,7 +95,7 @@ public function testConnectingViaSslEnforcesDefaultSslOptionsOnContext() $this->assertTrue($options['ssl']['verify_peer_name']); } - public function testConnectingViaSslWithCustomSslOptionsOnContext() + public function testConnectingViaSslWithCustomSslOptionsOnContext(): void { $config = [ 'timeout' => 30, @@ -122,7 +122,7 @@ public function testConnectingViaSslWithCustomSslOptionsOnContext() * The configuration is set to a legitimate certificate bundle file, * to exclude errors from being thrown from an invalid cafile context being set. */ - public function testConnectingViaSslUsesCertificateFileContext() + public function testConnectingViaSslUsesCertificateFileContext(): void { $config = [ 'timeout' => 30, @@ -145,7 +145,7 @@ public function testConnectingViaSslUsesCertificateFileContext() * * @link https://framework.zend.com/issues/browse/ZEND-5577 */ - public function testConfigSetAsTraversable() + public function testConfigSetAsTraversable(): void { $config = new ArrayObject([ 'timeout' => 400, @@ -163,11 +163,9 @@ public function testConfigSetAsTraversable() /** * Check that an exception is thrown when trying to set invalid config - * - * @dataProvider invalidConfigProvider - * @param mixed $config */ - public function testSetConfigInvalidConfig($config) + #[DataProvider('invalidConfigProvider')] + public function testSetConfigInvalidConfig(mixed $config): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Array or Laminas\Config object expected'); @@ -176,7 +174,7 @@ public function testSetConfigInvalidConfig($config) } /** @psalm-return array */ - public function provideValidTimeoutConfig(): array + public static function provideValidTimeoutConfig(): array { return [ 'integer' => [10], @@ -184,11 +182,8 @@ public function provideValidTimeoutConfig(): array ]; } - /** - * @dataProvider provideValidTimeoutConfig - * @param int|string $timeout - */ - public function testPassValidTimeout($timeout) + #[DataProvider('provideValidTimeoutConfig')] + public function testPassValidTimeout(int|string $timeout): void { $adapter = new Adapter\Socket(); $adapter->setOptions(['timeout' => $timeout]); @@ -196,7 +191,7 @@ public function testPassValidTimeout($timeout) $adapter->connect('getlaminas.org'); } - public function testThrowInvalidArgumentExceptionOnNonIntegerAndNonNumericStringTimeout() + public function testThrowInvalidArgumentExceptionOnNonIntegerAndNonNumericStringTimeout(): void { $adapter = new Adapter\Socket(); $adapter->setOptions(['timeout' => 'timeout']); @@ -210,7 +205,7 @@ public function testThrowInvalidArgumentExceptionOnNonIntegerAndNonNumericString // Stream context related tests // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testGetNewStreamContext() + public function testGetNewStreamContext(): void { $adapterClass = $this->config['adapter']; $adapter = new $adapterClass(); @@ -219,7 +214,7 @@ public function testGetNewStreamContext() $this->assertEquals('stream-context', get_resource_type($context)); } - public function testSetNewStreamContextResource() + public function testSetNewStreamContextResource(): void { $adapterClass = $this->config['adapter']; $adapter = new $adapterClass(); @@ -230,7 +225,7 @@ public function testSetNewStreamContextResource() $this->assertEquals($context, $adapter->getStreamContext()); } - public function testSetNewStreamContextOptions() + public function testSetNewStreamContextOptions(): void { $adapterClass = $this->config['adapter']; $adapter = new $adapterClass(); @@ -253,11 +248,9 @@ public function testSetNewStreamContextOptions() /** * Test that setting invalid options / context causes an exception - * - * @dataProvider invalidContextProvider - * @param mixed $invalid */ - public function testSetInvalidContextOptions($invalid) + #[DataProvider('invalidContextProvider')] + public function testSetInvalidContextOptions(mixed $invalid): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Expecting either a stream context resource or array'); @@ -267,7 +260,7 @@ public function testSetInvalidContextOptions($invalid) $adapter->setStreamContext($invalid); } - public function testSetHttpsStreamContextParam() + public function testSetHttpsStreamContextParam(): void { if ($this->client->getUri()->getScheme() !== 'https') { $this->markTestSkipped(); @@ -295,7 +288,7 @@ public function testSetHttpsStreamContextParam() * * @link https://getlaminas.org/issues/browse/Laminas-7309 */ - public function testExceptionOnReadTimeout() + public function testExceptionOnReadTimeout(): void { // Set 1 second timeout $this->client->setOptions(['timeout' => 1]); @@ -324,7 +317,7 @@ public function testExceptionOnReadTimeout() * * @link https://getlaminas.org/issues/browse/Laminas-6218 */ - public function testMultibyteChunkedResponseLaminas6218() + public function testMultibyteChunkedResponseLaminas6218(): void { $md5 = '7667818873302f9995be3798d503d8d3'; @@ -335,10 +328,9 @@ public function testMultibyteChunkedResponseLaminas6218() /** * Verifies that writing on a socket is considered valid even if 0 bytes * were written. - * - * @runInSeparateProcess */ - public function testAllowsZeroWrittenBytes() + #[RunInSeparateProcess] + public function testAllowsZeroWrittenBytes(): void { $this->adapter->connect('localhost'); require_once __DIR__ . '/_files/fwrite.php'; @@ -349,7 +341,7 @@ public function testAllowsZeroWrittenBytes() * Verifies that the headers are being set as given without changing any * character case. */ - public function testCaseInsensitiveHeaders() + public function testCaseInsensitiveHeaders(): void { $this->adapter->connect('localhost'); $requestString = $this->adapter->write( @@ -369,10 +361,8 @@ public function testCaseInsensitiveHeaders() /** * Provide invalid context resources / options - * - * @return array */ - public static function invalidContextProvider() + public static function invalidContextProvider(): array { return [ [new stdClass()], diff --git a/test/Client/StaticClientTest.php b/test/Client/StaticClientTest.php index a641577c..d7181bb1 100644 --- a/test/Client/StaticClientTest.php +++ b/test/Client/StaticClientTest.php @@ -6,6 +6,7 @@ use Laminas\Http\Client; use Laminas\Http\ClientStatic as HTTPClient; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use ReflectionClass; @@ -18,18 +19,15 @@ /** * This are the test for the prototype of Laminas\Http\Client - * - * @group Laminas\Http - * @group Laminas\Http\Client */ +#[Group('Laminas\Http')] +#[Group(Client::class)] class StaticClientTest extends TestCase { /** * Uri for test - * - * @var string */ - protected $baseuri; + protected string $baseuri; /** * Set up the test case @@ -56,7 +54,7 @@ protected function setUp(): void /** * Test simple GET */ - public function testHttpSimpleGet() + public function testHttpSimpleGet(): void { $response = HTTPClient::get($this->baseuri . 'testSimpleRequests.php'); $this->assertTrue($response->isSuccess()); @@ -65,7 +63,7 @@ public function testHttpSimpleGet() /** * Test GET with query string in URI */ - public function testHttpGetWithParamsInUri() + public function testHttpGetWithParamsInUri(): void { $response = HTTPClient::get($this->baseuri . 'testGetData.php?foo'); $this->assertTrue($response->isSuccess()); @@ -75,7 +73,7 @@ public function testHttpGetWithParamsInUri() /** * Test GET with query as params */ - public function testHttpMultiGetWithParam() + public function testHttpMultiGetWithParam(): void { $response = HTTPClient::get($this->baseuri . 'testGetData.php', ['foo' => 'bar']); $this->assertTrue($response->isSuccess()); @@ -86,7 +84,7 @@ public function testHttpMultiGetWithParam() /** * Test GET with body */ - public function testHttpGetWithBody() + public function testHttpGetWithBody(): void { $getBody = 'baz'; @@ -106,7 +104,7 @@ public function testHttpGetWithBody() /** * Test simple POST */ - public function testHttpSimplePost() + public function testHttpSimplePost(): void { $response = HTTPClient::post($this->baseuri . 'testPostData.php', ['foo' => 'bar']); $this->assertTrue($response->isSuccess()); @@ -117,7 +115,7 @@ public function testHttpSimplePost() /** * Test POST with header Content-Type */ - public function testHttpPostContentType() + public function testHttpPostContentType(): void { $response = HTTPClient::post( $this->baseuri . 'testPostData.php', @@ -132,7 +130,7 @@ public function testHttpPostContentType() /** * Test POST with body */ - public function testHttpPostWithBody() + public function testHttpPostWithBody(): void { $postBody = 'foo'; @@ -152,7 +150,7 @@ public function testHttpPostWithBody() * * @link https://github.com/zendframework/zf2/issues/6482 */ - public function testHttpGetUsesAdapterConfig() + public function testHttpGetUsesAdapterConfig(): void { $testUri = $this->baseuri . 'testSimpleRequests.php'; @@ -177,7 +175,7 @@ public function testHttpGetUsesAdapterConfig() * * @link https://github.com/zendframework/zf2/issues/6482 */ - public function testHttpPostUsesAdapterConfig() + public function testHttpPostUsesAdapterConfig(): void { $testUri = $this->baseuri . 'testPostData.php'; diff --git a/test/Client/StaticTest.php b/test/Client/StaticTest.php index 142427dc..fe07909e 100644 --- a/test/Client/StaticTest.php +++ b/test/Client/StaticTest.php @@ -16,6 +16,8 @@ use Laminas\Uri\Http as UriHttp; use LaminasTest\Http\Client\TestAsset\MockAdapter; use LaminasTest\Http\Client\TestAsset\MockClient; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use stdClass; @@ -45,10 +47,9 @@ * on performing actual requests to an HTTP server. These tests can be * executed once, and do not need to be tested with different servers / * client setups. - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] class StaticTest extends TestCase { /** @@ -56,7 +57,7 @@ class StaticTest extends TestCase * * @var HTTPClient */ - protected $client; + protected HTTPClient|MockClient|null $client; /** * Set up the test suite before each test @@ -81,7 +82,7 @@ public function tearDown(): void /** * Test we can SET and GET a URI as string */ - public function testSetGetUriString() + public function testSetGetUriString(): void { $uristr = 'https://www.zend.com:80/'; @@ -102,7 +103,7 @@ public function testSetGetUriString() /** * Test we can SET and GET a URI as object */ - public function testSetGetUriObject() + public function testSetGetUriObject(): void { $uriobj = new UriHttp('https://www.zend.com:80/'); @@ -117,7 +118,7 @@ public function testSetGetUriObject() * Test that setting the same parameter twice in the query string does not * get reduced to a single value only. */ - public function testDoubleGetParameter() + public function testDoubleGetParameter(): void { $qstr = 'foo=bar&foo=baz'; @@ -140,7 +141,7 @@ public function testDoubleGetParameter() /** * Test we can get already set headers */ - public function testGetHeader() + public function testGetHeader(): void { $this->client->setHeaders([ 'Accept-encoding' => 'gzip,deflate', @@ -167,7 +168,7 @@ public function testGetHeader() * Test setAuth (dynamic method) fails when trying to use an unsupported * authentication scheme */ - public function testExceptUnsupportedAuthDynamic() + public function testExceptUnsupportedAuthDynamic(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid or not supported authentication type: \'SuperStrongAlgo\''); @@ -182,7 +183,7 @@ public function testExceptUnsupportedAuthDynamic() /** * Test we can properly set a new cookies */ - public function testSetNewCookies() + public function testSetNewCookies(): void { $this->client->addCookie('cookie', 'value'); $this->client->addCookie('chocolate', 'chips'); @@ -197,7 +198,7 @@ public function testSetNewCookies() /** * Test we can unset a cookie jar */ - public function testUnsetCookies() + public function testUnsetCookies(): void { // Set the cookie jar just like in testSetNewCookieJar $this->client->addCookie('cookie', 'value'); @@ -214,7 +215,7 @@ public function testUnsetCookies() /** * Make sure using an invalid cookie jar object throws an exception */ - public function testSetInvalidCookies() + public function testSetInvalidCookies(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid parameter type passed as Cookie'); @@ -229,7 +230,7 @@ public function testSetInvalidCookies() /** * Test that we can set a valid configuration array with some options */ - public function testConfigSetAsArray() + public function testConfigSetAsArray(): void { $config = [ 'timeout' => 500, @@ -250,7 +251,7 @@ public function testConfigSetAsArray() * * @link https://framework.zend.com/issues/browse/ZEND-5577 */ - public function testConfigSetAsTraversable() + public function testConfigSetAsTraversable(): void { $config = new ArrayObject([ 'timeout' => 400, @@ -268,11 +269,9 @@ public function testConfigSetAsTraversable() /** * Test that passing invalid variables to setConfig() causes an exception - * - * @dataProvider invalidConfigProvider - * @param mixed $config */ - public function testConfigSetInvalid($config) + #[DataProvider('invalidConfigProvider')] + public function testConfigSetInvalid(mixed $config): void { $this->expectException(ClientException\InvalidArgumentException::class); $this->expectExceptionMessage('Config parameter is not valid'); @@ -283,10 +282,9 @@ public function testConfigSetInvalid($config) /** * Test that configuration options are passed to the adapter after the * adapter is instantiated - * - * @group Laminas-4557 */ - public function testConfigPassToAdapterLaminas4557() + #[Group('Laminas-4557')] + public function testConfigPassToAdapterLaminas4557(): void { $adapter = new MockAdapter(); @@ -309,7 +307,7 @@ public function testConfigPassToAdapterLaminas4557() /** * Test the getLastRawResponse() method actually returns the last response */ - public function testGetLastRawResponse() + public function testGetLastRawResponse(): void { // First, make sure we get null before the request $this->assertEquals( @@ -333,7 +331,7 @@ public function testGetLastRawResponse() /** * Test that getLastRawResponse returns null when not storing */ - public function testGetLastRawResponseWhenNotStoring() + public function testGetLastRawResponseWhenNotStoring(): void { // Now, test we get a proper response after the request $this->client->setUri('http://example.com/foo/bar'); @@ -352,7 +350,7 @@ public function testGetLastRawResponseWhenNotStoring() * Check we get an exception when trying to send a POST request with an * invalid content-type header */ - public function testInvalidPostContentType() + public function testInvalidPostContentType(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped(sprintf( @@ -373,7 +371,7 @@ public function testInvalidPostContentType() /** * Check we get an exception if there's an error in the socket */ - public function testSocketErrorException() + public function testSocketErrorException(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped(sprintf( @@ -397,11 +395,9 @@ public function testSocketErrorException() /** * Check that an exception is thrown if non-word characters are used in * the request method. - * - * @dataProvider invalidMethodProvider - * @param string $method */ - public function testSettingInvalidMethodThrowsException($method) + #[DataProvider('invalidMethodProvider')] + public function testSettingInvalidMethodThrowsException(string $method): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid HTTP method passed'); @@ -413,7 +409,7 @@ public function testSettingInvalidMethodThrowsException($method) * Test that POST data with multi-dimensional array is properly encoded as * multipart/form-data */ - public function testFormDataEncodingWithMultiArrayLaminas7038() + public function testFormDataEncodingWithMultiArrayLaminas7038(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped(sprintf( @@ -465,7 +461,7 @@ public function testFormDataEncodingWithMultiArrayLaminas7038() * * @link https://getlaminas.org/issues/browse/Laminas-2098 */ - public function testMultibyteRawPostDataLaminas2098() + public function testMultibyteRawPostDataLaminas2098(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped(sprintf( @@ -493,10 +489,9 @@ public function testMultibyteRawPostDataLaminas2098() /** * Testing if the connection isn't closed - * - * @group Laminas-9685 */ - public function testOpenTempStreamWithValidFileDoesntThrowsException() + #[Group('Laminas-9685')] + public function testOpenTempStreamWithValidFileDoesntThrowsException(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped(sprintf( @@ -518,10 +513,9 @@ public function testOpenTempStreamWithValidFileDoesntThrowsException() /** * Test if a downloaded file can be deleted - * - * @group Laminas-9685 */ - public function testDownloadedFileCanBeDeleted() + #[Group('Laminas-9685')] + public function testDownloadedFileCanBeDeleted(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped('Laminas\Http\Client online tests are not enabled'); @@ -548,10 +542,9 @@ public function testDownloadedFileCanBeDeleted() /** * Testing if the connection can be closed - * - * @group Laminas-9685 */ - public function testOpenTempStreamWithBogusFileClosesTheConnection() + #[Group('Laminas-9685')] + public function testOpenTempStreamWithBogusFileClosesTheConnection(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped(sprintf( @@ -574,10 +567,9 @@ public function testOpenTempStreamWithBogusFileClosesTheConnection() /** * Test sending cookie with encoded value - * - * @group fix-double-encoding-problem-about-cookie-value */ - public function testEncodedCookiesInRequestHeaders() + #[Group('fix-double-encoding-problem-about-cookie-value')] + public function testEncodedCookiesInRequestHeaders(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped(sprintf( @@ -597,10 +589,9 @@ public function testEncodedCookiesInRequestHeaders() /** * Test sending cookie header with raw value - * - * @group fix-double-encoding-problem-about-cookie-value */ - public function testRawCookiesInRequestHeaders() + #[Group('fix-double-encoding-problem-about-cookie-value')] + public function testRawCookiesInRequestHeaders(): void { if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped(sprintf( @@ -625,10 +616,8 @@ public function testRawCookiesInRequestHeaders() /** * Data provider of valid non-standard HTTP methods - * - * @return array */ - public static function validMethodProvider() + public static function validMethodProvider(): array { return [ ['OPTIONS'], @@ -642,10 +631,8 @@ public static function validMethodProvider() /** * Data provider of invalid HTTP methods - * - * @return array */ - public static function invalidMethodProvider() + public static function invalidMethodProvider(): array { return [ ['N@5TYM3T#0D'], @@ -657,15 +644,13 @@ public static function invalidMethodProvider() /** * Data provider for invalid configuration containers - * - * @return array */ - public static function invalidConfigProvider() + public static function invalidConfigProvider(): array { return [ [false], ['foobar'], - ['foo' => 'bar'], + ['bar'], [null], [new stdClass()], [55], diff --git a/test/Client/TestAdapterTest.php b/test/Client/TestAdapterTest.php index c11bb784..a55d9ddc 100644 --- a/test/Client/TestAdapterTest.php +++ b/test/Client/TestAdapterTest.php @@ -10,14 +10,15 @@ use Laminas\Http\Client\Adapter\Exception\RuntimeException; use Laminas\Http\Client\Adapter\Test; use Laminas\Http\Response; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; /** * Exercises Laminas_Http_Client_Adapter_Test - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] class TestAdapterTest extends TestCase { /** @@ -25,7 +26,7 @@ class TestAdapterTest extends TestCase * * @var Test */ - protected $adapter; + protected Test|null $adapter; /** * Set up the test adapter before running the test @@ -46,7 +47,7 @@ public function tearDown(): void /** * Make sure an exception is thrown on invalid configuration */ - public function testSetConfigThrowsOnInvalidConfig() + public function testSetConfigThrowsOnInvalidConfig(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Array or Traversable object expected'); @@ -54,22 +55,22 @@ public function testSetConfigThrowsOnInvalidConfig() $this->adapter->setOptions('foo'); } - public function testSetConfigReturnsQuietly() + public function testSetConfigReturnsQuietly(): void { $this->adapter->setOptions(['foo' => 'bar']); } - public function testConnectReturnsQuietly() + public function testConnectReturnsQuietly(): void { $this->adapter->connect('http://foo'); } - public function testCloseReturnsQuietly() + public function testCloseReturnsQuietly(): void { $this->adapter->close(); } - public function testFailRequestOnDemand() + public function testFailRequestOnDemand(): void { $this->adapter->setNextRequestWillFail(true); @@ -83,13 +84,13 @@ public function testFailRequestOnDemand() } } - public function testReadDefaultResponse() + public function testReadDefaultResponse(): void { $expected = "HTTP/1.1 400 Bad Request\r\n\r\n"; $this->assertEquals($expected, $this->adapter->read()); } - public function testReadingSingleResponse() + public function testReadingSingleResponse(): void { $expected = "HTTP/1.1 200 OK\r\n\r\n"; $this->adapter->setResponse($expected); @@ -97,7 +98,7 @@ public function testReadingSingleResponse() $this->assertEquals($expected, $this->adapter->read()); } - public function testReadingResponseCycles() + public function testReadingResponseCycles(): void { $expected = [ "HTTP/1.1 200 OK\r\n\r\n", @@ -114,11 +115,9 @@ public function testReadingResponseCycles() /** * Test that responses could be added as strings - * - * @dataProvider validHttpResponseProvider - * @param string $testResponse */ - public function testAddResponseAsString($testResponse) + #[DataProvider('validHttpResponseProvider')] + public function testAddResponseAsString(string $testResponse): void { $this->adapter->read(); // pop out first response @@ -130,12 +129,9 @@ public function testAddResponseAsString($testResponse) * Test that responses could be added as objects (Laminas-7009) * * @link https://getlaminas.org/issues/browse/Laminas-7009 - * - * @dataProvider validHttpResponseProvider - * - * @param string $testResponse */ - public function testAddResponseAsObject($testResponse) + #[DataProvider('validHttpResponseProvider')] + public function testAddResponseAsObject(string $testResponse): void { $this->adapter->read(); // pop out first response @@ -145,7 +141,7 @@ public function testAddResponseAsObject($testResponse) $this->assertEquals($testResponse, $this->adapter->read()); } - public function testReadingResponseCyclesWhenSetByArray() + public function testReadingResponseCyclesWhenSetByArray(): void { $expected = [ "HTTP/1.1 200 OK\r\n\r\n", @@ -159,7 +155,7 @@ public function testReadingResponseCyclesWhenSetByArray() $this->assertEquals($expected[0], $this->adapter->read()); } - public function testSettingNextResponseByIndex() + public function testSettingNextResponseByIndex(): void { $expected = [ "HTTP/1.1 200 OK\r\n\r\n", @@ -176,7 +172,7 @@ public function testSettingNextResponseByIndex() } } - public function testSettingNextResponseToAnInvalidIndex() + public function testSettingNextResponseToAnInvalidIndex(): void { $indexes = [-1, 1]; foreach ($indexes as $i) { @@ -196,10 +192,8 @@ public function testSettingNextResponseToAnInvalidIndex() /** * Provide valid HTTP responses as string - * - * @return array */ - public static function validHttpResponseProvider() + public static function validHttpResponseProvider(): array { return [ ['HTTP/1.1 200 OK' . "\r\n\r\n"], diff --git a/test/Client/UseCaseTest.php b/test/Client/UseCaseTest.php index 0b40428b..38147d6a 100644 --- a/test/Client/UseCaseTest.php +++ b/test/Client/UseCaseTest.php @@ -8,6 +8,7 @@ use Laminas\Http\Client\Adapter\AdapterInterface; use Laminas\Http\Client\Adapter\Socket; use Laminas\Http\Request; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function filter_var; @@ -18,10 +19,9 @@ /** * This are the test for the prototype of Laminas\Http\Client - * - * @group Laminas_Http - * @group Laminas_Http_Client */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Client')] class UseCaseTest extends TestCase { /** @@ -30,28 +30,24 @@ class UseCaseTest extends TestCase * * @var string */ - protected $baseuri; + protected string|array|false $baseuri; /** * Common HTTP client * * @var HTTPClient */ - protected $client; + protected HTTPClient|null $client; /** * Common HTTP client adapter - * - * @var AdapterInterface */ - protected $adapter; + protected AdapterInterface $adapter; /** * Configuration array - * - * @var array */ - protected $config = [ + protected array $config = [ 'adapter' => Socket::class, ]; @@ -83,20 +79,20 @@ protected function tearDown(): void $this->client = null; } - public function testHttpGet() + public function testHttpGet(): void { $this->client->setMethod(Request::METHOD_GET); $response = $this->client->send(); $this->assertTrue($response->isSuccess()); } - public function testStaticHttpGet() + public function testStaticHttpGet(): void { // $response= HTTPClient::get($this->baseuri); // $this->assertTrue($response->isSuccess()); } - public function testRequestHttpGet() + public function testRequestHttpGet(): void { $client = new HTTPClient(); $request = new Request(); diff --git a/test/ClientTest.php b/test/ClientTest.php index 21dd8770..556355cb 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -18,6 +18,8 @@ use Laminas\Http\Response; use Laminas\Uri\Http; use LaminasTest\Http\TestAsset\ExtendedClient; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use ReflectionMethod; use ReflectionProperty; @@ -34,7 +36,7 @@ class ClientTest extends TestCase { - public function testIfCookiesAreSticky() + public function testIfCookiesAreSticky(): void { $initialCookies = [ new SetCookie('foo', 'far', null, '/', 'www.domain.com'), @@ -76,14 +78,14 @@ public function testIfCookiesAreSticky() $this->assertEquals(4, count($client->getCookies())); } - public function testClientRetrievesUppercaseHttpMethodFromRequestObject() + public function testClientRetrievesUppercaseHttpMethodFromRequestObject(): void { $client = new Client(); $client->setMethod('post'); $this->assertEquals(Client::ENC_URLENCODED, $client->getEncType()); } - public function testAcceptEncodingHeaderWorksProperly() + public function testAcceptEncodingHeaderWorksProperly(): void { $method = new ReflectionMethod(Client::class, 'prepareHeaders'); $method->setAccessible(true); @@ -119,7 +121,7 @@ public function testAcceptEncodingHeaderWorksProperly() $this->assertEquals('gzip, deflate', $headers['Accept-Encoding']); } - public function testIfZeroValueCookiesCanBeSet() + public function testIfZeroValueCookiesCanBeSet(): void { $client = new Client(); $client->addCookie('test', 0); @@ -127,7 +129,7 @@ public function testIfZeroValueCookiesCanBeSet() $client->addCookie('test3', false); } - public function testIfNullValueCookiesThrowsException() + public function testIfNullValueCookiesThrowsException(): void { $client = new Client(); @@ -135,7 +137,7 @@ public function testIfNullValueCookiesThrowsException() $client->addCookie('test', null); } - public function testIfCookieHeaderCanBeSet() + public function testIfCookieHeaderCanBeSet(): void { $header = [new SetCookie('foo', 'bar')]; $client = new Client(); @@ -146,7 +148,7 @@ public function testIfCookieHeaderCanBeSet() $this->assertEquals($header[0], $cookies['foo']); } - public function testIfArrayOfHeadersCanBeSet() + public function testIfArrayOfHeadersCanBeSet(): void { $headers = [ new SetCookie('foo'), @@ -160,7 +162,7 @@ public function testIfArrayOfHeadersCanBeSet() $this->assertEquals(2, count($cookies)); } - public function testIfArrayIteratorOfHeadersCanBeSet() + public function testIfArrayIteratorOfHeadersCanBeSet(): void { $headers = new ArrayIterator([ new SetCookie('foo'), @@ -174,29 +176,25 @@ public function testIfArrayIteratorOfHeadersCanBeSet() $this->assertEquals(2, count($cookies)); } - /** - * @group 2774 - * @group 2745 - */ - public function testArgSeparatorDefaultsToIniSetting() + #[Group('2774')] + #[Group('2745')] + public function testArgSeparatorDefaultsToIniSetting(): void { $argSeparator = ini_get('arg_separator.output'); $client = new Client(); $this->assertEquals($argSeparator, $client->getArgSeparator()); } - /** - * @group 2774 - * @group 2745 - */ - public function testCanOverrideArgSeparator() + #[Group('2774')] + #[Group('2745')] + public function testCanOverrideArgSeparator(): void { $client = new Client(); $client->setArgSeparator(';'); $this->assertEquals(';', $client->getArgSeparator()); } - public function testClientUsesAcceptEncodingHeaderFromRequestObject() + public function testClientUsesAcceptEncodingHeaderFromRequestObject(): void { $client = new Client(); @@ -218,25 +216,25 @@ public function testClientUsesAcceptEncodingHeaderFromRequestObject() $this->assertStringContainsString('Accept-Encoding: foo', $rawRequest); } - public function testEncodeAuthHeaderWorksAsExpected() + public function testEncodeAuthHeaderWorksAsExpected(): void { $encoded = Client::encodeAuthHeader('test', 'test'); $this->assertEquals('Basic ' . base64_encode('test:test'), $encoded); } - public function testEncodeAuthHeaderThrowsExceptionWhenUsernameContainsSemiColon() + public function testEncodeAuthHeaderThrowsExceptionWhenUsernameContainsSemiColon(): void { $this->expectException(ClientException\InvalidArgumentException::class); Client::encodeAuthHeader('test:', 'test'); } - public function testEncodeAuthHeaderThrowsExceptionWhenInvalidAuthTypeIsUsed() + public function testEncodeAuthHeaderThrowsExceptionWhenInvalidAuthTypeIsUsed(): void { $this->expectException(ClientException\InvalidArgumentException::class); Client::encodeAuthHeader('test', 'test', 'test'); } - public function testIfMaxredirectWorksCorrectly() + public function testIfMaxredirectWorksCorrectly(): void { $testAdapter = new Test(); // first response, contains a redirect @@ -272,7 +270,7 @@ public function testIfMaxredirectWorksCorrectly() $this->assertEquals($response->getContent(), 'Page #2'); } - public function testIfClientDoesNotLooseAuthenticationOnRedirect() + public function testIfClientDoesNotLooseAuthenticationOnRedirect(): void { // set up user credentials $user = 'username123'; @@ -305,7 +303,7 @@ public function testIfClientDoesNotLooseAuthenticationOnRedirect() $this->assertStringContainsString($encoded, $client->getLastRawRequest()); } - public function testIfClientDoesNotForwardAuthenticationToForeignHost() + public function testIfClientDoesNotForwardAuthenticationToForeignHost(): void { // set up user credentials $user = 'username123'; @@ -376,7 +374,7 @@ public function testIfClientDoesNotForwardAuthenticationToForeignHost() $this->assertStringNotContainsString($encoded, $client->getLastRawRequest()); } - public function testAdapterAlwaysReachableIfSpecified() + public function testAdapterAlwaysReachableIfSpecified(): void { $testAdapter = new Test(); $client = new Client('http://www.example.org/', [ @@ -386,7 +384,7 @@ public function testAdapterAlwaysReachableIfSpecified() $this->assertSame($testAdapter, $client->getAdapter()); } - public function testPrepareHeadersCreateRightHttpField() + public function testPrepareHeadersCreateRightHttpField(): void { $body = json_encode(['foofoo' => 'barbar']); @@ -412,7 +410,7 @@ public function testPrepareHeadersCreateRightHttpField() $this->assertArrayHasKey('Content-Length', $headers); } - public function testPrepareHeadersCurlDigestAuthentication() + public function testPrepareHeadersCurlDigestAuthentication(): void { $body = json_encode(['foofoo' => 'barbar']); @@ -435,10 +433,8 @@ public function testPrepareHeadersCurlDigestAuthentication() $this->assertStringContainsString('Digest', $headers['Authorization']); } - /** - * @group 6301 - */ - public function testCanSpecifyCustomAuthMethodsInExtendingClasses() + #[Group('6301')] + public function testCanSpecifyCustomAuthMethodsInExtendingClasses(): void { $client = new ExtendedClient(); @@ -458,10 +454,8 @@ public function testCanSpecifyCustomAuthMethodsInExtendingClasses() ); } - /** - * @group 6231 - */ - public function testHttpQueryParametersCastToString() + #[Group('6231')] + public function testHttpQueryParametersCastToString(): void { $client = new Client(); @@ -489,10 +483,8 @@ public function testHttpQueryParametersCastToString() $client->send($request); } - /** - * @group 6959 - */ - public function testClientRequestMethod() + #[Group('6959')] + public function testClientRequestMethod(): void { $request = new Request(); $request->setMethod(Request::METHOD_POST); @@ -505,10 +497,8 @@ public function testClientRequestMethod() $this->assertSame(Client::ENC_URLENCODED, $client->getEncType()); } - /** - * @group 7332 - */ - public function testAllowsClearingEncType() + #[Group('7332')] + public function testAllowsClearingEncType(): void { $client = new Client(); $client->setEncType('application/x-www-form-urlencoded'); @@ -522,7 +512,7 @@ public function testAllowsClearingEncType() /** * @see https://github.com/zendframework/zend-http/issues/33 */ - public function testFormUrlEncodeSeparator() + public function testFormUrlEncodeSeparator(): void { $client = new Client(); $client->setEncType('application/x-www-form-urlencoded'); @@ -538,7 +528,7 @@ public function testFormUrlEncodeSeparator() } /** @psalm-return array */ - public function uriDataProvider(): array + public static function uriDataProvider(): array { return [ 'valid-relative' => ['/example', true], @@ -546,9 +536,7 @@ public function uriDataProvider(): array ]; } - /** - * @dataProvider uriDataProvider - */ + #[DataProvider('uriDataProvider')] public function testUriCorrectlyDeterminesWhetherOrNotItIsAValidRelativeUri( string $uri, bool $isValidRelativeURI @@ -562,7 +550,7 @@ public function testUriCorrectlyDeterminesWhetherOrNotItIsAValidRelativeUri( } /** @psalm-return array */ - public function portChangeDataProvider(): array + public static function portChangeDataProvider(): array { return [ 'default-https' => ['https://localhost/example', 443], @@ -570,9 +558,7 @@ public function portChangeDataProvider(): array ]; } - /** - * @dataProvider portChangeDataProvider - */ + #[DataProvider('portChangeDataProvider')] public function testUriPortIsSetToAppropriateDefaultValueWhenAnUriOmittingThePortIsProvided( string $absoluteURI, int $port @@ -588,7 +574,7 @@ public function testUriPortIsSetToAppropriateDefaultValueWhenAnUriOmittingThePor $this->assertSame($port, $client->getUri()->getPort()); } - public function testUriPortIsNotSetWhenUriIsRelative() + public function testUriPortIsNotSetWhenUriIsRelative(): void { $client = new Client('/example'); $this->assertNull($client->getUri()->getPort()); @@ -599,7 +585,7 @@ public function testUriPortIsNotSetWhenUriIsRelative() } /** @psalm-return iterable|SetCookie[]}> */ - public function cookies(): iterable + public static function cookies(): iterable { yield 'name-value' => [['cookie-name' => 'cookie-value']]; yield 'SetCookie' => [[new SetCookie('cookie-name', 'cookie-value')]]; @@ -607,9 +593,9 @@ public function cookies(): iterable /** * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity - * @dataProvider cookies */ - public function testSetCookies(array $cookies) + #[DataProvider('cookies')] + public function testSetCookies(array $cookies): void { $client = new Client(); @@ -619,7 +605,7 @@ public function testSetCookies(array $cookies) self::assertContainsOnlyInstancesOf(SetCookie::class, $client->getCookies()); } - public function testSetCookieAcceptOnlyArray() + public function testSetCookieAcceptOnlyArray(): void { $client = new Client(); @@ -631,17 +617,15 @@ public function testSetCookieAcceptOnlyArray() /** * @return AdapterInterface[] */ - public function adapterWithStreamSupport() + public static function adapterWithStreamSupport(): iterable { yield 'curl' => [new Curl()]; yield 'proxy' => [new Proxy()]; yield 'socket' => [new Socket()]; } - /** - * @dataProvider adapterWithStreamSupport - */ - public function testStreamCompression(AdapterInterface $adapter) + #[DataProvider('adapterWithStreamSupport')] + public function testStreamCompression(AdapterInterface $adapter): void { $tmpFile = tempnam(sys_get_temp_dir(), 'stream'); @@ -655,7 +639,7 @@ public function testStreamCompression(AdapterInterface $adapter) self::assertSame($response->getBody(), file_get_contents($tmpFile)); } - public function testDefaultUserAgentDoesNotUseEscapeCharacter() + public function testDefaultUserAgentDoesNotUseEscapeCharacter(): void { $client = new Client(); $r = new ReflectionProperty($client, 'config'); diff --git a/test/CookiesTest.php b/test/CookiesTest.php index 0f152ced..c4460cfc 100644 --- a/test/CookiesTest.php +++ b/test/CookiesTest.php @@ -13,7 +13,7 @@ class CookiesTest extends TestCase { - public function testFromResponseInSetCookie() + public function testFromResponseInSetCookie(): void { $response = new Response(); $headers = new Headers(); @@ -27,7 +27,7 @@ public function testFromResponseInSetCookie() $this->assertSame($header, $response->getCookie('https://www.zend.com', 'foo')); } - public function testFromResponseInCookie() + public function testFromResponseInCookie(): void { $response = new Response(); $headers = new Headers(); @@ -41,7 +41,7 @@ public function testFromResponseInCookie() $this->assertSame($header, $response->getCookie('https://www.zend.com', 'foo')); } - public function testRequestCanHaveArrayCookies() + public function testRequestCanHaveArrayCookies(): void { $_COOKIE = [ 'test' => [ diff --git a/test/Header/AcceptCharsetTest.php b/test/Header/AcceptCharsetTest.php index ff693d06..7f1dcb47 100644 --- a/test/Header/AcceptCharsetTest.php +++ b/test/Header/AcceptCharsetTest.php @@ -7,44 +7,45 @@ use Laminas\Http\Header\AcceptCharset; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function array_shift; class AcceptCharsetTest extends TestCase { - public function testAcceptCharsetFromStringCreatesValidAcceptCharsetHeader() + public function testAcceptCharsetFromStringCreatesValidAcceptCharsetHeader(): void { $acceptCharsetHeader = AcceptCharset::fromString('Accept-Charset: xxx'); $this->assertInstanceOf(HeaderInterface::class, $acceptCharsetHeader); $this->assertInstanceOf(AcceptCharset::class, $acceptCharsetHeader); } - public function testAcceptCharsetGetFieldNameReturnsHeaderName() + public function testAcceptCharsetGetFieldNameReturnsHeaderName(): void { $acceptCharsetHeader = new AcceptCharset(); $this->assertEquals('Accept-Charset', $acceptCharsetHeader->getFieldName()); } - public function testAcceptCharsetGetFieldValueReturnsProperValue() + public function testAcceptCharsetGetFieldValueReturnsProperValue(): void { $acceptCharsetHeader = AcceptCharset::fromString('Accept-Charset: xxx'); $this->assertEquals('xxx', $acceptCharsetHeader->getFieldValue()); } - public function testAcceptCharsetGetFieldValueReturnsProperValueWithTrailingSemicolon() + public function testAcceptCharsetGetFieldValueReturnsProperValueWithTrailingSemicolon(): void { $acceptCharsetHeader = AcceptCharset::fromString('Accept-Charset: xxx;'); $this->assertEquals('xxx', $acceptCharsetHeader->getFieldValue()); } - public function testAcceptCharsetGetFieldValueReturnsProperValueWithSemicolonWithoutEqualSign() + public function testAcceptCharsetGetFieldValueReturnsProperValueWithSemicolonWithoutEqualSign(): void { $acceptCharsetHeader = AcceptCharset::fromString('Accept-Charset: xxx;yyy'); $this->assertEquals('xxx;yyy', $acceptCharsetHeader->getFieldValue()); } - public function testAcceptCharsetToStringReturnsHeaderFormattedString() + public function testAcceptCharsetToStringReturnsHeaderFormattedString(): void { $acceptCharsetHeader = new AcceptCharset(); $acceptCharsetHeader->addCharset('iso-8859-5', 0.8) @@ -56,14 +57,14 @@ public function testAcceptCharsetToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testCanParseCommaSeparatedValues() + public function testCanParseCommaSeparatedValues(): void { $header = AcceptCharset::fromString('Accept-Charset: iso-8859-5;q=0.8,unicode-1-1'); $this->assertTrue($header->hasCharset('iso-8859-5')); $this->assertTrue($header->hasCharset('unicode-1-1')); } - public function testPrioritizesValuesBasedOnQParameter() + public function testPrioritizesValuesBasedOnQParameter(): void { $header = AcceptCharset::fromString('Accept-Charset: iso-8859-5;q=0.8,unicode-1-1,*;q=0.4'); $expected = [ @@ -77,7 +78,7 @@ public function testPrioritizesValuesBasedOnQParameter() } } - public function testWildcharCharset() + public function testWildcharCharset(): void { $acceptHeader = new AcceptCharset(); $acceptHeader->addCharset('iso-8859-5', 0.8) @@ -90,10 +91,9 @@ public function testWildcharCharset() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); AcceptCharset::fromString("Accept-Charset: iso-8859-5\r\n\r\nevilContent"); @@ -101,10 +101,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaSetters() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaSetters(): void { $header = new AcceptCharset(); $this->expectException(InvalidArgumentException::class); diff --git a/test/Header/AcceptEncodingTest.php b/test/Header/AcceptEncodingTest.php index 1f1a6fb8..d2369a92 100644 --- a/test/Header/AcceptEncodingTest.php +++ b/test/Header/AcceptEncodingTest.php @@ -7,44 +7,45 @@ use Laminas\Http\Header\AcceptEncoding; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function array_shift; class AcceptEncodingTest extends TestCase { - public function testAcceptEncodingFromStringCreatesValidAcceptEncodingHeader() + public function testAcceptEncodingFromStringCreatesValidAcceptEncodingHeader(): void { $acceptEncodingHeader = AcceptEncoding::fromString('Accept-Encoding: xxx'); $this->assertInstanceOf(HeaderInterface::class, $acceptEncodingHeader); $this->assertInstanceOf(AcceptEncoding::class, $acceptEncodingHeader); } - public function testAcceptEncodingGetFieldNameReturnsHeaderName() + public function testAcceptEncodingGetFieldNameReturnsHeaderName(): void { $acceptEncodingHeader = new AcceptEncoding(); $this->assertEquals('Accept-Encoding', $acceptEncodingHeader->getFieldName()); } - public function testAcceptEncodingGetFieldValueReturnsProperValue() + public function testAcceptEncodingGetFieldValueReturnsProperValue(): void { $acceptEncodingHeader = AcceptEncoding::fromString('Accept-Encoding: xxx'); $this->assertEquals('xxx', $acceptEncodingHeader->getFieldValue()); } - public function testAcceptEncodingGetFieldValueReturnsProperValueWithTrailingSemicolon() + public function testAcceptEncodingGetFieldValueReturnsProperValueWithTrailingSemicolon(): void { $acceptEncodingHeader = AcceptEncoding::fromString('Accept-Encoding: xxx;'); $this->assertEquals('xxx', $acceptEncodingHeader->getFieldValue()); } - public function testAcceptEncodingGetFieldValueReturnsProperValueWithSemicolonWithoutEqualSign() + public function testAcceptEncodingGetFieldValueReturnsProperValueWithSemicolonWithoutEqualSign(): void { $acceptEncodingHeader = AcceptEncoding::fromString('Accept-Encoding: xxx;yyy'); $this->assertEquals('xxx;yyy', $acceptEncodingHeader->getFieldValue()); } - public function testAcceptEncodingToStringReturnsHeaderFormattedString() + public function testAcceptEncodingToStringReturnsHeaderFormattedString(): void { $acceptEncodingHeader = new AcceptEncoding(); $acceptEncodingHeader->addEncoding('compress', 0.5) @@ -56,14 +57,14 @@ public function testAcceptEncodingToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testCanParseCommaSeparatedValues() + public function testCanParseCommaSeparatedValues(): void { $header = AcceptEncoding::fromString('Accept-Encoding: compress;q=0.5,gzip'); $this->assertTrue($header->hasEncoding('compress')); $this->assertTrue($header->hasEncoding('gzip')); } - public function testPrioritizesValuesBasedOnQParameter() + public function testPrioritizesValuesBasedOnQParameter(): void { $header = AcceptEncoding::fromString('Accept-Encoding: compress;q=0.8,gzip,*;q=0.4'); $expected = [ @@ -78,7 +79,7 @@ public function testPrioritizesValuesBasedOnQParameter() } } - public function testWildcharEncoder() + public function testWildcharEncoder(): void { $acceptHeader = new AcceptEncoding(); $acceptHeader->addEncoding('compress', 0.8) @@ -91,10 +92,9 @@ public function testWildcharEncoder() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); $header = AcceptEncoding::fromString("Accept-Encoding: compress\r\n\r\nevilContent"); @@ -102,10 +102,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaSetters() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaSetters(): void { $header = new AcceptEncoding(); $this->expectException(InvalidArgumentException::class); diff --git a/test/Header/AcceptLanguageTest.php b/test/Header/AcceptLanguageTest.php index 30756ceb..9fb30f2a 100644 --- a/test/Header/AcceptLanguageTest.php +++ b/test/Header/AcceptLanguageTest.php @@ -7,44 +7,45 @@ use Laminas\Http\Header\AcceptLanguage; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function array_shift; class AcceptLanguageTest extends TestCase { - public function testAcceptLanguageFromStringCreatesValidAcceptLanguageHeader() + public function testAcceptLanguageFromStringCreatesValidAcceptLanguageHeader(): void { $acceptLanguageHeader = AcceptLanguage::fromString('Accept-Language: xxx'); $this->assertInstanceOf(HeaderInterface::class, $acceptLanguageHeader); $this->assertInstanceOf(AcceptLanguage::class, $acceptLanguageHeader); } - public function testAcceptLanguageGetFieldNameReturnsHeaderName() + public function testAcceptLanguageGetFieldNameReturnsHeaderName(): void { $acceptLanguageHeader = new AcceptLanguage(); $this->assertEquals('Accept-Language', $acceptLanguageHeader->getFieldName()); } - public function testAcceptLanguageGetFieldValueReturnsProperValue() + public function testAcceptLanguageGetFieldValueReturnsProperValue(): void { $acceptLanguageHeader = AcceptLanguage::fromString('Accept-Language: xxx'); $this->assertEquals('xxx', $acceptLanguageHeader->getFieldValue()); } - public function testAcceptLanguageGetFieldValueReturnsProperValueWithTrailingSemicolon() + public function testAcceptLanguageGetFieldValueReturnsProperValueWithTrailingSemicolon(): void { $acceptLanguageHeader = AcceptLanguage::fromString('Accept-Language: xxx;'); $this->assertEquals('xxx', $acceptLanguageHeader->getFieldValue()); } - public function testAcceptLanguageGetFieldValueReturnsProperValueWithSemicolonWithoutEqualSign() + public function testAcceptLanguageGetFieldValueReturnsProperValueWithSemicolonWithoutEqualSign(): void { $acceptLanguageHeader = AcceptLanguage::fromString('Accept-Language: xxx;yyy'); $this->assertEquals('xxx;yyy', $acceptLanguageHeader->getFieldValue()); } - public function testAcceptLanguageToStringReturnsHeaderFormattedString() + public function testAcceptLanguageToStringReturnsHeaderFormattedString(): void { $acceptLanguageHeader = new AcceptLanguage(); $acceptLanguageHeader->addLanguage('da', 0.8) @@ -56,14 +57,14 @@ public function testAcceptLanguageToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testCanParseCommaSeparatedValues() + public function testCanParseCommaSeparatedValues(): void { $header = AcceptLanguage::fromString('Accept-Language: da;q=0.8, en-gb'); $this->assertTrue($header->hasLanguage('da')); $this->assertTrue($header->hasLanguage('en-gb')); } - public function testPrioritizesValuesBasedOnQParameter() + public function testPrioritizesValuesBasedOnQParameter(): void { $header = AcceptLanguage::fromString('Accept-Language: da;q=0.8, en-gb, *;q=0.4'); $expected = [ @@ -79,7 +80,7 @@ public function testPrioritizesValuesBasedOnQParameter() $this->assertEquals($expected, $test); } - public function testWildcharLanguage() + public function testWildcharLanguage(): void { $acceptHeader = new AcceptLanguage(); $acceptHeader->addLanguage('da', 0.8) @@ -90,7 +91,7 @@ public function testWildcharLanguage() $this->assertEquals('Accept-Language: da;q=0.8, *;q=0.4', $acceptHeader->toString()); } - public function testWildcards() + public function testWildcards(): void { $accept = AcceptLanguage::fromString('*, en-*, en-us'); $res = $accept->getPrioritized(); @@ -107,10 +108,9 @@ public function testWildcards() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); $header = AcceptLanguage::fromString("Accept-Language: da\r\n\r\nevilContent"); @@ -118,10 +118,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaSetters() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaSetters(): void { $header = new AcceptLanguage(); $this->expectException(InvalidArgumentException::class); diff --git a/test/Header/AcceptRangesTest.php b/test/Header/AcceptRangesTest.php index 4876d46a..5e64a27a 100644 --- a/test/Header/AcceptRangesTest.php +++ b/test/Header/AcceptRangesTest.php @@ -7,31 +7,32 @@ use Laminas\Http\Header\AcceptRanges; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class AcceptRangesTest extends TestCase { - public function testAcceptRangesFromStringCreatesValidAcceptRangesHeader() + public function testAcceptRangesFromStringCreatesValidAcceptRangesHeader(): void { $acceptRangesHeader = AcceptRanges::fromString('Accept-Ranges: bytes'); $this->assertInstanceOf(HeaderInterface::class, $acceptRangesHeader); $this->assertInstanceOf(AcceptRanges::class, $acceptRangesHeader); } - public function testAcceptRangesGetFieldNameReturnsHeaderName() + public function testAcceptRangesGetFieldNameReturnsHeaderName(): void { $acceptRangesHeader = new AcceptRanges(); $this->assertEquals('Accept-Ranges', $acceptRangesHeader->getFieldName()); } - public function testAcceptRangesGetFieldValueReturnsProperValue() + public function testAcceptRangesGetFieldValueReturnsProperValue(): void { $acceptRangesHeader = AcceptRanges::fromString('Accept-Ranges: bytes'); $this->assertEquals('bytes', $acceptRangesHeader->getFieldValue()); $this->assertEquals('bytes', $acceptRangesHeader->getRangeUnit()); } - public function testAcceptRangesToStringReturnsHeaderFormattedString() + public function testAcceptRangesToStringReturnsHeaderFormattedString(): void { $acceptRangesHeader = new AcceptRanges(); $acceptRangesHeader->setRangeUnit('bytes'); @@ -41,13 +42,11 @@ public function testAcceptRangesToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); $header = AcceptRanges::fromString("Accept-Ranges: bytes;\r\n\r\nevilContent"); @@ -55,10 +54,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); $header = new AcceptRanges("bytes;\r\n\r\nevilContent"); diff --git a/test/Header/AcceptTest.php b/test/Header/AcceptTest.php index f3370393..c262f243 100644 --- a/test/Header/AcceptTest.php +++ b/test/Header/AcceptTest.php @@ -9,6 +9,8 @@ use Laminas\Http\Header\Accept\FieldValuePart\AcceptFieldValuePart; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function addslashes; @@ -16,38 +18,38 @@ class AcceptTest extends TestCase { - public function testInvalidHeaderLine() + public function testInvalidHeaderLine(): void { $this->expectException(InvalidArgumentException::class); Accept::fromString(''); } - public function testAcceptFromStringCreatesValidAcceptHeader() + public function testAcceptFromStringCreatesValidAcceptHeader(): void { $acceptHeader = Accept::fromString('Accept: xxx'); $this->assertInstanceOf(HeaderInterface::class, $acceptHeader); $this->assertInstanceOf(Accept::class, $acceptHeader); } - public function testAcceptGetFieldNameReturnsHeaderName() + public function testAcceptGetFieldNameReturnsHeaderName(): void { $acceptHeader = new Accept(); $this->assertEquals('Accept', $acceptHeader->getFieldName()); } - public function testAcceptGetFieldValueReturnsProperValue() + public function testAcceptGetFieldValueReturnsProperValue(): void { $acceptHeader = Accept::fromString('Accept: xxx'); $this->assertEquals('xxx', $acceptHeader->getFieldValue()); } - public function testAcceptGetFieldValueReturnsProperValueWithAHeaderWithoutSpaces() + public function testAcceptGetFieldValueReturnsProperValueWithAHeaderWithoutSpaces(): void { $acceptHeader = Accept::fromString('Accept:xxx'); $this->assertEquals('xxx', $acceptHeader->getFieldValue()); } - public function testAcceptToStringReturnsHeaderFormattedString() + public function testAcceptToStringReturnsHeaderFormattedString(): void { $acceptHeader = new Accept(); $acceptHeader->addMediaType('text/html', 0.8) @@ -67,7 +69,7 @@ public function testAcceptToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testCanParseCommaSeparatedValues() + public function testCanParseCommaSeparatedValues(): void { $header = Accept::fromString('Accept: text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c'); $this->assertTrue($header->hasMediaType('text/plain')); @@ -76,7 +78,7 @@ public function testCanParseCommaSeparatedValues() $this->assertTrue($header->hasMediaType('text/x-c')); } - public function testPrioritizesValuesBasedOnQParameter() + public function testPrioritizesValuesBasedOnQParameter(): void { $header = Accept::fromString( 'Accept: text/plain; q=0.5, text/html, text/xml; q=0, text/x-dvi; q=0.8, text/x-c' @@ -94,7 +96,7 @@ public function testPrioritizesValuesBasedOnQParameter() } } - public function testLevel() + public function testLevel(): void { $acceptHeader = new Accept(); $acceptHeader->addMediaType('text/html', 0.8, ['level' => 1]) @@ -108,7 +110,7 @@ public function testLevel() ); } - public function testPrioritizedLevel() + public function testPrioritizedLevel(): void { $header = Accept::fromString( 'Accept: text/*;q=0.3, text/html;q=0.7, text/html;level=1,' @@ -128,7 +130,7 @@ public function testPrioritizedLevel() } } - public function testPrios() + public function testPrios(): void { $values = [ 'invalidPrio' => false, @@ -157,7 +159,7 @@ public function testPrios() } } - public function testWildcharMediaType() + public function testWildcharMediaType(): void { $acceptHeader = new Accept(); $acceptHeader->addMediaType('text/*', 0.8) @@ -170,7 +172,7 @@ public function testWildcharMediaType() $this->assertEquals('Accept: application/*, text/*;q=0.8, */*;q=0.4', $acceptHeader->toString()); } - public function testMatchWildCard() + public function testMatchWildCard(): void { $acceptHeader = Accept::fromString('Accept: */*'); $this->assertTrue($acceptHeader->hasMediaType('application/vnd.foobar+json')); @@ -190,7 +192,7 @@ public function testMatchWildCard() $this->assertTrue($acceptHeader->hasMediaType('text/*')); } - public function testParsingAndAssemblingQuotedStrings() + public function testParsingAndAssemblingQuotedStrings(): void { $acceptStr = 'Accept: application/vnd.foobar+html;q=1;version="2' . '\"";level="foo;, bar", text/json;level=1, text/xml;level=2;q=0.4'; @@ -199,7 +201,7 @@ public function testParsingAndAssemblingQuotedStrings() $this->assertEquals($acceptStr, $acceptHeader->getFieldName() . ': ' . $acceptHeader->getFieldValue()); } - public function testMatchReturnsMatchedAgainstObject() + public function testMatchReturnsMatchedAgainstObject(): void { $acceptStr = 'Accept: text/html;q=1; version=23; level=5, text/json;level=1,text/xml;level=2;q=0.4'; $acceptHeader = Accept::fromString($acceptStr); @@ -223,7 +225,7 @@ public function testMatchReturnsMatchedAgainstObject() ); } - public function testVersioning() + public function testVersioning(): void { $acceptStr = 'Accept: text/html;q=1; version=23; level=5, text/json;level=1,text/xml;level=2;q=0.4'; $acceptHeader = Accept::fromString($acceptStr); @@ -261,7 +263,7 @@ public function testVersioning() } } - public function testWildcardWithDifferentParamsAndRanges() + public function testWildcardWithDifferentParamsAndRanges(): void { $acceptHeader = Accept::fromString('Accept: */*; version=21'); $this->assertFalse($acceptHeader->match('*/*; version=20|22')); @@ -278,26 +280,16 @@ public function testWildcardWithDifferentParamsAndRanges() $this->assertEquals('21', $res->getParams()->version); } - /** - * @group 3739 - * @covers Laminas\Http\Header\AbstractAccept::matchAcceptParams() - */ - public function testParamRangesWithDecimals() + #[Group('3739')] + public function testParamRangesWithDecimals(): void { $acceptHeader = Accept::fromString('Accept: application/vnd.com.example+xml; version=10'); $this->assertFalse($acceptHeader->match('application/vnd.com.example+xml; version="\"3.1\"-\"3.1.1-DEV\""')); } - /** - * @group 3740 - * @covers Laminas\Http\Header\AbstractAccept::matchAcceptParams() - * @covers Laminas\Http\Header\AbstractAccept::getParametersFromFieldValuePart() - * @dataProvider provideParamRanges - * @param string $range - * @param string $input - * @param bool $success - */ - public function testParamRangesSupportDevStage($range, $input, $success) + #[DataProvider('provideParamRanges')] + #[Group('3740')] + public function testParamRangesSupportDevStage(string $range, string $input, bool $success): void { $acceptHeader = Accept::fromString( 'Accept: application/vnd.com.example+xml; version="' . addslashes($input) . '"' @@ -314,11 +306,8 @@ public function testParamRangesSupportDevStage($range, $input, $success) } } - /** - * @group 3740 - * @return array - */ - public function provideParamRanges() + #[Group('3740')] + public static function provideParamRanges(): array { return [ ['"3.1.1-DEV"-3.1.1', '3.1.1', true], @@ -334,7 +323,7 @@ public function provideParamRanges() ]; } - public function testVersioningAndPriorization() + public function testVersioningAndPriorization(): void { $acceptStr = 'Accept: text/html; version=23, text/json; version=15.3; q=0.9,text/html;level=2;q=0.4'; $acceptHeader = Accept::fromString($acceptStr); @@ -374,7 +363,7 @@ public function testVersioningAndPriorization() } } - public function testPrioritizing() + public function testPrioritizing(): void { // Example is copy/paste from rfc2616 $acceptStr = 'Accept: text/*;q=0.3, */*,text/html;q=1, text/html;level=1,text/html;level=2;q=0.4, */*;q=0.5'; @@ -402,7 +391,7 @@ public function testPrioritizing() } } - public function testPrioritizing2() + public function testPrioritizing2(): void { $accept = Accept::fromString("Accept: application/text, \tapplication/*"); $res = $accept->getPrioritized(); @@ -438,7 +427,7 @@ public function testPrioritizing2() $this->assertEquals('application/vnd.foobar+xml; version="\'Ѿ"', $res[0]->getRaw()); } - public function testWildcardDefaults() + public function testWildcardDefaults(): void { $this->markTestIncomplete('No wildcard defaults implemented yet'); @@ -459,16 +448,15 @@ public function testWildcardDefaults() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Accept::fromString("Accept: application/text\r\n\r\nevilContent"); } - public function testGetEmptyFieldValue() + public function testGetEmptyFieldValue(): void { $accept = new Accept(); $accept->getFieldValue(); diff --git a/test/Header/AgeTest.php b/test/Header/AgeTest.php index c33816f1..229b64cd 100644 --- a/test/Header/AgeTest.php +++ b/test/Header/AgeTest.php @@ -7,13 +7,14 @@ use Laminas\Http\Header\Age; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use const PHP_INT_MAX; class AgeTest extends TestCase { - public function testAgeFromStringCreatesValidAgeHeader() + public function testAgeFromStringCreatesValidAgeHeader(): void { $ageHeader = Age::fromString('Age: 12'); $this->assertInstanceOf(HeaderInterface::class, $ageHeader); @@ -21,27 +22,27 @@ public function testAgeFromStringCreatesValidAgeHeader() $this->assertEquals('12', $ageHeader->getDeltaSeconds()); } - public function testAgeGetFieldNameReturnsHeaderName() + public function testAgeGetFieldNameReturnsHeaderName(): void { $ageHeader = new Age(); $this->assertEquals('Age', $ageHeader->getFieldName()); } - public function testAgeGetFieldValueReturnsProperValue() + public function testAgeGetFieldValueReturnsProperValue(): void { $ageHeader = new Age(); $ageHeader->setDeltaSeconds('12'); $this->assertEquals('12', $ageHeader->getFieldValue()); } - public function testAgeToStringReturnsHeaderFormattedString() + public function testAgeToStringReturnsHeaderFormattedString(): void { $ageHeader = new Age(); $ageHeader->setDeltaSeconds('12'); $this->assertEquals('Age: 12', $ageHeader->toString()); } - public function testAgeCorrectsDeltaSecondsOverflow() + public function testAgeCorrectsDeltaSecondsOverflow(): void { $ageHeader = new Age(); $ageHeader->setDeltaSeconds(PHP_INT_MAX); @@ -50,10 +51,9 @@ public function testAgeCorrectsDeltaSecondsOverflow() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); $header = Age::fromString("Age: 100\r\n\r\nevilContent"); @@ -61,10 +61,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); $header = new Age("100\r\n\r\nevilContent"); diff --git a/test/Header/AllowTest.php b/test/Header/AllowTest.php index 306362da..88765bf1 100644 --- a/test/Header/AllowTest.php +++ b/test/Header/AllowTest.php @@ -7,11 +7,13 @@ use Laminas\Http\Header\Allow; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class AllowTest extends TestCase { - public function testAllowFromStringCreatesValidAllowHeader() + public function testAllowFromStringCreatesValidAllowHeader(): void { $allowHeader = Allow::fromString('Allow: GET, POST, PUT'); $this->assertInstanceOf(HeaderInterface::class, $allowHeader); @@ -19,25 +21,25 @@ public function testAllowFromStringCreatesValidAllowHeader() $this->assertEquals(['GET', 'POST', 'PUT'], $allowHeader->getAllowedMethods()); } - public function testAllowFromStringSupportsExtensionMethods() + public function testAllowFromStringSupportsExtensionMethods(): void { $allowHeader = Allow::fromString('Allow: GET, POST, PROCREATE'); $this->assertTrue($allowHeader->isAllowedMethod('PROCREATE')); } - public function testAllowFromStringWithNonPostMethod() + public function testAllowFromStringWithNonPostMethod(): void { $allowHeader = Allow::fromString('Allow: GET'); $this->assertEquals('GET', $allowHeader->getFieldValue()); } - public function testAllowGetFieldNameReturnsHeaderName() + public function testAllowGetFieldNameReturnsHeaderName(): void { $allowHeader = new Allow(); $this->assertEquals('Allow', $allowHeader->getFieldName()); } - public function testAllowListAllDefinedMethods() + public function testAllowListAllDefinedMethods(): void { $methods = [ 'OPTIONS' => false, @@ -54,27 +56,27 @@ public function testAllowListAllDefinedMethods() $this->assertEquals($methods, $allowHeader->getAllMethods()); } - public function testAllowGetDefaultAllowedMethods() + public function testAllowGetDefaultAllowedMethods(): void { $allowHeader = new Allow(); $this->assertEquals(['GET', 'POST'], $allowHeader->getAllowedMethods()); } - public function testAllowGetFieldValueReturnsProperValue() + public function testAllowGetFieldValueReturnsProperValue(): void { $allowHeader = new Allow(); $allowHeader->allowMethods(['GET', 'POST', 'TRACE']); $this->assertEquals('GET, POST, TRACE', $allowHeader->getFieldValue()); } - public function testAllowToStringReturnsHeaderFormattedString() + public function testAllowToStringReturnsHeaderFormattedString(): void { $allowHeader = new Allow(); $allowHeader->allowMethods(['GET', 'POST', 'TRACE']); $this->assertEquals('Allow: GET, POST, TRACE', $allowHeader->toString()); } - public function testAllowChecksAllowedMethod() + public function testAllowChecksAllowedMethod(): void { $allowHeader = new Allow(); $allowHeader->allowMethods(['GET', 'POST', 'TRACE']); @@ -83,10 +85,9 @@ public function testAllowChecksAllowedMethod() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid header value detected'); @@ -95,7 +96,7 @@ public function testPreventsCRLFAttackViaFromString() } /** @psalm-return array */ - public function injectionMethods(): array + public static function injectionMethods(): array { return [ 'string' => ["\rG\r\nE\nT"], @@ -105,12 +106,10 @@ public function injectionMethods(): array /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 - * @dataProvider injectionMethods - * @param array|string $methods */ - public function testPreventsCRLFAttackViaAllowMethods($methods) + #[DataProvider('injectionMethods')] + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaAllowMethods(array|string $methods): void { $header = new Allow(); $this->expectException(InvalidArgumentException::class); @@ -121,12 +120,10 @@ public function testPreventsCRLFAttackViaAllowMethods($methods) /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 - * @dataProvider injectionMethods - * @param array|string $methods */ - public function testPreventsCRLFAttackViaDisallowMethods($methods) + #[DataProvider('injectionMethods')] + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaDisallowMethods(array|string $methods): void { $header = new Allow(); $this->expectException(InvalidArgumentException::class); diff --git a/test/Header/AuthenticationInfoTest.php b/test/Header/AuthenticationInfoTest.php index 346e8d3c..62662452 100644 --- a/test/Header/AuthenticationInfoTest.php +++ b/test/Header/AuthenticationInfoTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\AuthenticationInfo; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class AuthenticationInfoTest extends TestCase { - public function testAuthenticationInfoFromStringCreatesValidAuthenticationInfoHeader() + public function testAuthenticationInfoFromStringCreatesValidAuthenticationInfoHeader(): void { $authenticationInfoHeader = AuthenticationInfo::fromString('Authentication-Info: xxx'); $this->assertInstanceOf(HeaderInterface::class, $authenticationInfoHeader); $this->assertInstanceOf(AuthenticationInfo::class, $authenticationInfoHeader); } - public function testAuthenticationInfoGetFieldNameReturnsHeaderName() + public function testAuthenticationInfoGetFieldNameReturnsHeaderName(): void { $authenticationInfoHeader = new AuthenticationInfo(); $this->assertEquals('Authentication-Info', $authenticationInfoHeader->getFieldName()); } - public function testAuthenticationInfoGetFieldValueReturnsProperValue() + public function testAuthenticationInfoGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('AuthenticationInfo needs to be completed'); @@ -32,7 +33,7 @@ public function testAuthenticationInfoGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $authenticationInfoHeader->getFieldValue()); } - public function testAuthenticationInfoToStringReturnsHeaderFormattedString() + public function testAuthenticationInfoToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('AuthenticationInfo needs to be completed'); @@ -43,13 +44,11 @@ public function testAuthenticationInfoToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); $header = AuthenticationInfo::fromString("Authentication-Info: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new AuthenticationInfo("xxx\r\n\r\nevilContent"); diff --git a/test/Header/AuthorizationTest.php b/test/Header/AuthorizationTest.php index 55a248d8..561424ea 100644 --- a/test/Header/AuthorizationTest.php +++ b/test/Header/AuthorizationTest.php @@ -7,30 +7,31 @@ use Laminas\Http\Header\Authorization; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class AuthorizationTest extends TestCase { - public function testAuthorizationFromStringCreatesValidAuthorizationHeader() + public function testAuthorizationFromStringCreatesValidAuthorizationHeader(): void { $authorizationHeader = Authorization::fromString('Authorization: xxx'); $this->assertInstanceOf(HeaderInterface::class, $authorizationHeader); $this->assertInstanceOf(Authorization::class, $authorizationHeader); } - public function testAuthorizationGetFieldNameReturnsHeaderName() + public function testAuthorizationGetFieldNameReturnsHeaderName(): void { $authorizationHeader = new Authorization(); $this->assertEquals('Authorization', $authorizationHeader->getFieldName()); } - public function testAuthorizationGetFieldValueReturnsProperValue() + public function testAuthorizationGetFieldValueReturnsProperValue(): void { $authorizationHeader = new Authorization('xxx'); $this->assertEquals('xxx', $authorizationHeader->getFieldValue()); } - public function testAuthorizationToStringReturnsHeaderFormattedString() + public function testAuthorizationToStringReturnsHeaderFormattedString(): void { $authorizationHeader = new Authorization('xxx'); $this->assertEquals('Authorization: xxx', $authorizationHeader->toString()); @@ -40,13 +41,11 @@ public function testAuthorizationToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); $header = Authorization::fromString("Authorization: xxx\r\n\r\nevilContent"); @@ -54,10 +53,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Authorization("xxx\r\n\r\nevilContent"); diff --git a/test/Header/CacheControlTest.php b/test/Header/CacheControlTest.php index 662fce19..dd3591eb 100644 --- a/test/Header/CacheControlTest.php +++ b/test/Header/CacheControlTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\CacheControl; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class CacheControlTest extends TestCase { - public function testCacheControlFromStringCreatesValidCacheControlHeader() + public function testCacheControlFromStringCreatesValidCacheControlHeader(): void { $cacheControlHeader = CacheControl::fromString('Cache-Control: xxx'); $this->assertInstanceOf(HeaderInterface::class, $cacheControlHeader); $this->assertInstanceOf(CacheControl::class, $cacheControlHeader); } - public function testCacheControlGetFieldNameReturnsHeaderName() + public function testCacheControlGetFieldNameReturnsHeaderName(): void { $cacheControlHeader = new CacheControl(); $this->assertEquals('Cache-Control', $cacheControlHeader->getFieldName()); } - public function testCacheControlGetFieldValueReturnsProperValue() + public function testCacheControlGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('CacheControl needs to be completed'); @@ -32,7 +33,7 @@ public function testCacheControlGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $cacheControlHeader->getFieldValue()); } - public function testCacheControlToStringReturnsHeaderFormattedString() + public function testCacheControlToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('CacheControl needs to be completed'); @@ -45,7 +46,7 @@ public function testCacheControlToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testCacheControlIsEmpty() + public function testCacheControlIsEmpty(): void { $cacheControlHeader = new CacheControl(); $this->assertTrue($cacheControlHeader->isEmpty()); @@ -55,7 +56,7 @@ public function testCacheControlIsEmpty() $this->assertTrue($cacheControlHeader->isEmpty()); } - public function testCacheControlAddHasGetRemove() + public function testCacheControlAddHasGetRemove(): void { $cacheControlHeader = new CacheControl(); $cacheControlHeader->addDirective('xxx'); @@ -73,7 +74,7 @@ public function testCacheControlAddHasGetRemove() $this->assertNull($cacheControlHeader->getDirective('xxx')); } - public function testCacheControlGetFieldValue() + public function testCacheControlGetFieldValue(): void { $cacheControlHeader = new CacheControl(); $this->assertEmpty($cacheControlHeader->getFieldValue()); @@ -87,7 +88,7 @@ public function testCacheControlGetFieldValue() $this->assertEquals('aaa, xxx, yyy=foo, zzz="bar, baz"', $cacheControlHeader->getFieldValue()); } - public function testCacheControlParse() + public function testCacheControlParse(): void { $cacheControlHeader = CacheControl::fromString('Cache-Control: a, b=foo, c="bar, baz"'); $this->assertTrue($cacheControlHeader->hasDirective('a')); @@ -100,10 +101,9 @@ public function testCacheControlParse() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); CacheControl::fromString("Cache-Control: xxx\r\n\r\n"); @@ -111,10 +111,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testProtectsFromCRLFAttackViaSetters() + #[Group('ZF2015-04')] + public function testProtectsFromCRLFAttackViaSetters(): void { $header = new CacheControl(); $this->expectException(InvalidArgumentException::class); diff --git a/test/Header/ConnectionTest.php b/test/Header/ConnectionTest.php index 036dd493..70c862c6 100644 --- a/test/Header/ConnectionTest.php +++ b/test/Header/ConnectionTest.php @@ -7,11 +7,12 @@ use Laminas\Http\Header\Connection; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ConnectionTest extends TestCase { - public function testConnectionFromStringCreatesValidConnectionHeader() + public function testConnectionFromStringCreatesValidConnectionHeader(): void { $connectionHeader = Connection::fromString('Connection: close'); $this->assertInstanceOf(HeaderInterface::class, $connectionHeader); @@ -20,20 +21,20 @@ public function testConnectionFromStringCreatesValidConnectionHeader() $this->assertFalse($connectionHeader->isPersistent()); } - public function testConnectionGetFieldNameReturnsHeaderName() + public function testConnectionGetFieldNameReturnsHeaderName(): void { $connectionHeader = new Connection(); $this->assertEquals('Connection', $connectionHeader->getFieldName()); } - public function testConnectionGetFieldValueReturnsProperValue() + public function testConnectionGetFieldValueReturnsProperValue(): void { $connectionHeader = new Connection(); $connectionHeader->setValue('Keep-Alive'); $this->assertEquals('keep-alive', $connectionHeader->getFieldValue()); } - public function testConnectionToStringReturnsHeaderFormattedString() + public function testConnectionToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Connection needs to be completed'); @@ -42,7 +43,7 @@ public function testConnectionToStringReturnsHeaderFormattedString() $this->assertEmpty('Connection: close', $connectionHeader->toString()); } - public function testConnectionSetPersistentReturnsProperValue() + public function testConnectionSetPersistentReturnsProperValue(): void { $connectionHeader = new Connection(); $connectionHeader->setPersistent(true); @@ -53,10 +54,9 @@ public function testConnectionSetPersistentReturnsProperValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Connection::fromString("Connection: close\r\n\r\nevilContent"); @@ -64,10 +64,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaSetters() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaSetters(): void { $header = new Connection(); $this->expectException(InvalidArgumentException::class); diff --git a/test/Header/ContentDispositionTest.php b/test/Header/ContentDispositionTest.php index 45c5c006..cec18268 100644 --- a/test/Header/ContentDispositionTest.php +++ b/test/Header/ContentDispositionTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\ContentDisposition; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ContentDispositionTest extends TestCase { - public function testContentDispositionFromStringCreatesValidContentDispositionHeader() + public function testContentDispositionFromStringCreatesValidContentDispositionHeader(): void { $contentDispositionHeader = ContentDisposition::fromString('Content-Disposition: xxx'); $this->assertInstanceOf(HeaderInterface::class, $contentDispositionHeader); $this->assertInstanceOf(ContentDisposition::class, $contentDispositionHeader); } - public function testContentDispositionGetFieldNameReturnsHeaderName() + public function testContentDispositionGetFieldNameReturnsHeaderName(): void { $contentDispositionHeader = new ContentDisposition(); $this->assertEquals('Content-Disposition', $contentDispositionHeader->getFieldName()); } - public function testContentDispositionGetFieldValueReturnsProperValue() + public function testContentDispositionGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ContentDisposition needs to be completed'); @@ -32,7 +33,7 @@ public function testContentDispositionGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $contentDispositionHeader->getFieldValue()); } - public function testContentDispositionToStringReturnsHeaderFormattedString() + public function testContentDispositionToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ContentDisposition needs to be completed'); @@ -43,13 +44,11 @@ public function testContentDispositionToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentDisposition::fromString("Content-Disposition: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ContentDisposition("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ContentEncodingTest.php b/test/Header/ContentEncodingTest.php index 10f44fae..c7470b6e 100644 --- a/test/Header/ContentEncodingTest.php +++ b/test/Header/ContentEncodingTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\ContentEncoding; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ContentEncodingTest extends TestCase { - public function testContentEncodingFromStringCreatesValidContentEncodingHeader() + public function testContentEncodingFromStringCreatesValidContentEncodingHeader(): void { $contentEncodingHeader = ContentEncoding::fromString('Content-Encoding: xxx'); $this->assertInstanceOf(HeaderInterface::class, $contentEncodingHeader); $this->assertInstanceOf(ContentEncoding::class, $contentEncodingHeader); } - public function testContentEncodingGetFieldNameReturnsHeaderName() + public function testContentEncodingGetFieldNameReturnsHeaderName(): void { $contentEncodingHeader = new ContentEncoding(); $this->assertEquals('Content-Encoding', $contentEncodingHeader->getFieldName()); } - public function testContentEncodingGetFieldValueReturnsProperValue() + public function testContentEncodingGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ContentEncoding needs to be completed'); @@ -32,7 +33,7 @@ public function testContentEncodingGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $contentEncodingHeader->getFieldValue()); } - public function testContentEncodingToStringReturnsHeaderFormattedString() + public function testContentEncodingToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ContentEncoding needs to be completed'); @@ -43,13 +44,11 @@ public function testContentEncodingToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentEncoding::fromString("Content-Encoding: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ContentEncoding("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ContentLanguageTest.php b/test/Header/ContentLanguageTest.php index 9a2136ba..91cc3fcd 100644 --- a/test/Header/ContentLanguageTest.php +++ b/test/Header/ContentLanguageTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\ContentLanguage; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ContentLanguageTest extends TestCase { - public function testContentLanguageFromStringCreatesValidContentLanguageHeader() + public function testContentLanguageFromStringCreatesValidContentLanguageHeader(): void { $contentLanguageHeader = ContentLanguage::fromString('Content-Language: xxx'); $this->assertInstanceOf(HeaderInterface::class, $contentLanguageHeader); $this->assertInstanceOf(ContentLanguage::class, $contentLanguageHeader); } - public function testContentLanguageGetFieldNameReturnsHeaderName() + public function testContentLanguageGetFieldNameReturnsHeaderName(): void { $contentLanguageHeader = new ContentLanguage(); $this->assertEquals('Content-Language', $contentLanguageHeader->getFieldName()); } - public function testContentLanguageGetFieldValueReturnsProperValue() + public function testContentLanguageGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ContentLanguage needs to be completed'); @@ -32,7 +33,7 @@ public function testContentLanguageGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $contentLanguageHeader->getFieldValue()); } - public function testContentLanguageToStringReturnsHeaderFormattedString() + public function testContentLanguageToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ContentLanguage needs to be completed'); @@ -43,13 +44,11 @@ public function testContentLanguageToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentLanguage::fromString("Content-Language: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ContentLanguage("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ContentLengthTest.php b/test/Header/ContentLengthTest.php index 1cec1a15..6dbae733 100644 --- a/test/Header/ContentLengthTest.php +++ b/test/Header/ContentLengthTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\ContentLength; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ContentLengthTest extends TestCase { - public function testContentLengthFromStringCreatesValidContentLengthHeader() + public function testContentLengthFromStringCreatesValidContentLengthHeader(): void { $contentLengthHeader = ContentLength::fromString('Content-Length: xxx'); $this->assertInstanceOf(HeaderInterface::class, $contentLengthHeader); $this->assertInstanceOf(ContentLength::class, $contentLengthHeader); } - public function testContentLengthGetFieldNameReturnsHeaderName() + public function testContentLengthGetFieldNameReturnsHeaderName(): void { $contentLengthHeader = new ContentLength(); $this->assertEquals('Content-Length', $contentLengthHeader->getFieldName()); } - public function testContentLengthGetFieldValueReturnsProperValue() + public function testContentLengthGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ContentLength needs to be completed'); @@ -32,7 +33,7 @@ public function testContentLengthGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $contentLengthHeader->getFieldValue()); } - public function testContentLengthToStringReturnsHeaderFormattedString() + public function testContentLengthToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ContentLength needs to be completed'); @@ -43,13 +44,11 @@ public function testContentLengthToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentLength::fromString("Content-Length: xxx\r\n\r\nevilContent"); @@ -57,16 +56,15 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ContentLength("Content-Length: xxx\r\n\r\nevilContent"); } - public function testZeroValue() + public function testZeroValue(): void { $contentLengthHeader = new ContentLength(0); $this->assertEquals(0, $contentLengthHeader->getFieldValue()); diff --git a/test/Header/ContentLocationTest.php b/test/Header/ContentLocationTest.php index b4d84767..d69f84ac 100644 --- a/test/Header/ContentLocationTest.php +++ b/test/Header/ContentLocationTest.php @@ -8,18 +8,19 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Uri\UriInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ContentLocationTest extends TestCase { - public function testContentLocationFromStringCreatesValidLocationHeader() + public function testContentLocationFromStringCreatesValidLocationHeader(): void { $contentLocationHeader = ContentLocation::fromString('Content-Location: http://www.example.com/'); $this->assertInstanceOf(HeaderInterface::class, $contentLocationHeader); $this->assertInstanceOf(ContentLocation::class, $contentLocationHeader); } - public function testContentLocationGetFieldValueReturnsProperValue() + public function testContentLocationGetFieldValueReturnsProperValue(): void { $contentLocationHeader = new ContentLocation(); $contentLocationHeader->setUri('http://www.example.com/'); @@ -29,7 +30,7 @@ public function testContentLocationGetFieldValueReturnsProperValue() $this->assertEquals('/path', $contentLocationHeader->getFieldValue()); } - public function testContentLocationToStringReturnsHeaderFormattedString() + public function testContentLocationToStringReturnsHeaderFormattedString(): void { $contentLocationHeader = new ContentLocation(); $contentLocationHeader->setUri('http://www.example.com/path?query'); @@ -40,7 +41,7 @@ public function testContentLocationToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testContentLocationCanSetAndAccessAbsoluteUri() + public function testContentLocationCanSetAndAccessAbsoluteUri(): void { $contentLocationHeader = ContentLocation::fromString('Content-Location: http://www.example.com/path'); $uri = $contentLocationHeader->uri(); @@ -49,7 +50,7 @@ public function testContentLocationCanSetAndAccessAbsoluteUri() $this->assertEquals('http://www.example.com/path', $contentLocationHeader->getUri()); } - public function testContentLocationCanSetAndAccessRelativeUri() + public function testContentLocationCanSetAndAccessRelativeUri(): void { $contentLocationHeader = ContentLocation::fromString('Content-Location: /path/to'); $uri = $contentLocationHeader->uri(); @@ -60,10 +61,9 @@ public function testContentLocationCanSetAndAccessRelativeUri() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentLocation::fromString("Content-Location: /path/to\r\n\r\nevilContent"); diff --git a/test/Header/ContentMD5Test.php b/test/Header/ContentMD5Test.php index 02bd681f..9a4cc864 100644 --- a/test/Header/ContentMD5Test.php +++ b/test/Header/ContentMD5Test.php @@ -5,24 +5,25 @@ use Laminas\Http\Header\ContentMD5; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ContentMD5Test extends TestCase { - public function testContentMD5FromStringCreatesValidContentMD5Header() + public function testContentMD5FromStringCreatesValidContentMD5Header(): void { $contentMD5Header = ContentMD5::fromString('Content-MD5: xxx'); $this->assertInstanceOf(HeaderInterface::class, $contentMD5Header); $this->assertInstanceOf(ContentMD5::class, $contentMD5Header); } - public function testContentMD5GetFieldNameReturnsHeaderName() + public function testContentMD5GetFieldNameReturnsHeaderName(): void { $contentMD5Header = new ContentMD5(); $this->assertEquals('Content-MD5', $contentMD5Header->getFieldName()); } - public function testContentMD5GetFieldValueReturnsProperValue() + public function testContentMD5GetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ContentMD5 needs to be completed'); @@ -30,7 +31,7 @@ public function testContentMD5GetFieldValueReturnsProperValue() $this->assertEquals('xxx', $contentMD5Header->getFieldValue()); } - public function testContentMD5ToStringReturnsHeaderFormattedString() + public function testContentMD5ToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ContentMD5 needs to be completed'); @@ -41,13 +42,11 @@ public function testContentMD5ToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentMD5::fromString("Content-MD5: xxx\r\n\r\nevilContent"); @@ -55,10 +54,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ContentMD5("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ContentRangeTest.php b/test/Header/ContentRangeTest.php index 2951e498..76411877 100644 --- a/test/Header/ContentRangeTest.php +++ b/test/Header/ContentRangeTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\ContentRange; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ContentRangeTest extends TestCase { - public function testContentRangeFromStringCreatesValidContentRangeHeader() + public function testContentRangeFromStringCreatesValidContentRangeHeader(): void { $contentRangeHeader = ContentRange::fromString('Content-Range: xxx'); $this->assertInstanceOf(HeaderInterface::class, $contentRangeHeader); $this->assertInstanceOf(ContentRange::class, $contentRangeHeader); } - public function testContentRangeGetFieldNameReturnsHeaderName() + public function testContentRangeGetFieldNameReturnsHeaderName(): void { $contentRangeHeader = new ContentRange(); $this->assertEquals('Content-Range', $contentRangeHeader->getFieldName()); } - public function testContentRangeGetFieldValueReturnsProperValue() + public function testContentRangeGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ContentRange needs to be completed'); @@ -32,7 +33,7 @@ public function testContentRangeGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $contentRangeHeader->getFieldValue()); } - public function testContentRangeToStringReturnsHeaderFormattedString() + public function testContentRangeToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ContentRange needs to be completed'); @@ -43,13 +44,11 @@ public function testContentRangeToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentRange::fromString("Content-Range: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ContentRange("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ContentSecurityPolicyReportOnlyTest.php b/test/Header/ContentSecurityPolicyReportOnlyTest.php index 66caf73f..70ee7a27 100644 --- a/test/Header/ContentSecurityPolicyReportOnlyTest.php +++ b/test/Header/ContentSecurityPolicyReportOnlyTest.php @@ -9,7 +9,7 @@ class ContentSecurityPolicyReportOnlyTest extends TestCase { - public function testContentSecurityPolicyReportOnlyToString() + public function testContentSecurityPolicyReportOnlyToString(): void { $csp = ContentSecurityPolicyReportOnly::fromString( "Content-Security-Policy-Report-Only: default-src 'none'; img-src 'self' https://*.gravatar.com;" diff --git a/test/Header/ContentSecurityPolicyTest.php b/test/Header/ContentSecurityPolicyTest.php index 4576e116..5c3caa86 100644 --- a/test/Header/ContentSecurityPolicyTest.php +++ b/test/Header/ContentSecurityPolicyTest.php @@ -11,19 +11,21 @@ use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\MultipleHeaderInterface; use Laminas\Http\Headers; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function implode; class ContentSecurityPolicyTest extends TestCase { - public function testContentSecurityPolicyFromStringThrowsExceptionIfImproperHeaderNameUsed() + public function testContentSecurityPolicyFromStringThrowsExceptionIfImproperHeaderNameUsed(): void { $this->expectException(InvalidArgumentException::class); ContentSecurityPolicy::fromString('X-Content-Security-Policy: default-src *;'); } - public function testContentSecurityPolicyFromStringParsesDirectivesCorrectly() + public function testContentSecurityPolicyFromStringParsesDirectivesCorrectly(): void { $csp = ContentSecurityPolicy::fromString( "Content-Security-Policy: default-src 'none'; script-src 'self'; img-src 'self'; style-src 'self';" @@ -40,13 +42,13 @@ public function testContentSecurityPolicyFromStringParsesDirectivesCorrectly() $this->assertEquals($directives, $csp->getDirectives()); } - public function testContentSecurityPolicyGetFieldNameReturnsHeaderName() + public function testContentSecurityPolicyGetFieldNameReturnsHeaderName(): void { $csp = new ContentSecurityPolicy(); $this->assertEquals('Content-Security-Policy', $csp->getFieldName()); } - public function testContentSecurityPolicyToStringReturnsHeaderFormattedString() + public function testContentSecurityPolicyToStringReturnsHeaderFormattedString(): void { $csp = ContentSecurityPolicy::fromString( "Content-Security-Policy: default-src 'none'; img-src 'self' https://*.gravatar.com;" @@ -59,7 +61,7 @@ public function testContentSecurityPolicyToStringReturnsHeaderFormattedString() ); } - public function testContentSecurityPolicySetDirective() + public function testContentSecurityPolicySetDirective(): void { $csp = new ContentSecurityPolicy(); $csp->setDirective('default-src', ['https://*.google.com', 'http://foo.com']) @@ -70,7 +72,7 @@ public function testContentSecurityPolicySetDirective() $this->assertEquals($header, $csp->toString()); } - public function testContentSecurityPolicySetDirectiveWithEmptySourcesDefaultsToNone() + public function testContentSecurityPolicySetDirectiveWithEmptySourcesDefaultsToNone(): void { $csp = new ContentSecurityPolicy(); $csp->setDirective('default-src', ["'self'"]) @@ -82,14 +84,14 @@ public function testContentSecurityPolicySetDirectiveWithEmptySourcesDefaultsToN ); } - public function testContentSecurityPolicySetDirectiveThrowsExceptionIfInvalidDirectiveNameGiven() + public function testContentSecurityPolicySetDirectiveThrowsExceptionIfInvalidDirectiveNameGiven(): void { $this->expectException(InvalidArgumentException::class); $csp = new ContentSecurityPolicy(); $csp->setDirective('foo', []); } - public function testContentSecurityPolicyGetFieldValueReturnsProperValue() + public function testContentSecurityPolicyGetFieldValueReturnsProperValue(): void { $csp = new ContentSecurityPolicy(); $csp->setDirective('default-src', ["'self'"]) @@ -99,10 +101,9 @@ public function testContentSecurityPolicyGetFieldValueReturnsProperValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentSecurityPolicy::fromString("Content-Security-Policy: default-src 'none'\r\n\r\nevilContent"); @@ -110,17 +111,16 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaDirective() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaDirective(): void { $header = new ContentSecurityPolicy(); $this->expectException(InvalidArgumentException::class); $header->setDirective('default-src', ["\rsome\r\nCRLF\ninjection"]); } - public function testContentSecurityPolicySetDirectiveWithEmptyReportUriDefaultsToUnset() + public function testContentSecurityPolicySetDirectiveWithEmptyReportUriDefaultsToUnset(): void { $csp = new ContentSecurityPolicy(); $csp->setDirective('report-uri', []); @@ -130,7 +130,7 @@ public function testContentSecurityPolicySetDirectiveWithEmptyReportUriDefaultsT ); } - public function testContentSecurityPolicySetDirectiveWithEmptyReportUriRemovesExistingValue() + public function testContentSecurityPolicySetDirectiveWithEmptyReportUriRemovesExistingValue(): void { $csp = new ContentSecurityPolicy(); $csp->setDirective('report-uri', ['csp-error']); @@ -146,7 +146,7 @@ public function testContentSecurityPolicySetDirectiveWithEmptyReportUriRemovesEx ); } - public function testToStringMultipleHeaders() + public function testToStringMultipleHeaders(): void { $csp = new ContentSecurityPolicy(); $csp->setDirective('default-src', ["'self'"]); @@ -161,7 +161,7 @@ public function testToStringMultipleHeaders() ); } - public function testToStringMultipleHeadersExceptionIfDifferent() + public function testToStringMultipleHeadersExceptionIfDifferent(): void { $csp = new ContentSecurityPolicy(); $csp->setDirective('default-src', ["'self'"]); @@ -176,7 +176,7 @@ public function testToStringMultipleHeadersExceptionIfDifferent() $csp->toStringMultipleHeaders([$additional]); } - public function testMultiple() + public function testMultiple(): void { $headers = new Headers(); $headers->addHeader((new ContentSecurityPolicy())->setDirective('default-src', ["'self'"])); @@ -226,16 +226,14 @@ public static function validDirectives(): array } /** - * @dataProvider validDirectives - * @param string $directive * @param string[] $values - * @param string $expected */ + #[DataProvider('validDirectives')] public function testContentSecurityPolicySetDirectiveThrowsExceptionIfMissingDirectiveNameGiven( - $directive, + string $directive, array $values, - $expected - ) { + string $expected + ): void { $csp = new ContentSecurityPolicy(); $csp->setDirective($directive, $values); @@ -243,12 +241,10 @@ public function testContentSecurityPolicySetDirectiveThrowsExceptionIfMissingDir } /** - * @dataProvider validDirectives - * @param string $directive * @param string[] $values - * @param string $header */ - public function testFromString($directive, array $values, $header) + #[DataProvider('validDirectives')] + public function testFromString(string $directive, array $values, string $header): void { $contentSecurityPolicy = ContentSecurityPolicy::fromString($header); @@ -256,20 +252,14 @@ public function testFromString($directive, array $values, $header) self::assertSame(implode(' ', $values), $contentSecurityPolicy->getDirectives()[$directive]); } - /** - * @return string - */ - public function directivesWithoutValue() + public static function directivesWithoutValue(): iterable { yield ['block-all-mixed-content']; yield ['upgrade-insecure-requests']; } - /** - * @dataProvider directivesWithoutValue - * @param string $directive - */ - public function testExceptionWhenProvideValueWithDirectiveWithoutValue($directive) + #[DataProvider('directivesWithoutValue')] + public function testExceptionWhenProvideValueWithDirectiveWithoutValue(string $directive): void { $csp = new ContentSecurityPolicy(); diff --git a/test/Header/ContentTransferEncodingTest.php b/test/Header/ContentTransferEncodingTest.php index 661556d5..2cbca5a0 100644 --- a/test/Header/ContentTransferEncodingTest.php +++ b/test/Header/ContentTransferEncodingTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\ContentTransferEncoding; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ContentTransferEncodingTest extends TestCase { - public function testContentTransferEncodingFromStringCreatesValidContentTransferEncodingHeader() + public function testContentTransferEncodingFromStringCreatesValidContentTransferEncodingHeader(): void { $contentTransferEncodingHeader = ContentTransferEncoding::fromString('Content-Transfer-Encoding: xxx'); $this->assertInstanceOf(HeaderInterface::class, $contentTransferEncodingHeader); $this->assertInstanceOf(ContentTransferEncoding::class, $contentTransferEncodingHeader); } - public function testContentTransferEncodingGetFieldNameReturnsHeaderName() + public function testContentTransferEncodingGetFieldNameReturnsHeaderName(): void { $contentTransferEncodingHeader = new ContentTransferEncoding(); $this->assertEquals('Content-Transfer-Encoding', $contentTransferEncodingHeader->getFieldName()); } - public function testContentTransferEncodingGetFieldValueReturnsProperValue() + public function testContentTransferEncodingGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ContentTransferEncoding needs to be completed'); @@ -32,7 +33,7 @@ public function testContentTransferEncodingGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $contentTransferEncodingHeader->getFieldValue()); } - public function testContentTransferEncodingToStringReturnsHeaderFormattedString() + public function testContentTransferEncodingToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ContentTransferEncoding needs to be completed'); @@ -43,13 +44,11 @@ public function testContentTransferEncodingToStringReturnsHeaderFormattedString( } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentTransferEncoding::fromString("Content-Transfer-Encoding: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ContentTransferEncoding("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ContentTypeTest.php b/test/Header/ContentTypeTest.php index 19f6b703..d34ea526 100644 --- a/test/Header/ContentTypeTest.php +++ b/test/Header/ContentTypeTest.php @@ -7,6 +7,8 @@ use Laminas\Http\Header\ContentType; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function implode; @@ -14,26 +16,26 @@ class ContentTypeTest extends TestCase { - public function testContentTypeFromStringCreatesValidContentTypeHeader() + public function testContentTypeFromStringCreatesValidContentTypeHeader(): void { $contentTypeHeader = ContentType::fromString('Content-Type: xxx'); $this->assertInstanceOf(HeaderInterface::class, $contentTypeHeader); $this->assertInstanceOf(ContentType::class, $contentTypeHeader); } - public function testContentTypeGetFieldNameReturnsHeaderName() + public function testContentTypeGetFieldNameReturnsHeaderName(): void { $contentTypeHeader = new ContentType(); $this->assertEquals('Content-Type', $contentTypeHeader->getFieldName()); } - public function testContentTypeGetFieldValueReturnsProperValue() + public function testContentTypeGetFieldValueReturnsProperValue(): void { $header = ContentType::fromString('Content-Type: application/json'); $this->assertEquals('application/json', $header->getFieldValue()); } - public function testContentTypeToStringReturnsHeaderFormattedString() + public function testContentTypeToStringReturnsHeaderFormattedString(): void { $header = new ContentType(); $header->setMediaType('application/atom+xml') @@ -45,7 +47,7 @@ public function testContentTypeToStringReturnsHeaderFormattedString() // Implementation specific tests here /** @psalm-return array */ - public function wildcardMatches(): array + public static function wildcardMatches(): array { return [ 'wildcard' => ['*/*'], @@ -63,11 +65,8 @@ public function wildcardMatches(): array ]; } - /** - * @dataProvider wildcardMatches - * @param string $matchAgainst - */ - public function testMatchWildCard($matchAgainst) + #[DataProvider('wildcardMatches')] + public function testMatchWildCard(string $matchAgainst): void { $header = ContentType::fromString('Content-Type: application/vnd.foobar+json'); $result = $header->match($matchAgainst); @@ -75,7 +74,7 @@ public function testMatchWildCard($matchAgainst) } /** @psalm-return array */ - public function invalidMatches(): array + public static function invalidMatches(): array { return [ 'format' => ['application/vnd.foobar+xml'], @@ -88,11 +87,8 @@ public function invalidMatches(): array ]; } - /** - * @dataProvider invalidMatches - * @param string $matchAgainst - */ - public function testFailedMatches($matchAgainst) + #[DataProvider('invalidMatches')] + public function testFailedMatches(string $matchAgainst): void { $header = ContentType::fromString('Content-Type: application/vnd.foobar+json'); $result = $header->match($matchAgainst); @@ -100,7 +96,7 @@ public function testFailedMatches($matchAgainst) } /** @psalm-return array */ - public function multipleCriteria(): array + public static function multipleCriteria(): array { $criteria = [ 'application/vnd.foobar+xml', @@ -114,11 +110,8 @@ public function multipleCriteria(): array ]; } - /** - * @dataProvider multipleCriteria - * @param array|string $criteria - */ - public function testReturnsMatchingMediaTypeOfFirstCriteriaToValidate($criteria) + #[DataProvider('multipleCriteria')] + public function testReturnsMatchingMediaTypeOfFirstCriteriaToValidate(array|string $criteria): void { $header = ContentType::fromString('Content-Type: application/vnd.foobar+json'); $result = $header->match($criteria); @@ -126,7 +119,7 @@ public function testReturnsMatchingMediaTypeOfFirstCriteriaToValidate($criteria) } /** @psalm-return array */ - public function contentTypeParameterExamples(): array + public static function contentTypeParameterExamples(): array { return [ 'no-quotes' => ['Content-Type: foo/bar; param=baz', 'baz'], @@ -136,12 +129,8 @@ public function contentTypeParameterExamples(): array ]; } - /** - * @dataProvider contentTypeParameterExamples - * @param string $headerString - * @param string $expectedParameterValue - */ - public function testContentTypeParsesParametersCorrectly($headerString, $expectedParameterValue) + #[DataProvider('contentTypeParameterExamples')] + public function testContentTypeParsesParametersCorrectly(string $headerString, string $expectedParameterValue): void { $contentTypeHeader = ContentType::fromString($headerString); @@ -153,10 +142,9 @@ public function testContentTypeParsesParametersCorrectly($headerString, $expecte /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ContentType::fromString("Content-Type: foo/bar;\r\n\r\nevilContent"); @@ -164,10 +152,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ContentType("foo/bar\r\n\r\nevilContent"); diff --git a/test/Header/CookieTest.php b/test/Header/CookieTest.php index a980ea81..fff9f5ba 100644 --- a/test/Header/CookieTest.php +++ b/test/Header/CookieTest.php @@ -9,17 +9,18 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\SetCookie; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; /** * Laminas_Http_Cookie unit tests - * - * @group Laminas_Http - * @group Laminas_Http_Cookie */ +#[Group('Laminas_Http')] +#[Group('Laminas_Http_Cookie')] class CookieTest extends TestCase { - public function testCookieFromStringCreatesValidCookieHeader() + public function testCookieFromStringCreatesValidCookieHeader(): void { $cookieHeader = Cookie::fromString('Cookie: name=value'); $this->assertInstanceOf(HeaderInterface::class, $cookieHeader); @@ -27,14 +28,14 @@ public function testCookieFromStringCreatesValidCookieHeader() $this->assertInstanceOf(Cookie::class, $cookieHeader); } - public function testCookieFromStringCreatesValidCookieHeadersWithMultipleValues() + public function testCookieFromStringCreatesValidCookieHeadersWithMultipleValues(): void { $cookieHeader = Cookie::fromString('Cookie: name=value; foo=bar'); $this->assertEquals('value', $cookieHeader->name); $this->assertEquals('bar', $cookieHeader['foo']); } - public function testCookieFromSetCookieArrayProducesASingleCookie() + public function testCookieFromSetCookieArrayProducesASingleCookie(): void { $setCookies = [ new SetCookie('foo', 'bar'), @@ -45,20 +46,20 @@ public function testCookieFromSetCookieArrayProducesASingleCookie() $this->assertEquals('Cookie: foo=bar; name=value', $cookie->toString()); } - public function testCookieGetFieldNameReturnsHeaderName() + public function testCookieGetFieldNameReturnsHeaderName(): void { $cookieHeader = new Cookie(); $this->assertEquals('Cookie', $cookieHeader->getFieldName()); } - public function testCookieGetFieldValueReturnsProperValue() + public function testCookieGetFieldValueReturnsProperValue(): void { $cookieHeader = new Cookie(); $cookieHeader->foo = 'bar'; $this->assertEquals('foo=bar', $cookieHeader->getFieldValue()); } - public function testCookieToStringReturnsHeaderFormattedString() + public function testCookieToStringReturnsHeaderFormattedString(): void { $cookieHeader = new Cookie(); @@ -68,10 +69,9 @@ public function testCookieToStringReturnsHeaderFormattedString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Cookie::fromString("Cookie: foo=bar\r\n\r\nevilContent"); @@ -79,20 +79,17 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 - * @dataProvider valuesProvider - * @param mixed $value - * @param string $serialized */ - public function testSerialization($value, $serialized) + #[DataProvider('valuesProvider')] + #[Group('ZF2015-04')] + public function testSerialization(mixed $value, string $serialized): void { $header = new Cookie([$value]); $this->assertEquals('Cookie: ' . $serialized, $header->toString()); } /** @psalm-return array */ - public function valuesProvider(): array + public static function valuesProvider(): array { return [ // Description => [raw value, serialized] diff --git a/test/Header/DateTest.php b/test/Header/DateTest.php index 866f585c..6444005c 100644 --- a/test/Header/DateTest.php +++ b/test/Header/DateTest.php @@ -9,6 +9,7 @@ use Laminas\Http\Header\Date; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function time; @@ -23,14 +24,14 @@ public function tearDown(): void Date::setDateFormat(Date::DATE_RFC1123); } - public function testDateFromStringCreatesValidDateHeader() + public function testDateFromStringCreatesValidDateHeader(): void { $dateHeader = Date::fromString('Date: Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertInstanceOf(HeaderInterface::class, $dateHeader); $this->assertInstanceOf(Date::class, $dateHeader); } - public function testDateFromTimeStringCreatesValidDateHeader() + public function testDateFromTimeStringCreatesValidDateHeader(): void { $dateHeader = Date::fromTimeString('+12 hours'); @@ -49,7 +50,7 @@ public function testDateFromTimeStringCreatesValidDateHeader() } } - public function testDateFromTimestampCreatesValidDateHeader() + public function testDateFromTimestampCreatesValidDateHeader(): void { $dateHeader = Date::fromTimestamp(time() + 12 * 60 * 60); @@ -68,32 +69,32 @@ public function testDateFromTimestampCreatesValidDateHeader() } } - public function testDateFromTimeStringDetectsBadInput() + public function testDateFromTimeStringDetectsBadInput(): void { $this->expectException(InvalidArgumentException::class); Date::fromTimeString('3 Days of the Condor'); } - public function testDateFromTimestampDetectsBadInput() + public function testDateFromTimestampDetectsBadInput(): void { $this->expectException(InvalidArgumentException::class); Date::fromTimestamp('The Day of the Jackal'); } - public function testDateGetFieldNameReturnsHeaderName() + public function testDateGetFieldNameReturnsHeaderName(): void { $dateHeader = new Date(); $this->assertEquals('Date', $dateHeader->getFieldName()); } - public function testDateGetFieldValueReturnsProperValue() + public function testDateGetFieldValueReturnsProperValue(): void { $dateHeader = new Date(); $dateHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertEquals('Sun, 06 Nov 1994 08:49:37 GMT', $dateHeader->getFieldValue()); } - public function testDateToStringReturnsHeaderFormattedString() + public function testDateToStringReturnsHeaderFormattedString(): void { $dateHeader = new Date(); $dateHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); @@ -103,20 +104,20 @@ public function testDateToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testDateReturnsDateTimeObject() + public function testDateReturnsDateTimeObject(): void { $dateHeader = new Date(); $this->assertInstanceOf(DateTime::class, $dateHeader->date()); } - public function testDateFromStringCreatesValidDateTime() + public function testDateFromStringCreatesValidDateTime(): void { $dateHeader = Date::fromString('Date: Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertInstanceOf(DateTime::class, $dateHeader->date()); $this->assertEquals('Sun, 06 Nov 1994 08:49:37 GMT', $dateHeader->date()->format('D, d M Y H:i:s \G\M\T')); } - public function testDateReturnsProperlyFormattedDate() + public function testDateReturnsProperlyFormattedDate(): void { $date = new DateTime('now', new DateTimeZone('GMT')); @@ -125,7 +126,7 @@ public function testDateReturnsProperlyFormattedDate() $this->assertEquals($date->format('D, d M Y H:i:s \G\M\T'), $dateHeader->getDate()); } - public function testDateThrowsExceptionForInvalidDate() + public function testDateThrowsExceptionForInvalidDate(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid date'); @@ -133,14 +134,14 @@ public function testDateThrowsExceptionForInvalidDate() $dateHeader->setDate('~~~~'); } - public function testDateCanCompareDates() + public function testDateCanCompareDates(): void { $dateHeader = new Date(); $dateHeader->setDate('1 day ago'); $this->assertEquals(-1, $dateHeader->compareTo(new DateTime('now'))); } - public function testDateCanOutputDatesInOldFormats() + public function testDateCanOutputDatesInOldFormats(): void { Date::setDateFormat(Date::DATE_ANSIC); @@ -152,10 +153,9 @@ public function testDateCanOutputDatesInOldFormats() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Date::fromString("Date: Sun, 06 Nov 1994 08:49:37 GMT\r\n\r\nevilContent"); diff --git a/test/Header/EtagTest.php b/test/Header/EtagTest.php index 1ad46f40..f9f0f568 100644 --- a/test/Header/EtagTest.php +++ b/test/Header/EtagTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Etag; use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class EtagTest extends TestCase { - public function testEtagFromStringCreatesValidEtagHeader() + public function testEtagFromStringCreatesValidEtagHeader(): void { $etagHeader = Etag::fromString('Etag: xxx'); $this->assertInstanceOf(HeaderInterface::class, $etagHeader); $this->assertInstanceOf(Etag::class, $etagHeader); } - public function testEtagGetFieldNameReturnsHeaderName() + public function testEtagGetFieldNameReturnsHeaderName(): void { $etagHeader = new Etag(); $this->assertEquals('Etag', $etagHeader->getFieldName()); } - public function testEtagGetFieldValueReturnsProperValue() + public function testEtagGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Etag needs to be completed'); @@ -32,7 +33,7 @@ public function testEtagGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $etagHeader->getFieldValue()); } - public function testEtagToStringReturnsHeaderFormattedString() + public function testEtagToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Etag needs to be completed'); @@ -43,13 +44,11 @@ public function testEtagToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Etag::fromString("Etag: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Etag("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ExpectTest.php b/test/Header/ExpectTest.php index ee3dcd63..40f668dd 100644 --- a/test/Header/ExpectTest.php +++ b/test/Header/ExpectTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\Expect; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ExpectTest extends TestCase { - public function testExpectFromStringCreatesValidExpectHeader() + public function testExpectFromStringCreatesValidExpectHeader(): void { $expectHeader = Expect::fromString('Expect: xxx'); $this->assertInstanceOf(HeaderInterface::class, $expectHeader); $this->assertInstanceOf(Expect::class, $expectHeader); } - public function testExpectGetFieldNameReturnsHeaderName() + public function testExpectGetFieldNameReturnsHeaderName(): void { $expectHeader = new Expect(); $this->assertEquals('Expect', $expectHeader->getFieldName()); } - public function testExpectGetFieldValueReturnsProperValue() + public function testExpectGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Expect needs to be completed'); @@ -32,7 +33,7 @@ public function testExpectGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $expectHeader->getFieldValue()); } - public function testExpectToStringReturnsHeaderFormattedString() + public function testExpectToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Expect needs to be completed'); @@ -43,13 +44,11 @@ public function testExpectToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Expect::fromString("Expect: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Expect("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ExpiresTest.php b/test/Header/ExpiresTest.php index 4e04f771..82910ad2 100644 --- a/test/Header/ExpiresTest.php +++ b/test/Header/ExpiresTest.php @@ -7,31 +7,32 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\Expires; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ExpiresTest extends TestCase { - public function testExpiresFromStringCreatesValidExpiresHeader() + public function testExpiresFromStringCreatesValidExpiresHeader(): void { $expiresHeader = Expires::fromString('Expires: Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertInstanceOf(HeaderInterface::class, $expiresHeader); $this->assertInstanceOf(Expires::class, $expiresHeader); } - public function testExpiresGetFieldNameReturnsHeaderName() + public function testExpiresGetFieldNameReturnsHeaderName(): void { $expiresHeader = new Expires(); $this->assertEquals('Expires', $expiresHeader->getFieldName()); } - public function testExpiresGetFieldValueReturnsProperValue() + public function testExpiresGetFieldValueReturnsProperValue(): void { $expiresHeader = new Expires(); $expiresHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertEquals('Sun, 06 Nov 1994 08:49:37 GMT', $expiresHeader->getFieldValue()); } - public function testExpiresToStringReturnsHeaderFormattedString() + public function testExpiresToStringReturnsHeaderFormattedString(): void { $expiresHeader = new Expires(); $expiresHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); @@ -43,19 +44,17 @@ public function testExpiresToStringReturnsHeaderFormattedString() * * @see LaminasTest\Http\Header\DateTest */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Expires::fromString("Expires: Sun, 06 Nov 1994 08:49:37 GMT\r\n\r\nevilContent"); } - public function testExpiresSetToZero() + public function testExpiresSetToZero(): void { $expires = Expires::fromString('Expires: 0'); $this->assertEquals('Expires: Thu, 01 Jan 1970 00:00:00 GMT', $expires->toString()); diff --git a/test/Header/FeaturePolicyTest.php b/test/Header/FeaturePolicyTest.php index 1190847e..ec49272e 100644 --- a/test/Header/FeaturePolicyTest.php +++ b/test/Header/FeaturePolicyTest.php @@ -7,17 +7,18 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\FeaturePolicy; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class FeaturePolicyTest extends TestCase { - public function testFeaturePolicyFromStringThrowsExceptionIfImproperHeaderNameUsed() + public function testFeaturePolicyFromStringThrowsExceptionIfImproperHeaderNameUsed(): void { $this->expectException(InvalidArgumentException::class); FeaturePolicy::fromString('X-Feature-Policy: geolocation \'none\';'); } - public function testFeaturePolicyFromStringParsesDirectivesCorrectly() + public function testFeaturePolicyFromStringParsesDirectivesCorrectly(): void { $header = FeaturePolicy::fromString( "Feature-Policy: geolocation 'none'; autoplay 'self'; microphone 'self';" @@ -32,13 +33,13 @@ public function testFeaturePolicyFromStringParsesDirectivesCorrectly() $this->assertEquals($directives, $header->getDirectives()); } - public function testFeaturePolicyGetFieldNameReturnsHeaderName() + public function testFeaturePolicyGetFieldNameReturnsHeaderName(): void { $header = new FeaturePolicy(); $this->assertEquals('Feature-Policy', $header->getFieldName()); } - public function testFeaturePolicyToStringReturnsHeaderFormattedString() + public function testFeaturePolicyToStringReturnsHeaderFormattedString(): void { $header = FeaturePolicy::fromString( "Feature-Policy: geolocation 'none'; autoplay 'self'; microphone 'self';" @@ -51,7 +52,7 @@ public function testFeaturePolicyToStringReturnsHeaderFormattedString() ); } - public function testFeaturePolicySetDirective() + public function testFeaturePolicySetDirective(): void { $fp = new FeaturePolicy(); $fp->setDirective('geolocation', ['https://*.google.com', 'http://foo.com']) @@ -62,7 +63,7 @@ public function testFeaturePolicySetDirective() $this->assertEquals($header, $fp->toString()); } - public function testFeaturePolicySetDirectiveWithEmptySourcesDefaultsToNone() + public function testFeaturePolicySetDirectiveWithEmptySourcesDefaultsToNone(): void { $header = new FeaturePolicy(); $header->setDirective('geolocation', ["'self'"]) @@ -74,14 +75,14 @@ public function testFeaturePolicySetDirectiveWithEmptySourcesDefaultsToNone() ); } - public function testFeaturePolicySetDirectiveThrowsExceptionIfInvalidDirectiveNameGiven() + public function testFeaturePolicySetDirectiveThrowsExceptionIfInvalidDirectiveNameGiven(): void { $this->expectException(InvalidArgumentException::class); $header = new FeaturePolicy(); $header->setDirective('foo', []); } - public function testFeaturePolicyGetFieldValueReturnsProperValue() + public function testFeaturePolicyGetFieldValueReturnsProperValue(): void { $header = new FeaturePolicy(); $header->setDirective('geolocation', ["'self'"]) @@ -91,10 +92,9 @@ public function testFeaturePolicyGetFieldValueReturnsProperValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); FeaturePolicy::fromString("Feature-Policy: default-src 'none'\r\n\r\nevilContent"); @@ -102,10 +102,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaDirective() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaDirective(): void { $header = new FeaturePolicy(); $this->expectException(InvalidArgumentException::class); diff --git a/test/Header/FromTest.php b/test/Header/FromTest.php index 1eaec50e..d54935a4 100644 --- a/test/Header/FromTest.php +++ b/test/Header/FromTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\From; use Laminas\Http\Header\HeaderInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class FromTest extends TestCase { - public function testFromFromStringCreatesValidFromHeader() + public function testFromFromStringCreatesValidFromHeader(): void { $fromHeader = From::fromString('From: xxx'); $this->assertInstanceOf(HeaderInterface::class, $fromHeader); $this->assertInstanceOf(From::class, $fromHeader); } - public function testFromGetFieldNameReturnsHeaderName() + public function testFromGetFieldNameReturnsHeaderName(): void { $fromHeader = new From(); $this->assertEquals('From', $fromHeader->getFieldName()); } - public function testFromGetFieldValueReturnsProperValue() + public function testFromGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('From needs to be completed'); @@ -32,7 +33,7 @@ public function testFromGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $fromHeader->getFieldValue()); } - public function testFromToStringReturnsHeaderFormattedString() + public function testFromToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('From needs to be completed'); @@ -43,13 +44,11 @@ public function testFromToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); From::fromString("From: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new From("xxx\r\n\r\nevilContent"); diff --git a/test/Header/GenericHeaderTest.php b/test/Header/GenericHeaderTest.php index bba30d50..e06f07b7 100644 --- a/test/Header/GenericHeaderTest.php +++ b/test/Header/GenericHeaderTest.php @@ -6,17 +6,16 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\GenericHeader; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function ord; class GenericHeaderTest extends TestCase { - /** - * @dataProvider validFieldNameChars - * @param string $name - */ - public function testValidFieldName($name) + #[DataProvider('validFieldNameChars')] + public function testValidFieldName(string $name): void { try { new GenericHeader($name); @@ -29,11 +28,8 @@ public function testValidFieldName($name) } } - /** - * @dataProvider invalidFieldNameChars - * @param string $name - */ - public function testInvalidFieldName($name) + #[DataProvider('invalidFieldNameChars')] + public function testInvalidFieldName(string $name): void { try { new GenericHeader($name); @@ -46,10 +42,8 @@ public function testInvalidFieldName($name) } } - /** - * @group ZF#7295 - */ - public function testDoesNotReplaceUnderscoresWithDashes() + #[Group('ZF#7295')] + public function testDoesNotReplaceUnderscoresWithDashes(): void { $header = new GenericHeader('X_Foo_Bar'); $this->assertEquals('X_Foo_Bar', $header->getFieldName()); @@ -57,10 +51,9 @@ public function testDoesNotReplaceUnderscoresWithDashes() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); GenericHeader::fromString("X_Foo_Bar: Bar\r\n\r\nevilContent"); @@ -68,10 +61,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new GenericHeader('X_Foo_Bar', "Bar\r\n\r\nevilContent"); @@ -79,10 +71,9 @@ public function testPreventsCRLFAttackViaConstructor() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testProtectsFromCRLFAttackViaSetFieldName() + #[Group('ZF2015-04')] + public function testProtectsFromCRLFAttackViaSetFieldName(): void { $header = new GenericHeader(); $this->expectException(InvalidArgumentException::class); @@ -92,10 +83,9 @@ public function testProtectsFromCRLFAttackViaSetFieldName() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testProtectsFromCRLFAttackViaSetFieldValue() + #[Group('ZF2015-04')] + public function testProtectsFromCRLFAttackViaSetFieldValue(): void { $header = new GenericHeader(); $this->expectException(InvalidArgumentException::class); @@ -107,7 +97,7 @@ public function testProtectsFromCRLFAttackViaSetFieldValue() * * @return string[] */ - public function validFieldNameChars() + public static function validFieldNameChars(): array { return [ ['!'], @@ -139,7 +129,7 @@ public function validFieldNameChars() * * @return string[] */ - public function invalidFieldNameChars() + public static function invalidFieldNameChars(): array { return [ ["\x00"], // Min CTL invalid character range. diff --git a/test/Header/HeaderValueTest.php b/test/Header/HeaderValueTest.php index f66efdb3..ea1aa786 100644 --- a/test/Header/HeaderValueTest.php +++ b/test/Header/HeaderValueTest.php @@ -6,6 +6,8 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderValue; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class HeaderValueTest extends TestCase @@ -15,7 +17,7 @@ class HeaderValueTest extends TestCase * * @psalm-return array */ - public function getFilterValues(): array + public static function getFilterValues(): array { return [ ["This is a\n test", 'This is a test'], @@ -32,19 +34,15 @@ public function getFilterValues(): array ]; } - /** - * @group ZF2015-04 - * @dataProvider getFilterValues - * @param string $value - * @param string $expected - */ - public function testFiltersValuesPerRfc7230($value, $expected) + #[DataProvider('getFilterValues')] + #[Group('ZF2015-04')] + public function testFiltersValuesPerRfc7230(string $value, string $expected): void { $this->assertEquals($expected, HeaderValue::filter($value)); } /** @psalm-return array */ - public function validateValues(): array + public static function validateValues(): array { return [ ["This is a\n test", 'assertFalse'], @@ -61,19 +59,15 @@ public function validateValues(): array ]; } - /** - * @group ZF2015-04 - * @dataProvider validateValues - * @param string $value - * @param string $assertion - */ - public function testValidatesValuesPerRfc7230($value, $assertion) + #[DataProvider('validateValues')] + #[Group('ZF2015-04')] + public function testValidatesValuesPerRfc7230(string $value, string $assertion): void { $this->{$assertion}(HeaderValue::isValid($value)); } /** @psalm-return array */ - public function assertValues(): array + public static function assertValues(): array { return [ ["This is a\n test"], @@ -89,12 +83,9 @@ public function assertValues(): array ]; } - /** - * @group ZF2015-04 - * @dataProvider assertValues - * @param string $value - */ - public function testAssertValidRaisesExceptionForInvalidValue($value) + #[DataProvider('assertValues')] + #[Group('ZF2015-04')] + public function testAssertValidRaisesExceptionForInvalidValue(string $value): void { $this->expectException(InvalidArgumentException::class); HeaderValue::assertValid($value); diff --git a/test/Header/HostTest.php b/test/Header/HostTest.php index 30f64ffe..bdb4d2f9 100644 --- a/test/Header/HostTest.php +++ b/test/Header/HostTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Host; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class HostTest extends TestCase { - public function testHostFromStringCreatesValidHostHeader() + public function testHostFromStringCreatesValidHostHeader(): void { $hostHeader = Host::fromString('Host: xxx'); $this->assertInstanceOf(HeaderInterface::class, $hostHeader); $this->assertInstanceOf(Host::class, $hostHeader); } - public function testHostGetFieldNameReturnsHeaderName() + public function testHostGetFieldNameReturnsHeaderName(): void { $hostHeader = new Host(); $this->assertEquals('Host', $hostHeader->getFieldName()); } - public function testHostGetFieldValueReturnsProperValue() + public function testHostGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Host needs to be completed'); @@ -32,7 +33,7 @@ public function testHostGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $hostHeader->getFieldValue()); } - public function testHostToStringReturnsHeaderFormattedString() + public function testHostToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Host needs to be completed'); @@ -43,13 +44,11 @@ public function testHostToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Host::fromString("Host: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Host("xxx\r\n\r\nevilContent"); diff --git a/test/Header/IfMatchTest.php b/test/Header/IfMatchTest.php index 69f68e8c..d3afc928 100644 --- a/test/Header/IfMatchTest.php +++ b/test/Header/IfMatchTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\IfMatch; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class IfMatchTest extends TestCase { - public function testIfMatchFromStringCreatesValidIfMatchHeader() + public function testIfMatchFromStringCreatesValidIfMatchHeader(): void { $ifMatchHeader = IfMatch::fromString('If-Match: xxx'); $this->assertInstanceOf(HeaderInterface::class, $ifMatchHeader); $this->assertInstanceOf(IfMatch::class, $ifMatchHeader); } - public function testIfMatchGetFieldNameReturnsHeaderName() + public function testIfMatchGetFieldNameReturnsHeaderName(): void { $ifMatchHeader = new IfMatch(); $this->assertEquals('If-Match', $ifMatchHeader->getFieldName()); } - public function testIfMatchGetFieldValueReturnsProperValue() + public function testIfMatchGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('IfMatch needs to be completed'); @@ -32,7 +33,7 @@ public function testIfMatchGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $ifMatchHeader->getFieldValue()); } - public function testIfMatchToStringReturnsHeaderFormattedString() + public function testIfMatchToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('IfMatch needs to be completed'); @@ -43,13 +44,11 @@ public function testIfMatchToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); IfMatch::fromString("If-Match: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new IfMatch("xxx\r\n\r\nevilContent"); diff --git a/test/Header/IfModifiedSinceTest.php b/test/Header/IfModifiedSinceTest.php index dbcfe152..286d1e65 100644 --- a/test/Header/IfModifiedSinceTest.php +++ b/test/Header/IfModifiedSinceTest.php @@ -7,31 +7,32 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\IfModifiedSince; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class IfModifiedSinceTest extends TestCase { - public function testIfModifiedSinceFromStringCreatesValidIfModifiedSinceHeader() + public function testIfModifiedSinceFromStringCreatesValidIfModifiedSinceHeader(): void { $ifModifiedSinceHeader = IfModifiedSince::fromString('If-Modified-Since: Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertInstanceOf(HeaderInterface::class, $ifModifiedSinceHeader); $this->assertInstanceOf(IfModifiedSince::class, $ifModifiedSinceHeader); } - public function testIfModifiedSinceGetFieldNameReturnsHeaderName() + public function testIfModifiedSinceGetFieldNameReturnsHeaderName(): void { $ifModifiedSinceHeader = new IfModifiedSince(); $this->assertEquals('If-Modified-Since', $ifModifiedSinceHeader->getFieldName()); } - public function testIfModifiedSinceGetFieldValueReturnsProperValue() + public function testIfModifiedSinceGetFieldValueReturnsProperValue(): void { $ifModifiedSinceHeader = new IfModifiedSince(); $ifModifiedSinceHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertEquals('Sun, 06 Nov 1994 08:49:37 GMT', $ifModifiedSinceHeader->getFieldValue()); } - public function testIfModifiedSinceToStringReturnsHeaderFormattedString() + public function testIfModifiedSinceToStringReturnsHeaderFormattedString(): void { $ifModifiedSinceHeader = new IfModifiedSince(); $ifModifiedSinceHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); @@ -43,13 +44,11 @@ public function testIfModifiedSinceToStringReturnsHeaderFormattedString() * * @see LaminasTest\Http\Header\DateTest */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); IfModifiedSince::fromString( diff --git a/test/Header/IfNoneMatchTest.php b/test/Header/IfNoneMatchTest.php index 43a56d65..c8688ae3 100644 --- a/test/Header/IfNoneMatchTest.php +++ b/test/Header/IfNoneMatchTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\IfNoneMatch; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class IfNoneMatchTest extends TestCase { - public function testIfNoneMatchFromStringCreatesValidIfNoneMatchHeader() + public function testIfNoneMatchFromStringCreatesValidIfNoneMatchHeader(): void { $ifNoneMatchHeader = IfNoneMatch::fromString('If-None-Match: xxx'); $this->assertInstanceOf(HeaderInterface::class, $ifNoneMatchHeader); $this->assertInstanceOf(IfNoneMatch::class, $ifNoneMatchHeader); } - public function testIfNoneMatchGetFieldNameReturnsHeaderName() + public function testIfNoneMatchGetFieldNameReturnsHeaderName(): void { $ifNoneMatchHeader = new IfNoneMatch(); $this->assertEquals('If-None-Match', $ifNoneMatchHeader->getFieldName()); } - public function testIfNoneMatchGetFieldValueReturnsProperValue() + public function testIfNoneMatchGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('IfNoneMatch needs to be completed'); @@ -32,7 +33,7 @@ public function testIfNoneMatchGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $ifNoneMatchHeader->getFieldValue()); } - public function testIfNoneMatchToStringReturnsHeaderFormattedString() + public function testIfNoneMatchToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('IfNoneMatch needs to be completed'); @@ -43,13 +44,11 @@ public function testIfNoneMatchToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); IfNoneMatch::fromString("If-None-Match: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new IfNoneMatch("xxx\r\n\r\nevilContent"); diff --git a/test/Header/IfRangeTest.php b/test/Header/IfRangeTest.php index 6758f352..a5bc8d21 100644 --- a/test/Header/IfRangeTest.php +++ b/test/Header/IfRangeTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\IfRange; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class IfRangeTest extends TestCase { - public function testIfRangeFromStringCreatesValidIfRangeHeader() + public function testIfRangeFromStringCreatesValidIfRangeHeader(): void { $ifRangeHeader = IfRange::fromString('If-Range: xxx'); $this->assertInstanceOf(HeaderInterface::class, $ifRangeHeader); $this->assertInstanceOf(IfRange::class, $ifRangeHeader); } - public function testIfRangeGetFieldNameReturnsHeaderName() + public function testIfRangeGetFieldNameReturnsHeaderName(): void { $ifRangeHeader = new IfRange(); $this->assertEquals('If-Range', $ifRangeHeader->getFieldName()); } - public function testIfRangeGetFieldValueReturnsProperValue() + public function testIfRangeGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('IfRange needs to be completed'); @@ -32,7 +33,7 @@ public function testIfRangeGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $ifRangeHeader->getFieldValue()); } - public function testIfRangeToStringReturnsHeaderFormattedString() + public function testIfRangeToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('IfRange needs to be completed'); @@ -43,13 +44,11 @@ public function testIfRangeToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); IfRange::fromString("If-Range: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new IfRange("xxx\r\n\r\nevilContent"); diff --git a/test/Header/IfUnmodifiedSinceTest.php b/test/Header/IfUnmodifiedSinceTest.php index 951beb0d..8e916944 100644 --- a/test/Header/IfUnmodifiedSinceTest.php +++ b/test/Header/IfUnmodifiedSinceTest.php @@ -7,31 +7,32 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\IfUnmodifiedSince; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class IfUnmodifiedSinceTest extends TestCase { - public function testIfUnmodifiedSinceFromStringCreatesValidIfUnmodifiedSinceHeader() + public function testIfUnmodifiedSinceFromStringCreatesValidIfUnmodifiedSinceHeader(): void { $ifUnmodifiedSinceHeader = IfUnmodifiedSince::fromString('If-Unmodified-Since: Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertInstanceOf(HeaderInterface::class, $ifUnmodifiedSinceHeader); $this->assertInstanceOf(IfUnmodifiedSince::class, $ifUnmodifiedSinceHeader); } - public function testIfUnmodifiedSinceGetFieldNameReturnsHeaderName() + public function testIfUnmodifiedSinceGetFieldNameReturnsHeaderName(): void { $ifUnmodifiedSinceHeader = new IfUnmodifiedSince(); $this->assertEquals('If-Unmodified-Since', $ifUnmodifiedSinceHeader->getFieldName()); } - public function testIfUnmodifiedSinceGetFieldValueReturnsProperValue() + public function testIfUnmodifiedSinceGetFieldValueReturnsProperValue(): void { $ifUnmodifiedSinceHeader = new IfUnmodifiedSince(); $ifUnmodifiedSinceHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertEquals('Sun, 06 Nov 1994 08:49:37 GMT', $ifUnmodifiedSinceHeader->getFieldValue()); } - public function testIfUnmodifiedSinceToStringReturnsHeaderFormattedString() + public function testIfUnmodifiedSinceToStringReturnsHeaderFormattedString(): void { $ifUnmodifiedSinceHeader = new IfUnmodifiedSince(); $ifUnmodifiedSinceHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); @@ -43,13 +44,11 @@ public function testIfUnmodifiedSinceToStringReturnsHeaderFormattedString() * * @see LaminasTest\Http\Header\DateTest */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testCRLFAttack() + #[Group('ZF2015-04')] + public function testCRLFAttack(): void { $this->expectException(InvalidArgumentException::class); IfUnmodifiedSince::fromString( diff --git a/test/Header/KeepAliveTest.php b/test/Header/KeepAliveTest.php index 4f01453f..c2851577 100644 --- a/test/Header/KeepAliveTest.php +++ b/test/Header/KeepAliveTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\KeepAlive; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class KeepAliveTest extends TestCase { - public function testKeepAliveFromStringCreatesValidKeepAliveHeader() + public function testKeepAliveFromStringCreatesValidKeepAliveHeader(): void { $keepAliveHeader = KeepAlive::fromString('Keep-Alive: xxx'); $this->assertInstanceOf(HeaderInterface::class, $keepAliveHeader); $this->assertInstanceOf(KeepAlive::class, $keepAliveHeader); } - public function testKeepAliveGetFieldNameReturnsHeaderName() + public function testKeepAliveGetFieldNameReturnsHeaderName(): void { $keepAliveHeader = new KeepAlive(); $this->assertEquals('Keep-Alive', $keepAliveHeader->getFieldName()); } - public function testKeepAliveGetFieldValueReturnsProperValue() + public function testKeepAliveGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('KeepAlive needs to be completed'); @@ -32,7 +33,7 @@ public function testKeepAliveGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $keepAliveHeader->getFieldValue()); } - public function testKeepAliveToStringReturnsHeaderFormattedString() + public function testKeepAliveToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('KeepAlive needs to be completed'); @@ -43,13 +44,11 @@ public function testKeepAliveToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); KeepAlive::fromString("Keep-Alive: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new KeepAlive("xxx\r\n\r\nevilContent"); diff --git a/test/Header/LastModifiedTest.php b/test/Header/LastModifiedTest.php index 26d704f5..a39d2a3e 100644 --- a/test/Header/LastModifiedTest.php +++ b/test/Header/LastModifiedTest.php @@ -7,31 +7,32 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\LastModified; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class LastModifiedTest extends TestCase { - public function testExpiresFromStringCreatesValidLastModifiedHeader() + public function testExpiresFromStringCreatesValidLastModifiedHeader(): void { $lastModifiedHeader = LastModified::fromString('Last-Modified: Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertInstanceOf(HeaderInterface::class, $lastModifiedHeader); $this->assertInstanceOf(LastModified::class, $lastModifiedHeader); } - public function testLastModifiedGetFieldNameReturnsHeaderName() + public function testLastModifiedGetFieldNameReturnsHeaderName(): void { $lastModifiedHeader = new LastModified(); $this->assertEquals('Last-Modified', $lastModifiedHeader->getFieldName()); } - public function testLastModifiedGetFieldValueReturnsProperValue() + public function testLastModifiedGetFieldValueReturnsProperValue(): void { $lastModifiedHeader = new LastModified(); $lastModifiedHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertEquals('Sun, 06 Nov 1994 08:49:37 GMT', $lastModifiedHeader->getFieldValue()); } - public function testLastModifiedToStringReturnsHeaderFormattedString() + public function testLastModifiedToStringReturnsHeaderFormattedString(): void { $lastModifiedHeader = new LastModified(); $lastModifiedHeader->setDate('Sun, 06 Nov 1994 08:49:37 GMT'); @@ -43,13 +44,11 @@ public function testLastModifiedToStringReturnsHeaderFormattedString() * * @see LaminasTest\Http\Header\DateTest */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); LastModified::fromString("Last-Modified: Sun, 06 Nov 1994 08:49:37 GMT\r\n\r\nevilContent"); diff --git a/test/Header/LocationTest.php b/test/Header/LocationTest.php index 6c902f3f..6ad3528f 100644 --- a/test/Header/LocationTest.php +++ b/test/Header/LocationTest.php @@ -12,15 +12,17 @@ use Laminas\Uri\Mailto; use Laminas\Uri\Uri; use Laminas\Uri\UriFactory; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class LocationTest extends TestCase { /** - * @dataProvider locationFromStringCreatesValidLocationHeaderProvider * @param string $uri The URL to redirect to */ - public function testLocationFromStringCreatesValidLocationHeader($uri) + #[DataProvider('locationFromStringCreatesValidLocationHeaderProvider')] + public function testLocationFromStringCreatesValidLocationHeader(string $uri): void { $locationHeader = Location::fromString('Location: ' . $uri); $this->assertInstanceOf(HeaderInterface::class, $locationHeader); @@ -28,7 +30,7 @@ public function testLocationFromStringCreatesValidLocationHeader($uri) } /** @psalm-return array */ - public function locationFromStringCreatesValidLocationHeaderProvider(): array + public static function locationFromStringCreatesValidLocationHeaderProvider(): array { return [ ['http://www.example.com'], @@ -40,12 +42,9 @@ public function locationFromStringCreatesValidLocationHeaderProvider(): array /** * Test that we can set a redirect to different URI-Schemes - * - * @dataProvider locationCanSetDifferentSchemeUrisProvider - * @param string $uri - * @param string $expectedClass */ - public function testLocationCanSetDifferentSchemeUris($uri, $expectedClass) + #[DataProvider('locationCanSetDifferentSchemeUrisProvider')] + public function testLocationCanSetDifferentSchemeUris(string $uri, string $expectedClass): void { $locationHeader = new Location(); $locationHeader->setUri($uri); @@ -54,12 +53,9 @@ public function testLocationCanSetDifferentSchemeUris($uri, $expectedClass) /** * Test that we can set a redirect to different URI-schemes via a class - * - * @dataProvider locationCanSetDifferentSchemeUrisProvider - * @param string $uri - * @param string $expectedClass */ - public function testLocationCanSetDifferentSchemeUriObjects($uri, $expectedClass) + #[DataProvider('locationCanSetDifferentSchemeUrisProvider')] + public function testLocationCanSetDifferentSchemeUriObjects(string $uri, string $expectedClass): void { $uri = UriFactory::factory($uri); $locationHeader = new Location(); @@ -69,10 +65,8 @@ public function testLocationCanSetDifferentSchemeUriObjects($uri, $expectedClass /** * Provide data to the locationCanSetDifferentSchemeUris-test - * - * @return array */ - public function locationCanSetDifferentSchemeUrisProvider() + public static function locationCanSetDifferentSchemeUrisProvider(): array { return [ ['http://www.example.com', Http::class], @@ -82,7 +76,7 @@ public function locationCanSetDifferentSchemeUrisProvider() ]; } - public function testLocationGetFieldValueReturnsProperValue() + public function testLocationGetFieldValueReturnsProperValue(): void { $locationHeader = new Location(); $locationHeader->setUri('http://www.example.com/'); @@ -92,7 +86,7 @@ public function testLocationGetFieldValueReturnsProperValue() $this->assertEquals('/path', $locationHeader->getFieldValue()); } - public function testLocationToStringReturnsHeaderFormattedString() + public function testLocationToStringReturnsHeaderFormattedString(): void { $locationHeader = new Location(); $locationHeader->setUri('http://www.example.com/path?query'); @@ -103,7 +97,7 @@ public function testLocationToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testLocationCanSetAndAccessAbsoluteUri() + public function testLocationCanSetAndAccessAbsoluteUri(): void { $locationHeader = Location::fromString('Location: http://www.example.com/path'); $uri = $locationHeader->uri(); @@ -112,7 +106,7 @@ public function testLocationCanSetAndAccessAbsoluteUri() $this->assertEquals('http://www.example.com/path', $locationHeader->getUri()); } - public function testLocationCanSetAndAccessRelativeUri() + public function testLocationCanSetAndAccessRelativeUri(): void { $locationHeader = Location::fromString('Location: /path/to'); $uri = $locationHeader->uri(); @@ -123,10 +117,9 @@ public function testLocationCanSetAndAccessRelativeUri() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testCRLFAttack() + #[Group('ZF2015-04')] + public function testCRLFAttack(): void { $this->expectException(InvalidArgumentException::class); Location::fromString("Location: http://www.example.com/path\r\n\r\nevilContent"); diff --git a/test/Header/MaxForwardsTest.php b/test/Header/MaxForwardsTest.php index 07f50c83..649657e6 100644 --- a/test/Header/MaxForwardsTest.php +++ b/test/Header/MaxForwardsTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\MaxForwards; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class MaxForwardsTest extends TestCase { - public function testMaxForwardsFromStringCreatesValidMaxForwardsHeader() + public function testMaxForwardsFromStringCreatesValidMaxForwardsHeader(): void { $maxForwardsHeader = MaxForwards::fromString('Max-Forwards: xxx'); $this->assertInstanceOf(HeaderInterface::class, $maxForwardsHeader); $this->assertInstanceOf(MaxForwards::class, $maxForwardsHeader); } - public function testMaxForwardsGetFieldNameReturnsHeaderName() + public function testMaxForwardsGetFieldNameReturnsHeaderName(): void { $maxForwardsHeader = new MaxForwards(); $this->assertEquals('Max-Forwards', $maxForwardsHeader->getFieldName()); } - public function testMaxForwardsGetFieldValueReturnsProperValue() + public function testMaxForwardsGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('MaxForwards needs to be completed'); @@ -32,7 +33,7 @@ public function testMaxForwardsGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $maxForwardsHeader->getFieldValue()); } - public function testMaxForwardsToStringReturnsHeaderFormattedString() + public function testMaxForwardsToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('MaxForwards needs to be completed'); @@ -43,13 +44,11 @@ public function testMaxForwardsToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); MaxForwards::fromString("Max-Forwards: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructorValue() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructorValue(): void { $this->expectException(InvalidArgumentException::class); new MaxForwards("xxx\r\n\r\nevilContent"); diff --git a/test/Header/OriginTest.php b/test/Header/OriginTest.php index 83e8fe41..7584fd75 100644 --- a/test/Header/OriginTest.php +++ b/test/Header/OriginTest.php @@ -8,34 +8,33 @@ use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Origin; use Laminas\Uri\Exception\InvalidUriPartException; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class OriginTest extends TestCase { - /** - * @group ZF#6484 - */ - public function testOriginFieldValueIsAlwaysAString() + #[Group('ZF#6484')] + public function testOriginFieldValueIsAlwaysAString(): void { $origin = new Origin(); $this->assertIsString($origin->getFieldValue()); } - public function testOriginFromStringCreatesValidOriginHeader() + public function testOriginFromStringCreatesValidOriginHeader(): void { $originHeader = Origin::fromString('Origin: http://laminas.org'); $this->assertInstanceOf(HeaderInterface::class, $originHeader); $this->assertInstanceOf(Origin::class, $originHeader); } - public function testOriginGetFieldNameReturnsHeaderName() + public function testOriginGetFieldNameReturnsHeaderName(): void { $originHeader = new Origin(); $this->assertEquals('Origin', $originHeader->getFieldName()); } - public function testOriginGetFieldValueReturnsProperValue() + public function testOriginGetFieldValueReturnsProperValue(): void { $originHeader = Origin::fromString('Origin: http://laminas.org'); $this->assertEquals('http://laminas.org', $originHeader->getFieldValue()); @@ -43,19 +42,16 @@ public function testOriginGetFieldValueReturnsProperValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidUriPartException::class); Origin::fromString("Origin: http://laminas.org\r\n\r\nevilContent"); } - /** - * @group ZF2015-04 - */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Origin("http://laminas.org\r\n\r\nevilContent"); diff --git a/test/Header/PragmaTest.php b/test/Header/PragmaTest.php index 593bc276..31e7fbbd 100644 --- a/test/Header/PragmaTest.php +++ b/test/Header/PragmaTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Pragma; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class PragmaTest extends TestCase { - public function testPragmaFromStringCreatesValidPragmaHeader() + public function testPragmaFromStringCreatesValidPragmaHeader(): void { $pragmaHeader = Pragma::fromString('Pragma: xxx'); $this->assertInstanceOf(HeaderInterface::class, $pragmaHeader); $this->assertInstanceOf(Pragma::class, $pragmaHeader); } - public function testPragmaGetFieldNameReturnsHeaderName() + public function testPragmaGetFieldNameReturnsHeaderName(): void { $pragmaHeader = new Pragma(); $this->assertEquals('Pragma', $pragmaHeader->getFieldName()); } - public function testPragmaGetFieldValueReturnsProperValue() + public function testPragmaGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Pragma needs to be completed'); @@ -32,7 +33,7 @@ public function testPragmaGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $pragmaHeader->getFieldValue()); } - public function testPragmaToStringReturnsHeaderFormattedString() + public function testPragmaToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Pragma needs to be completed'); @@ -43,13 +44,11 @@ public function testPragmaToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Pragma::fromString("Pragma: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Pragma("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ProxyAuthenticateTest.php b/test/Header/ProxyAuthenticateTest.php index 3c42d81b..8e729feb 100644 --- a/test/Header/ProxyAuthenticateTest.php +++ b/test/Header/ProxyAuthenticateTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\ProxyAuthenticate; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ProxyAuthenticateTest extends TestCase { - public function testProxyAuthenticateFromStringCreatesValidProxyAuthenticateHeader() + public function testProxyAuthenticateFromStringCreatesValidProxyAuthenticateHeader(): void { $proxyAuthenticateHeader = ProxyAuthenticate::fromString('Proxy-Authenticate: xxx'); $this->assertInstanceOf(HeaderInterface::class, $proxyAuthenticateHeader); $this->assertInstanceOf(ProxyAuthenticate::class, $proxyAuthenticateHeader); } - public function testProxyAuthenticateGetFieldNameReturnsHeaderName() + public function testProxyAuthenticateGetFieldNameReturnsHeaderName(): void { $proxyAuthenticateHeader = new ProxyAuthenticate(); $this->assertEquals('Proxy-Authenticate', $proxyAuthenticateHeader->getFieldName()); } - public function testProxyAuthenticateGetFieldValueReturnsProperValue() + public function testProxyAuthenticateGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ProxyAuthenticate needs to be completed'); @@ -32,7 +33,7 @@ public function testProxyAuthenticateGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $proxyAuthenticateHeader->getFieldValue()); } - public function testProxyAuthenticateToStringReturnsHeaderFormattedString() + public function testProxyAuthenticateToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ProxyAuthenticate needs to be completed'); @@ -43,13 +44,11 @@ public function testProxyAuthenticateToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ProxyAuthenticate::fromString("Proxy-Authenticate: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ProxyAuthenticate("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ProxyAuthorizationTest.php b/test/Header/ProxyAuthorizationTest.php index 48abde72..fe8422bd 100644 --- a/test/Header/ProxyAuthorizationTest.php +++ b/test/Header/ProxyAuthorizationTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\ProxyAuthorization; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ProxyAuthorizationTest extends TestCase { - public function testProxyAuthorizationFromStringCreatesValidProxyAuthorizationHeader() + public function testProxyAuthorizationFromStringCreatesValidProxyAuthorizationHeader(): void { $proxyAuthorizationHeader = ProxyAuthorization::fromString('Proxy-Authorization: xxx'); $this->assertInstanceOf(HeaderInterface::class, $proxyAuthorizationHeader); $this->assertInstanceOf(ProxyAuthorization::class, $proxyAuthorizationHeader); } - public function testProxyAuthorizationGetFieldNameReturnsHeaderName() + public function testProxyAuthorizationGetFieldNameReturnsHeaderName(): void { $proxyAuthorizationHeader = new ProxyAuthorization(); $this->assertEquals('Proxy-Authorization', $proxyAuthorizationHeader->getFieldName()); } - public function testProxyAuthorizationGetFieldValueReturnsProperValue() + public function testProxyAuthorizationGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('ProxyAuthorization needs to be completed'); @@ -32,7 +33,7 @@ public function testProxyAuthorizationGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $proxyAuthorizationHeader->getFieldValue()); } - public function testProxyAuthorizationToStringReturnsHeaderFormattedString() + public function testProxyAuthorizationToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('ProxyAuthorization needs to be completed'); @@ -43,13 +44,11 @@ public function testProxyAuthorizationToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); ProxyAuthorization::fromString("Proxy-Authorization: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new ProxyAuthorization("xxx\r\n\r\nevilContent"); diff --git a/test/Header/RangeTest.php b/test/Header/RangeTest.php index a929b73c..82e1ad48 100644 --- a/test/Header/RangeTest.php +++ b/test/Header/RangeTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Range; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class RangeTest extends TestCase { - public function testRangeFromStringCreatesValidRangeHeader() + public function testRangeFromStringCreatesValidRangeHeader(): void { $rangeHeader = Range::fromString('Range: xxx'); $this->assertInstanceOf(HeaderInterface::class, $rangeHeader); $this->assertInstanceOf(Range::class, $rangeHeader); } - public function testRangeGetFieldNameReturnsHeaderName() + public function testRangeGetFieldNameReturnsHeaderName(): void { $rangeHeader = new Range(); $this->assertEquals('Range', $rangeHeader->getFieldName()); } - public function testRangeGetFieldValueReturnsProperValue() + public function testRangeGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Range needs to be completed'); @@ -32,7 +33,7 @@ public function testRangeGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $rangeHeader->getFieldValue()); } - public function testRangeToStringReturnsHeaderFormattedString() + public function testRangeToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Range needs to be completed'); @@ -43,13 +44,11 @@ public function testRangeToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Range::fromString("Range: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructorValue() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructorValue(): void { $this->expectException(InvalidArgumentException::class); new Range("xxx\r\n\r\nevilContent"); diff --git a/test/Header/RefererTest.php b/test/Header/RefererTest.php index e049bbaa..b5c18fbc 100644 --- a/test/Header/RefererTest.php +++ b/test/Header/RefererTest.php @@ -11,18 +11,19 @@ use Laminas\Http\Headers; use Laminas\Uri\Http; use Laminas\Uri\Uri; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class RefererTest extends TestCase { - public function testRefererFromStringCreatesValidLocationHeader() + public function testRefererFromStringCreatesValidLocationHeader(): void { $refererHeader = Referer::fromString('Referer: http://www.example.com/'); $this->assertInstanceOf(HeaderInterface::class, $refererHeader); $this->assertInstanceOf(Referer::class, $refererHeader); } - public function testRefererGetFieldValueReturnsProperValue() + public function testRefererGetFieldValueReturnsProperValue(): void { $refererHeader = new Referer(); $refererHeader->setUri('http://www.example.com/'); @@ -32,7 +33,7 @@ public function testRefererGetFieldValueReturnsProperValue() $this->assertEquals('/path', $refererHeader->getFieldValue()); } - public function testRefererToStringReturnsHeaderFormattedString() + public function testRefererToStringReturnsHeaderFormattedString(): void { $refererHeader = new Referer(); $refererHeader->setUri('http://www.example.com/path?query'); @@ -43,7 +44,7 @@ public function testRefererToStringReturnsHeaderFormattedString() // Implementation specific tests here // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle - public function testRefererCanSetAndAccessAbsoluteUri() + public function testRefererCanSetAndAccessAbsoluteUri(): void { $refererHeader = Referer::fromString('Referer: http://www.example.com/path'); $uri = $refererHeader->uri(); @@ -52,7 +53,7 @@ public function testRefererCanSetAndAccessAbsoluteUri() $this->assertEquals('http://www.example.com/path', $refererHeader->getUri()); } - public function testRefererCanSetAndAccessRelativeUri() + public function testRefererCanSetAndAccessRelativeUri(): void { $refererHeader = Referer::fromString('Referer: /path/to'); $uri = $refererHeader->uri(); @@ -61,7 +62,7 @@ public function testRefererCanSetAndAccessRelativeUri() $this->assertEquals('/path/to', $refererHeader->getUri()); } - public function testRefererDoesNotHaveUriFragment() + public function testRefererDoesNotHaveUriFragment(): void { $refererHeader = new Referer(); $refererHeader->setUri('http://www.example.com/path?query#fragment'); @@ -70,16 +71,15 @@ public function testRefererDoesNotHaveUriFragment() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testCRLFAttack() + #[Group('ZF2015-04')] + public function testCRLFAttack(): void { $this->expectException(InvalidArgumentException::class); Referer::fromString("Referer: http://www.example.com/\r\n\r\nevilContent"); } - public function testInvalidUriShouldWrapException() + public function testInvalidUriShouldWrapException(): void { $headerString = "Referer: unknown-scheme://test"; diff --git a/test/Header/RefreshTest.php b/test/Header/RefreshTest.php index aa5354c6..a2d0b389 100644 --- a/test/Header/RefreshTest.php +++ b/test/Header/RefreshTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Refresh; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class RefreshTest extends TestCase { - public function testRefreshFromStringCreatesValidRefreshHeader() + public function testRefreshFromStringCreatesValidRefreshHeader(): void { $refreshHeader = Refresh::fromString('Refresh: xxx'); $this->assertInstanceOf(HeaderInterface::class, $refreshHeader); $this->assertInstanceOf(Refresh::class, $refreshHeader); } - public function testRefreshGetFieldNameReturnsHeaderName() + public function testRefreshGetFieldNameReturnsHeaderName(): void { $refreshHeader = new Refresh(); $this->assertEquals('Refresh', $refreshHeader->getFieldName()); } - public function testRefreshGetFieldValueReturnsProperValue() + public function testRefreshGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Refresh needs to be completed'); @@ -32,7 +33,7 @@ public function testRefreshGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $refreshHeader->getFieldValue()); } - public function testRefreshToStringReturnsHeaderFormattedString() + public function testRefreshToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Refresh needs to be completed'); @@ -43,13 +44,11 @@ public function testRefreshToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Refresh::fromString("Refresh: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructorValue() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructorValue(): void { $this->expectException(InvalidArgumentException::class); new Refresh("xxx\r\n\r\nevilContent"); diff --git a/test/Header/RetryAfterTest.php b/test/Header/RetryAfterTest.php index 13994580..e82a93c6 100644 --- a/test/Header/RetryAfterTest.php +++ b/test/Header/RetryAfterTest.php @@ -7,11 +7,12 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\RetryAfter; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class RetryAfterTest extends TestCase { - public function testRetryAfterFromStringCreatesValidRetryAfterHeader() + public function testRetryAfterFromStringCreatesValidRetryAfterHeader(): void { $retryAfterHeader = RetryAfter::fromString('Retry-After: 10'); $this->assertInstanceOf(HeaderInterface::class, $retryAfterHeader); @@ -19,19 +20,19 @@ public function testRetryAfterFromStringCreatesValidRetryAfterHeader() $this->assertEquals('10', $retryAfterHeader->getDeltaSeconds()); } - public function testRetryAfterFromStringCreatesValidRetryAfterHeaderFromDate() + public function testRetryAfterFromStringCreatesValidRetryAfterHeaderFromDate(): void { $retryAfterHeader = RetryAfter::fromString('Retry-After: Sun, 06 Nov 1994 08:49:37 GMT'); $this->assertEquals('Sun, 06 Nov 1994 08:49:37 GMT', $retryAfterHeader->getDate()); } - public function testRetryAfterGetFieldNameReturnsHeaderName() + public function testRetryAfterGetFieldNameReturnsHeaderName(): void { $retryAfterHeader = new RetryAfter(); $this->assertEquals('Retry-After', $retryAfterHeader->getFieldName()); } - public function testRetryAfterGetFieldValueReturnsProperValue() + public function testRetryAfterGetFieldValueReturnsProperValue(): void { $retryAfterHeader = new RetryAfter(); $retryAfterHeader->setDeltaSeconds(3600); @@ -40,7 +41,7 @@ public function testRetryAfterGetFieldValueReturnsProperValue() $this->assertEquals('Sun, 06 Nov 1994 08:49:37 GMT', $retryAfterHeader->getFieldValue()); } - public function testRetryAfterToStringReturnsHeaderFormattedString() + public function testRetryAfterToStringReturnsHeaderFormattedString(): void { $retryAfterHeader = new RetryAfter(); @@ -53,10 +54,9 @@ public function testRetryAfterToStringReturnsHeaderFormattedString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); RetryAfter::fromString("Retry-After: 10\r\n\r\nevilContent"); diff --git a/test/Header/ServerTest.php b/test/Header/ServerTest.php index 1fec13d9..80baebc7 100644 --- a/test/Header/ServerTest.php +++ b/test/Header/ServerTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Server; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ServerTest extends TestCase { - public function testServerFromStringCreatesValidServerHeader() + public function testServerFromStringCreatesValidServerHeader(): void { $serverHeader = Server::fromString('Server: xxx'); $this->assertInstanceOf(HeaderInterface::class, $serverHeader); $this->assertInstanceOf(Server::class, $serverHeader); } - public function testServerGetFieldNameReturnsHeaderName() + public function testServerGetFieldNameReturnsHeaderName(): void { $serverHeader = new Server(); $this->assertEquals('Server', $serverHeader->getFieldName()); } - public function testServerGetFieldValueReturnsProperValue() + public function testServerGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Server needs to be completed'); @@ -32,7 +33,7 @@ public function testServerGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $serverHeader->getFieldValue()); } - public function testServerToStringReturnsHeaderFormattedString() + public function testServerToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Server needs to be completed'); @@ -43,13 +44,11 @@ public function testServerToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Server::fromString("Server: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Server("xxx\r\n\r\nevilContent"); diff --git a/test/Header/SetCookieTest.php b/test/Header/SetCookieTest.php index fd3637f1..2e52ec7c 100644 --- a/test/Header/SetCookieTest.php +++ b/test/Header/SetCookieTest.php @@ -9,6 +9,8 @@ use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\MultipleHeaderInterface; use Laminas\Http\Header\SetCookie; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function gmdate; @@ -24,10 +26,8 @@ class SetCookieTest extends TestCase { - /** - * @group Laminas-254 - */ - public function testSetCookieConstructor() + #[Group('Laminas-254')] + public function testSetCookieConstructor(): void { $setCookieHeader = new SetCookie( 'myname', @@ -51,7 +51,7 @@ public function testSetCookieConstructor() $this->assertEquals(9, $setCookieHeader->getVersion()); } - public function testSetCookieConstructorWithSameSite() + public function testSetCookieConstructorWithSameSite(): void { $setCookieHeader = new SetCookie( 'myname', @@ -77,7 +77,7 @@ public function testSetCookieConstructorWithSameSite() $this->assertEquals('Strict', $setCookieHeader->getSameSite()); } - public function testSetCookieConstructorWithSameSiteCaseInsensitive() + public function testSetCookieConstructorWithSameSiteCaseInsensitive(): void { $setCookieHeader = new SetCookie( 'myname', @@ -103,7 +103,7 @@ public function testSetCookieConstructorWithSameSiteCaseInsensitive() $this->assertEquals(SetCookie::SAME_SITE_STRICT, $setCookieHeader->getSameSite()); } - public function testSetCookieWithInvalidSameSiteValueThrowException() + public function testSetCookieWithInvalidSameSiteValueThrowException(): void { $this->expectException(InvalidArgumentException::class); @@ -121,7 +121,7 @@ public function testSetCookieWithInvalidSameSiteValueThrowException() ); } - public function testSetInvalidSameSiteDirectiveValueViaSetter() + public function testSetInvalidSameSiteDirectiveValueViaSetter(): void { $setCookieHeader = new SetCookie( 'myname', @@ -139,7 +139,7 @@ public function testSetInvalidSameSiteDirectiveValueViaSetter() $setCookieHeader->setSameSite('InvalidValue'); } - public function testSameSiteGetterReturnsCanonicalValue() + public function testSameSiteGetterReturnsCanonicalValue(): void { $setCookieHeader = new SetCookie( 'myname', @@ -162,14 +162,14 @@ public function testSameSiteGetterReturnsCanonicalValue() $this->assertEquals(SetCookie::SAME_SITE_NONE, $setCookieHeader->getSameSite()); } - public function testSetCookieFromStringWithQuotedValue() + public function testSetCookieFromStringWithQuotedValue(): void { $setCookieHeader = SetCookie::fromString('Set-Cookie: myname="quotedValue"'); $this->assertEquals('quotedValue', $setCookieHeader->getValue()); $this->assertEquals('myname=quotedValue', $setCookieHeader->getFieldValue()); } - public function testSetCookieFromStringWithNotEncodedValue() + public function testSetCookieFromStringWithNotEncodedValue(): void { $setCookieHeader = SetCookie::fromString('Set-Cookie: foo=a:b; Path=/'); $this->assertFalse($setCookieHeader->getEncodeValue()); @@ -177,7 +177,7 @@ public function testSetCookieFromStringWithNotEncodedValue() $this->assertEquals('foo=a:b; Path=/', $setCookieHeader->getFieldValue()); } - public function testSetCookieFromStringCreatesValidSetCookieHeader() + public function testSetCookieFromStringCreatesValidSetCookieHeader(): void { $setCookieHeader = SetCookie::fromString('Set-Cookie: xxx'); $this->assertInstanceOf(MultipleHeaderInterface::class, $setCookieHeader); @@ -185,7 +185,7 @@ public function testSetCookieFromStringCreatesValidSetCookieHeader() $this->assertInstanceOf(SetCookie::class, $setCookieHeader); } - public function testSetCookieFromStringCanCreateSingleHeader() + public function testSetCookieFromStringCanCreateSingleHeader(): void { $setCookieHeader = SetCookie::fromString('Set-Cookie: myname=myvalue'); $this->assertInstanceOf(HeaderInterface::class, $setCookieHeader); @@ -234,7 +234,7 @@ public function testSetCookieFromStringCanCreateSingleHeader() $this->assertEquals(SetCookie::SAME_SITE_STRICT, $setCookieHeader->getSameSite()); } - public function testFieldValueWithSameSiteCaseInsensitive() + public function testFieldValueWithSameSiteCaseInsensitive(): void { $setCookieHeader = SetCookie::fromString( 'set-cookie: myname=myvalue; SameSite=Strict' @@ -253,7 +253,7 @@ public function testFieldValueWithSameSiteCaseInsensitive() ); } - public function testSetCookieFromStringCanCreateMultipleHeaders() + public function testSetCookieFromStringCanCreateMultipleHeaders(): void { $setCookieHeaders = SetCookie::fromString( 'Set-Cookie: myname=myvalue, ' @@ -279,13 +279,13 @@ public function testSetCookieFromStringCanCreateMultipleHeaders() $this->assertTrue($setCookieHeader->isHttponly()); } - public function testSetCookieGetFieldNameReturnsHeaderName() + public function testSetCookieGetFieldNameReturnsHeaderName(): void { $setCookieHeader = new SetCookie(); $this->assertEquals('Set-Cookie', $setCookieHeader->getFieldName()); } - public function testSetCookieGetFieldValueReturnsProperValue() + public function testSetCookieGetFieldValueReturnsProperValue(): void { $setCookieHeader = new SetCookie(); $setCookieHeader->setName('myname'); @@ -303,11 +303,9 @@ public function testSetCookieGetFieldValueReturnsProperValue() $this->assertEquals($target, $setCookieHeader->getFieldValue()); } - /** - * @group 6673 - * @group 6923 - */ - public function testSetCookieWithDateTimeFieldValueReturnsProperValue() + #[Group('6673')] + #[Group('6923')] + public function testSetCookieWithDateTimeFieldValueReturnsProperValue(): void { $setCookieHeader = new SetCookie(); $setCookieHeader->setName('myname'); @@ -325,7 +323,7 @@ public function testSetCookieWithDateTimeFieldValueReturnsProperValue() $this->assertEquals($target, $setCookieHeader->getFieldValue()); } - public function testSetCookieToStringReturnsHeaderFormattedString() + public function testSetCookieToStringReturnsHeaderFormattedString(): void { $setCookieHeader = new SetCookie(); $setCookieHeader->setName('myname'); @@ -343,7 +341,7 @@ public function testSetCookieToStringReturnsHeaderFormattedString() $this->assertEquals($target, $setCookieHeader->toString()); } - public function testSetCookieCanAppendOtherHeadersInWhenCreatingString() + public function testSetCookieCanAppendOtherHeadersInWhenCreatingString(): void { $setCookieHeader = new SetCookie(); $setCookieHeader->setName('myname'); @@ -370,7 +368,7 @@ public function testSetCookieCanAppendOtherHeadersInWhenCreatingString() $this->assertEquals($target, $headerLine); } - public function testSetCookieAttributesAreUnsettable() + public function testSetCookieAttributesAreUnsettable(): void { $setCookieHeader = new SetCookie(); $setCookieHeader->setName('myname'); @@ -403,7 +401,7 @@ public function testSetCookieAttributesAreUnsettable() $this->assertNull($setCookieHeader->isHttponly()); } - public function testSetCookieFieldValueIsEmptyStringWhenNameIsUnset() + public function testSetCookieFieldValueIsEmptyStringWhenNameIsUnset(): void { $setCookieHeader = new SetCookie(); $this->assertSame('', $setCookieHeader->getFieldValue()); // empty @@ -426,7 +424,7 @@ public function testSetCookieFieldValueIsEmptyStringWhenNameIsUnset() $this->assertNull($setCookieHeader->getName()); } - public function testSetCookieSetExpiresWithZeroTimeStamp() + public function testSetCookieSetExpiresWithZeroTimeStamp(): void { $setCookieHeader = new SetCookie('myname', 'myvalue', 0); $this->assertSame('Thu, 01-Jan-1970 00:00:00 GMT', $setCookieHeader->getExpires()); @@ -441,7 +439,7 @@ public function testSetCookieSetExpiresWithZeroTimeStamp() $this->assertSame($target, $setCookieHeader->getFieldValue()); } - public function testSetCookieSetExpiresWithUnixEpochString() + public function testSetCookieSetExpiresWithUnixEpochString(): void { $setCookieHeader = new SetCookie('myname', 'myvalue', 'Thu, 01-Jan-1970 00:00:00 GMT'); $this->assertSame('Thu, 01-Jan-1970 00:00:00 GMT', $setCookieHeader->getExpires()); @@ -462,7 +460,7 @@ public function testSetCookieSetExpiresWithUnixEpochString() * Check that setCookie does not fail when an expiry date which is bigger * then 2038 is supplied (effect only 32bit systems) */ - public function testSetCookieSetExpiresWithStringDateBiggerThen2038() + public function testSetCookieSetExpiresWithStringDateBiggerThen2038(): void { if (PHP_INT_SIZE !== 4) { $this->markTestSkipped('Testing set cookie expiry which is over 2038 is only relevant on 32bit systems'); @@ -472,7 +470,7 @@ public function testSetCookieSetExpiresWithStringDateBiggerThen2038() $this->assertSame(2147483647, $setCookieHeader->getExpires(true)); } - public function testIsValidForRequestSubdomainMatch() + public function testIsValidForRequestSubdomainMatch(): void { $setCookieHeader = new SetCookie( 'myname', @@ -498,12 +496,8 @@ public function testIsValidForRequestSubdomainMatch() ); // false because of path } - /** Implementation specific tests here */ - - /** - * @group Laminas-169 - */ - public function test169() + #[Group('Laminas-169')] + public function test169(): void { // @codingStandardsIgnoreStart $cookie = 'Set-Cookie: leo_auth_token=example; Version=1; Max-Age=1799; Expires=Mon, 20-Feb-2012 02:49:57 GMT; Path=/'; @@ -512,10 +506,8 @@ public function test169() $this->assertEquals($cookie, $setCookieHeader->toString()); } - /** - * @group Laminas-169 - */ - public function testDoesNotAcceptCookieNameFromArbitraryLocationInHeaderValue() + #[Group('Laminas-169')] + public function testDoesNotAcceptCookieNameFromArbitraryLocationInHeaderValue(): void { // @codingStandardsIgnoreStart $cookie = 'Set-Cookie: Version=1; Max-Age=1799; Expires=Mon, 20-Feb-2012 02:49:57 GMT; Path=/; leo_auth_token=example'; @@ -524,19 +516,14 @@ public function testDoesNotAcceptCookieNameFromArbitraryLocationInHeaderValue() $this->assertNotEquals('leo_auth_token', $setCookieHeader->getName()); } - public function testGetFieldName() + public function testGetFieldName(): void { $c = new SetCookie(); $this->assertEquals('Set-Cookie', $c->getFieldName()); } - /** - * @dataProvider validCookieWithInfoProvider - * @param string $cStr - * @param array $info - * @param string $expected - */ - public function testGetFieldValue($cStr, array $info, $expected) + #[DataProvider('validCookieWithInfoProvider')] + public function testGetFieldValue(string $cStr, array $info, string $expected): void { $cookie = SetCookie::fromString($cStr); if (! $cookie instanceof SetCookie) { @@ -546,13 +533,8 @@ public function testGetFieldValue($cStr, array $info, $expected) $this->assertEquals($cookie->getFieldName() . ': ' . $expected, $cookie->toString()); } - /** - * @dataProvider validCookieWithInfoProvider - * @param string $cStr - * @param array $info - * @param string $expected - */ - public function testToString($cStr, array $info, $expected) + #[DataProvider('validCookieWithInfoProvider')] + public function testToString(string $cStr, array $info, string $expected): void { $cookie = SetCookie::fromString($cStr); if (! $cookie instanceof SetCookie) { @@ -561,7 +543,7 @@ public function testToString($cStr, array $info, $expected) $this->assertEquals($cookie->getFieldName() . ': ' . $expected, $cookie->toString()); } - public function testRfcCompatibility() + public function testRfcCompatibility(): void { $name = 'myname'; $value = 'myvalue'; @@ -582,7 +564,7 @@ public function testRfcCompatibility() $this->assertEquals($cookie->toString(), sprintf($formatUnquoted, $cookie->getFieldName(), $name, $value)); } - public function testSetJsonValue() + public function testSetJsonValue(): void { $cookieName = 'fooCookie'; $jsonData = json_encode(['foo' => 'bar']); @@ -604,10 +586,9 @@ public function testSetJsonValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); SetCookie::fromString("Set-Cookie: leo_auth_token=example;\r\n\r\nevilContent"); @@ -615,23 +596,22 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $header = new SetCookie('leo_auth_token', "example\r\n\r\nevilContent"); $this->assertEquals('Set-Cookie: leo_auth_token=example%0D%0A%0D%0AevilContent', $header->toString()); } - public function testPreventsCRLFAttackViaSetValue() + public function testPreventsCRLFAttackViaSetValue(): void { $header = new SetCookie('leo_auth_token'); $header->setValue("example\r\n\r\nevilContent"); $this->assertEquals('Set-Cookie: leo_auth_token=example%0D%0A%0D%0AevilContent', $header->toString()); } - public function testSetCookieWithEncodeValue() + public function testSetCookieWithEncodeValue(): void { $header = new SetCookie('test'); $header->setValue('a:b'); @@ -640,7 +620,7 @@ public function testSetCookieWithEncodeValue() $this->assertSame('test=a%3Ab', $header->getFieldValue()); } - public function testSetCookieWithNoEncodeValue() + public function testSetCookieWithNoEncodeValue(): void { $header = new SetCookie('test'); $header->setValue('a:b'); @@ -651,7 +631,7 @@ public function testSetCookieWithNoEncodeValue() } /** @psalm-return array */ - public function setterInjections(): array + public static function setterInjections(): array { return [ 'name' => ['setName', "\r\nThis\rIs\nThe\r\nName"], @@ -662,13 +642,10 @@ public function setterInjections(): array /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 - * @dataProvider setterInjections - * @param string $method - * @param string $value */ - public function testPreventsCRLFAttackViaSetters($method, $value) + #[DataProvider('setterInjections')] + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaSetters(string $method, string $value): void { $header = new SetCookie(); $this->expectException(InvalidArgumentException::class); @@ -677,10 +654,8 @@ public function testPreventsCRLFAttackViaSetters($method, $value) /** * Provide valid cookie strings with information about them - * - * @return array */ - public static function validCookieWithInfoProvider() + public static function validCookieWithInfoProvider(): array { $now = time(); $yesterday = $now - (3600 * 24); diff --git a/test/Header/TETest.php b/test/Header/TETest.php index f4b4c191..48faa446 100644 --- a/test/Header/TETest.php +++ b/test/Header/TETest.php @@ -5,24 +5,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\TE; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class TETest extends TestCase { - public function testTEFromStringCreatesValidTEHeader() + public function testTEFromStringCreatesValidTEHeader(): void { $tEHeader = TE::fromString('TE: xxx'); $this->assertInstanceOf(HeaderInterface::class, $tEHeader); $this->assertInstanceOf(TE::class, $tEHeader); } - public function testTEGetFieldNameReturnsHeaderName() + public function testTEGetFieldNameReturnsHeaderName(): void { $tEHeader = new TE(); $this->assertEquals('TE', $tEHeader->getFieldName()); } - public function testTEGetFieldValueReturnsProperValue() + public function testTEGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('TE needs to be completed'); @@ -30,7 +31,7 @@ public function testTEGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $tEHeader->getFieldValue()); } - public function testTEToStringReturnsHeaderFormattedString() + public function testTEToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('TE needs to be completed'); @@ -41,13 +42,11 @@ public function testTEToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); TE::fromString("TE: xxx\r\n\r\nevilContent"); @@ -55,10 +54,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new TE("xxx\r\n\r\nevilContent"); diff --git a/test/Header/TrailerTest.php b/test/Header/TrailerTest.php index 21ceeb4d..3f803011 100644 --- a/test/Header/TrailerTest.php +++ b/test/Header/TrailerTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Trailer; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class TrailerTest extends TestCase { - public function testTrailerFromStringCreatesValidTrailerHeader() + public function testTrailerFromStringCreatesValidTrailerHeader(): void { $trailerHeader = Trailer::fromString('Trailer: xxx'); $this->assertInstanceOf(HeaderInterface::class, $trailerHeader); $this->assertInstanceOf(Trailer::class, $trailerHeader); } - public function testTrailerGetFieldNameReturnsHeaderName() + public function testTrailerGetFieldNameReturnsHeaderName(): void { $trailerHeader = new Trailer(); $this->assertEquals('Trailer', $trailerHeader->getFieldName()); } - public function testTrailerGetFieldValueReturnsProperValue() + public function testTrailerGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Trailer needs to be completed'); @@ -32,7 +33,7 @@ public function testTrailerGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $trailerHeader->getFieldValue()); } - public function testTrailerToStringReturnsHeaderFormattedString() + public function testTrailerToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Trailer needs to be completed'); @@ -43,13 +44,11 @@ public function testTrailerToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Trailer::fromString("Trailer: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Trailer("xxx\r\n\r\nevilContent"); diff --git a/test/Header/TransferEncodingTest.php b/test/Header/TransferEncodingTest.php index 6c028951..1a0ff796 100644 --- a/test/Header/TransferEncodingTest.php +++ b/test/Header/TransferEncodingTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\TransferEncoding; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class TransferEncodingTest extends TestCase { - public function testTransferEncodingFromStringCreatesValidTransferEncodingHeader() + public function testTransferEncodingFromStringCreatesValidTransferEncodingHeader(): void { $transferEncodingHeader = TransferEncoding::fromString('Transfer-Encoding: xxx'); $this->assertInstanceOf(HeaderInterface::class, $transferEncodingHeader); $this->assertInstanceOf(TransferEncoding::class, $transferEncodingHeader); } - public function testTransferEncodingGetFieldNameReturnsHeaderName() + public function testTransferEncodingGetFieldNameReturnsHeaderName(): void { $transferEncodingHeader = new TransferEncoding(); $this->assertEquals('Transfer-Encoding', $transferEncodingHeader->getFieldName()); } - public function testTransferEncodingGetFieldValueReturnsProperValue() + public function testTransferEncodingGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('TransferEncoding needs to be completed'); @@ -32,7 +33,7 @@ public function testTransferEncodingGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $transferEncodingHeader->getFieldValue()); } - public function testTransferEncodingToStringReturnsHeaderFormattedString() + public function testTransferEncodingToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('TransferEncoding needs to be completed'); @@ -43,13 +44,11 @@ public function testTransferEncodingToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); TransferEncoding::fromString("Transfer-Encoding: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new TransferEncoding("xxx\r\n\r\nevilContent"); diff --git a/test/Header/UpgradeTest.php b/test/Header/UpgradeTest.php index 175b9f5b..97bf7e7b 100644 --- a/test/Header/UpgradeTest.php +++ b/test/Header/UpgradeTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Upgrade; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class UpgradeTest extends TestCase { - public function testUpgradeFromStringCreatesValidUpgradeHeader() + public function testUpgradeFromStringCreatesValidUpgradeHeader(): void { $upgradeHeader = Upgrade::fromString('Upgrade: xxx'); $this->assertInstanceOf(HeaderInterface::class, $upgradeHeader); $this->assertInstanceOf(Upgrade::class, $upgradeHeader); } - public function testUpgradeGetFieldNameReturnsHeaderName() + public function testUpgradeGetFieldNameReturnsHeaderName(): void { $upgradeHeader = new Upgrade(); $this->assertEquals('Upgrade', $upgradeHeader->getFieldName()); } - public function testUpgradeGetFieldValueReturnsProperValue() + public function testUpgradeGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Upgrade needs to be completed'); @@ -32,7 +33,7 @@ public function testUpgradeGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $upgradeHeader->getFieldValue()); } - public function testUpgradeToStringReturnsHeaderFormattedString() + public function testUpgradeToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Upgrade needs to be completed'); @@ -43,13 +44,11 @@ public function testUpgradeToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Upgrade::fromString("Upgrade: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Upgrade("xxx\r\n\r\nevilContent"); diff --git a/test/Header/UserAgentTest.php b/test/Header/UserAgentTest.php index dde7f8dc..81385c15 100644 --- a/test/Header/UserAgentTest.php +++ b/test/Header/UserAgentTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\UserAgent; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class UserAgentTest extends TestCase { - public function testUserAgentFromStringCreatesValidUserAgentHeader() + public function testUserAgentFromStringCreatesValidUserAgentHeader(): void { $userAgentHeader = UserAgent::fromString('User-Agent: xxx'); $this->assertInstanceOf(HeaderInterface::class, $userAgentHeader); $this->assertInstanceOf(UserAgent::class, $userAgentHeader); } - public function testUserAgentGetFieldNameReturnsHeaderName() + public function testUserAgentGetFieldNameReturnsHeaderName(): void { $userAgentHeader = new UserAgent(); $this->assertEquals('User-Agent', $userAgentHeader->getFieldName()); } - public function testUserAgentGetFieldValueReturnsProperValue() + public function testUserAgentGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('UserAgent needs to be completed'); @@ -32,7 +33,7 @@ public function testUserAgentGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $userAgentHeader->getFieldValue()); } - public function testUserAgentToStringReturnsHeaderFormattedString() + public function testUserAgentToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('UserAgent needs to be completed'); @@ -43,13 +44,11 @@ public function testUserAgentToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); UserAgent::fromString("User-Agent: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new UserAgent("xxx\r\n\r\nevilContent"); diff --git a/test/Header/VaryTest.php b/test/Header/VaryTest.php index fcb52b14..075f3557 100644 --- a/test/Header/VaryTest.php +++ b/test/Header/VaryTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Vary; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class VaryTest extends TestCase { - public function testVaryFromStringCreatesValidVaryHeader() + public function testVaryFromStringCreatesValidVaryHeader(): void { $varyHeader = Vary::fromString('Vary: xxx'); $this->assertInstanceOf(HeaderInterface::class, $varyHeader); $this->assertInstanceOf(Vary::class, $varyHeader); } - public function testVaryGetFieldNameReturnsHeaderName() + public function testVaryGetFieldNameReturnsHeaderName(): void { $varyHeader = new Vary(); $this->assertEquals('Vary', $varyHeader->getFieldName()); } - public function testVaryGetFieldValueReturnsProperValue() + public function testVaryGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Vary needs to be completed'); @@ -32,7 +33,7 @@ public function testVaryGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $varyHeader->getFieldValue()); } - public function testVaryToStringReturnsHeaderFormattedString() + public function testVaryToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Vary needs to be completed'); @@ -43,13 +44,11 @@ public function testVaryToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Vary::fromString("Vary: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Vary("xxx\r\n\r\nevilContent"); diff --git a/test/Header/ViaTest.php b/test/Header/ViaTest.php index 84335f2e..7adec63a 100644 --- a/test/Header/ViaTest.php +++ b/test/Header/ViaTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Via; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class ViaTest extends TestCase { - public function testViaFromStringCreatesValidViaHeader() + public function testViaFromStringCreatesValidViaHeader(): void { $viaHeader = Via::fromString('Via: xxx'); $this->assertInstanceOf(HeaderInterface::class, $viaHeader); $this->assertInstanceOf(Via::class, $viaHeader); } - public function testViaGetFieldNameReturnsHeaderName() + public function testViaGetFieldNameReturnsHeaderName(): void { $viaHeader = new Via(); $this->assertEquals('Via', $viaHeader->getFieldName()); } - public function testViaGetFieldValueReturnsProperValue() + public function testViaGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Via needs to be completed'); @@ -32,7 +33,7 @@ public function testViaGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $viaHeader->getFieldValue()); } - public function testViaToStringReturnsHeaderFormattedString() + public function testViaToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Via needs to be completed'); @@ -43,13 +44,11 @@ public function testViaToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Via::fromString("Via: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Via("xxx\r\n\r\nevilContent"); diff --git a/test/Header/WWWAuthenticateTest.php b/test/Header/WWWAuthenticateTest.php index 8a7f165c..ee47fab4 100644 --- a/test/Header/WWWAuthenticateTest.php +++ b/test/Header/WWWAuthenticateTest.php @@ -5,24 +5,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\WWWAuthenticate; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class WWWAuthenticateTest extends TestCase { - public function testWWWAuthenticateFromStringCreatesValidWWWAuthenticateHeader() + public function testWWWAuthenticateFromStringCreatesValidWWWAuthenticateHeader(): void { $wWWAuthenticateHeader = WWWAuthenticate::fromString('WWW-Authenticate: xxx'); $this->assertInstanceOf(HeaderInterface::class, $wWWAuthenticateHeader); $this->assertInstanceOf(WWWAuthenticate::class, $wWWAuthenticateHeader); } - public function testWWWAuthenticateGetFieldNameReturnsHeaderName() + public function testWWWAuthenticateGetFieldNameReturnsHeaderName(): void { $wWWAuthenticateHeader = new WWWAuthenticate(); $this->assertEquals('WWW-Authenticate', $wWWAuthenticateHeader->getFieldName()); } - public function testWWWAuthenticateGetFieldValueReturnsProperValue() + public function testWWWAuthenticateGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('WWWAuthenticate needs to be completed'); @@ -30,7 +31,7 @@ public function testWWWAuthenticateGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $wWWAuthenticateHeader->getFieldValue()); } - public function testWWWAuthenticateToStringReturnsHeaderFormattedString() + public function testWWWAuthenticateToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('WWWAuthenticate needs to be completed'); @@ -41,13 +42,11 @@ public function testWWWAuthenticateToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); WWWAuthenticate::fromString("WWW-Authenticate: xxx\r\n\r\nevilContent"); @@ -55,10 +54,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new WWWAuthenticate("xxx\r\n\r\nevilContent"); diff --git a/test/Header/WarningTest.php b/test/Header/WarningTest.php index f0528d0c..11a51409 100644 --- a/test/Header/WarningTest.php +++ b/test/Header/WarningTest.php @@ -7,24 +7,25 @@ use Laminas\Http\Header\Exception\InvalidArgumentException; use Laminas\Http\Header\HeaderInterface; use Laminas\Http\Header\Warning; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; class WarningTest extends TestCase { - public function testWarningFromStringCreatesValidWarningHeader() + public function testWarningFromStringCreatesValidWarningHeader(): void { $warningHeader = Warning::fromString('Warning: xxx'); $this->assertInstanceOf(HeaderInterface::class, $warningHeader); $this->assertInstanceOf(Warning::class, $warningHeader); } - public function testWarningGetFieldNameReturnsHeaderName() + public function testWarningGetFieldNameReturnsHeaderName(): void { $warningHeader = new Warning(); $this->assertEquals('Warning', $warningHeader->getFieldName()); } - public function testWarningGetFieldValueReturnsProperValue() + public function testWarningGetFieldValueReturnsProperValue(): void { $this->markTestIncomplete('Warning needs to be completed'); @@ -32,7 +33,7 @@ public function testWarningGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $warningHeader->getFieldValue()); } - public function testWarningToStringReturnsHeaderFormattedString() + public function testWarningToStringReturnsHeaderFormattedString(): void { $this->markTestIncomplete('Warning needs to be completed'); @@ -43,13 +44,11 @@ public function testWarningToStringReturnsHeaderFormattedString() } /** Implementation specific tests here */ - /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaFromString() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaFromString(): void { $this->expectException(InvalidArgumentException::class); Warning::fromString("Warning: xxx\r\n\r\nevilContent"); @@ -57,10 +56,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackViaConstructor() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackViaConstructor(): void { $this->expectException(InvalidArgumentException::class); new Warning("xxx\r\n\r\nevilContent"); diff --git a/test/HeaderTest.php b/test/HeaderTest.php index c1f4c5a2..35eafae4 100644 --- a/test/HeaderTest.php +++ b/test/HeaderTest.php @@ -6,6 +6,7 @@ use Laminas\Http\Exception\InvalidArgumentException; use Laminas\Http\Header; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use function strtolower; @@ -14,7 +15,7 @@ class HeaderTest extends TestCase { /** @psalm-return iterable */ - public function header(): iterable + public static function header(): iterable { // phpcs:disable Generic.Files.LineLength.TooLong yield Header\AcceptRanges::class => [Header\AcceptRanges::class, 'Accept-Ranges']; @@ -58,11 +59,10 @@ public function header(): iterable /** * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity - * @dataProvider header - * @param string $class - * @param string $name + * */ - public function testThrowsExceptionIfInvalidHeaderLine($class, $name) + #[DataProvider('header')] + public function testThrowsExceptionIfInvalidHeaderLine(string $class, string $name): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid header line for ' . $name . ' string'); @@ -71,11 +71,10 @@ public function testThrowsExceptionIfInvalidHeaderLine($class, $name) /** * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity - * @dataProvider header - * @param string $class - * @param string $name + * */ - public function testCaseInsensitiveHeaderName($class, $name) + #[DataProvider('header')] + public function testCaseInsensitiveHeaderName(string $class, string $name): void { $header1 = $class::fromString(strtoupper($name) . ': foo'); self::assertSame('foo', $header1->getFieldValue()); @@ -86,11 +85,10 @@ public function testCaseInsensitiveHeaderName($class, $name) /** * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity - * @dataProvider header - * @param string $class - * @param string $name + * */ - public function testDefaultValues($class, $name) + #[DataProvider('header')] + public function testDefaultValues(string $class, string $name): void { $header = new $class(); @@ -101,11 +99,10 @@ public function testDefaultValues($class, $name) /** * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity - * @dataProvider header - * @param string $class - * @param string $name + * */ - public function testSetValueViaConstructor($class, $name) + #[DataProvider('header')] + public function testSetValueViaConstructor(string $class, string $name): void { $header = new $class('foo-bar'); @@ -115,14 +112,14 @@ public function testSetValueViaConstructor($class, $name) /** * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity - * @dataProvider header - * @param string $class + * * @param string $name * * Note: in theory this is invalid, as we would expect value to be string|null. * Null is default value but it is converted to string. */ - public function testSetIntValueViaConstructor($class, $name) + #[DataProvider('header')] + public function testSetIntValueViaConstructor(string $class, string $name): void { $header = new $class(100); @@ -132,11 +129,10 @@ public function testSetIntValueViaConstructor($class, $name) /** * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity - * @dataProvider header - * @param string $class - * @param string $name + * */ - public function testSetZeroStringValueViaConstructor($class, $name) + #[DataProvider('header')] + public function testSetZeroStringValueViaConstructor(string $class, string $name): void { $header = new $class('0'); @@ -146,11 +142,10 @@ public function testSetZeroStringValueViaConstructor($class, $name) /** * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity - * @dataProvider header - * @param string $class - * @param string $name + * */ - public function testFromStringWithNumber($class, $name) + #[DataProvider('header')] + public function testFromStringWithNumber(string $class, string $name): void { $header = $class::fromString($name . ': 100'); diff --git a/test/HeadersTest.php b/test/HeadersTest.php index 335727e4..3f47c68e 100644 --- a/test/HeadersTest.php +++ b/test/HeadersTest.php @@ -15,6 +15,7 @@ use Laminas\Http\Header\HeaderInterface; use Laminas\Http\HeaderLoader; use Laminas\Http\Headers; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function implode; @@ -22,20 +23,20 @@ class HeadersTest extends TestCase { - public function testHeadersImplementsProperClasses() + public function testHeadersImplementsProperClasses(): void { $headers = new Headers(); $this->assertInstanceOf(Iterator::class, $headers); $this->assertInstanceOf(Countable::class, $headers); } - public function testHeadersCanGetPluginClassLoader() + public function testHeadersCanGetPluginClassLoader(): void { $headers = new Headers(); $this->assertInstanceOf(HeaderLoader::class, $headers->getPluginClassLoader()); } - public function testHeadersFromStringFactoryCreatesSingleObject() + public function testHeadersFromStringFactoryCreatesSingleObject(): void { $headers = Headers::fromString('Fake: foo-bar'); $this->assertEquals(1, $headers->count()); @@ -46,7 +47,7 @@ public function testHeadersFromStringFactoryCreatesSingleObject() $this->assertEquals('foo-bar', $header->getFieldValue()); } - public function testHeadersFromStringFactoryCreatesSingleObjectWithHeaderBreakLine() + public function testHeadersFromStringFactoryCreatesSingleObjectWithHeaderBreakLine(): void { $headers = Headers::fromString("Fake: foo-bar\r\n\r\n"); $this->assertEquals(1, $headers->count()); @@ -57,7 +58,7 @@ public function testHeadersFromStringFactoryCreatesSingleObjectWithHeaderBreakLi $this->assertEquals('foo-bar', $header->getFieldValue()); } - public function testHeadersFromStringFactoryCreatesSingleObjectWithHeaderFolding() + public function testHeadersFromStringFactoryCreatesSingleObjectWithHeaderFolding(): void { $headers = Headers::fromString("Fake: foo\r\n -bar"); $this->assertEquals(1, $headers->count()); @@ -68,14 +69,14 @@ public function testHeadersFromStringFactoryCreatesSingleObjectWithHeaderFolding $this->assertEquals('foo-bar', $header->getFieldValue()); } - public function testHeadersFromStringFactoryThrowsExceptionOnMalformedHeaderLine() + public function testHeadersFromStringFactoryThrowsExceptionOnMalformedHeaderLine(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('does not match'); Headers::fromString("Fake = foo-bar\r\n\r\n"); } - public function testHeadersFromStringFactoryCreatesMultipleObjects() + public function testHeadersFromStringFactoryCreatesMultipleObjects(): void { $headers = Headers::fromString("Fake: foo-bar\r\nAnother-Fake: boo-baz"); $this->assertEquals(2, $headers->count()); @@ -97,7 +98,7 @@ public function testHeadersFromStringFactoryCreatesMultipleObjects() $this->assertSame($header, $headers->get('another.fake')); } - public function testHeadersFromStringMultiHeaderWillAggregateLazyLoadedHeaders() + public function testHeadersFromStringMultiHeaderWillAggregateLazyLoadedHeaders(): void { $headers = new Headers(); $pcl = $headers->getPluginClassLoader(); @@ -107,7 +108,7 @@ public function testHeadersFromStringMultiHeaderWillAggregateLazyLoadedHeaders() $this->assertEquals(3, $headers->count()); } - public function testHeadersHasAndGetWorkProperly() + public function testHeadersHasAndGetWorkProperly(): void { $headers = new Headers(); $headers->addHeaders([ @@ -120,7 +121,7 @@ public function testHeadersHasAndGetWorkProperly() $this->assertSame($f, $headers->get('foo')); } - public function testHeadersGetReturnsLastAddedHeaderValue() + public function testHeadersGetReturnsLastAddedHeaderValue(): void { $headers = new Headers(); $headers->addHeaders([ @@ -131,7 +132,7 @@ public function testHeadersGetReturnsLastAddedHeaderValue() $this->assertEquals($value, $headers->get('foo')->getFieldValue()); } - public function testHeadersAggregatesHeaderObjects() + public function testHeadersAggregatesHeaderObjects(): void { $fakeHeader = new Header\GenericHeader('Fake', 'bar'); $headers = new Headers(); @@ -140,7 +141,7 @@ public function testHeadersAggregatesHeaderObjects() $this->assertSame($fakeHeader, $headers->get('Fake')); } - public function testHeadersAggregatesHeaderThroughAddHeader() + public function testHeadersAggregatesHeaderThroughAddHeader(): void { $headers = new Headers(); $headers->addHeader(new Header\GenericHeader('Fake', 'bar')); @@ -148,7 +149,7 @@ public function testHeadersAggregatesHeaderThroughAddHeader() $this->assertInstanceOf(GenericHeader::class, $headers->get('Fake')); } - public function testHeadersAggregatesHeaderThroughAddHeaderLine() + public function testHeadersAggregatesHeaderThroughAddHeaderLine(): void { $headers = new Headers(); $headers->addHeaderLine('Fake', 'bar'); @@ -156,7 +157,7 @@ public function testHeadersAggregatesHeaderThroughAddHeaderLine() $this->assertInstanceOf(GenericHeader::class, $headers->get('Fake')); } - public function testHeadersAddHeaderLineThrowsExceptionOnMissingFieldValue() + public function testHeadersAddHeaderLineThrowsExceptionOnMissingFieldValue(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('without a field'); @@ -164,7 +165,7 @@ public function testHeadersAddHeaderLineThrowsExceptionOnMissingFieldValue() $headers->addHeaderLine('Foo'); } - public function testHeadersAggregatesHeadersThroughAddHeaders() + public function testHeadersAggregatesHeadersThroughAddHeaders(): void { $headers = new Headers(); $headers->addHeaders([new Header\GenericHeader('Foo', 'bar'), new Header\GenericHeader('Baz', 'baz')]); @@ -202,7 +203,7 @@ public function testHeadersAggregatesHeadersThroughAddHeaders() $this->assertEquals('baz', $headers->get('baz')->getFieldValue()); } - public function testHeadersAddHeadersThrowsExceptionOnInvalidArguments() + public function testHeadersAddHeadersThrowsExceptionOnInvalidArguments(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Expected array or Trav'); @@ -210,7 +211,7 @@ public function testHeadersAddHeadersThrowsExceptionOnInvalidArguments() $headers->addHeaders('foo'); } - public function testHeadersCanRemoveHeader() + public function testHeadersCanRemoveHeader(): void { $headers = new Headers(); $headers->addHeaders(['Foo' => 'bar', 'Baz' => 'baz']); @@ -221,7 +222,7 @@ public function testHeadersCanRemoveHeader() $this->assertFalse($headers->get('foo')); } - public function testHeadersCanClearAllHeaders() + public function testHeadersCanClearAllHeaders(): void { $headers = new Headers(); $headers->addHeaders(['Foo' => 'bar', 'Baz' => 'baz']); @@ -230,7 +231,7 @@ public function testHeadersCanClearAllHeaders() $this->assertEquals(0, $headers->count()); } - public function testHeadersCanBeIterated() + public function testHeadersCanBeIterated(): void { $headers = new Headers(); $headers->addHeaders(['Foo' => 'bar', 'Baz' => 'baz']); @@ -254,21 +255,21 @@ public function testHeadersCanBeIterated() $this->assertEquals(2, $iterations); } - public function testHeadersCanBeCastToString() + public function testHeadersCanBeCastToString(): void { $headers = new Headers(); $headers->addHeaders(['Foo' => 'bar', 'Baz' => 'baz']); $this->assertEquals('Foo: bar' . "\r\n" . 'Baz: baz' . "\r\n", $headers->toString()); } - public function testHeadersCanBeCastToArray() + public function testHeadersCanBeCastToArray(): void { $headers = new Headers(); $headers->addHeaders(['Foo' => 'bar', 'Baz' => 'baz']); $this->assertEquals(['Foo' => 'bar', 'Baz' => 'baz'], $headers->toArray()); } - public function testCastingToArrayReturnsMultiHeadersAsArrays() + public function testCastingToArrayReturnsMultiHeadersAsArrays(): void { $headers = new Headers(); $cookie1 = new Header\SetCookie('foo', 'bar'); @@ -285,7 +286,7 @@ public function testCastingToArrayReturnsMultiHeadersAsArrays() $this->assertEquals($expected, $array); } - public function testCastingToStringReturnsAllMultiHeaderValues() + public function testCastingToStringReturnsAllMultiHeaderValues(): void { $headers = new Headers(); $cookie1 = new Header\SetCookie('foo', 'bar'); @@ -301,7 +302,7 @@ public function testCastingToStringReturnsAllMultiHeaderValues() $this->assertEquals($expected, $string); } - public function testZeroIsAValidHeaderValue() + public function testZeroIsAValidHeaderValue(): void { $headers = Headers::fromString('Fake: 0'); $this->assertSame('0', $headers->get('Fake')->getFieldValue()); @@ -309,16 +310,15 @@ public function testZeroIsAValidHeaderValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testCRLFAttack() + #[Group('ZF2015-04')] + public function testCRLFAttack(): void { $this->expectException(RuntimeException::class); Headers::fromString("Fake: foo-bar\r\n\r\nevilContent"); } - public function testAddHeaderLineMultipleHeadersGet() + public function testAddHeaderLineMultipleHeadersGet(): void { $headers = new Headers(); $headers->addHeaderLine('Set-Cookie: cookie1=value1'); @@ -330,7 +330,7 @@ public function testAddHeaderLineMultipleHeadersGet() self::assertContainsOnlyInstancesOf(Header\SetCookie::class, $result); } - public function testAddHeaderLineMultipleHeadersToString() + public function testAddHeaderLineMultipleHeadersToString(): void { $headers = new Headers(); $headers->addHeaderLine('Set-Cookie: cookie1=value1'); @@ -343,7 +343,7 @@ public function testAddHeaderLineMultipleHeadersToString() ); } - public function testAddHeaderMultipleHeadersGet() + public function testAddHeaderMultipleHeadersGet(): void { $headers = new Headers(); $headers->addHeader(new Header\SetCookie('cookie1', 'value1')); @@ -355,7 +355,7 @@ public function testAddHeaderMultipleHeadersGet() self::assertContainsOnlyInstancesOf(Header\SetCookie::class, $result); } - public function testAddHeaderMultipleHeadersToString() + public function testAddHeaderMultipleHeadersToString(): void { $headers = new Headers(); $headers->addHeader(new Header\SetCookie('cookie1', 'value1')); @@ -368,7 +368,7 @@ public function testAddHeaderMultipleHeadersToString() ); } - public function testAddHeadersMultipleHeadersGet() + public function testAddHeadersMultipleHeadersGet(): void { $headers = new Headers(); $headers->addHeaders([ @@ -385,7 +385,7 @@ public function testAddHeadersMultipleHeadersGet() self::assertContainsOnlyInstancesOf(Header\SetCookie::class, $result); } - public function testAddHeadersMultipleHeadersToString() + public function testAddHeadersMultipleHeadersToString(): void { $headers = new Headers(); $headers->addHeaders([ @@ -406,7 +406,7 @@ public function testAddHeadersMultipleHeadersToString() ); } - public function testFromStringMultipleHeadersGet() + public function testFromStringMultipleHeadersGet(): void { $headers = Headers::fromString( 'Set-Cookie: cookie1=value1' . "\r\n" @@ -419,7 +419,7 @@ public function testFromStringMultipleHeadersGet() self::assertContainsOnlyInstancesOf(Header\SetCookie::class, $result); } - public function testFromStringHeadersToString() + public function testFromStringHeadersToString(): void { $headers = Headers::fromString( 'Set-Cookie: cookie1=value1' . "\r\n" @@ -433,7 +433,7 @@ public function testFromStringHeadersToString() ); } - public function testThrowExceptionOnInvalidHeader() + public function testThrowExceptionOnInvalidHeader(): void { $headers = new Headers(); $headers->addHeaderLine('Location', "/mail\r\ntest"); @@ -443,7 +443,7 @@ public function testThrowExceptionOnInvalidHeader() $headers->get('Location'); } - public function testToArrayCanHandleIteratorExtensionForMultipleHeaderValue() + public function testToArrayCanHandleIteratorExtensionForMultipleHeaderValue(): void { $headerValue = 'cookie1=value1; Expires=Sun, 02-Jan-2022 08:54:16 GMT; Domain=.example.org; Path=/;' . ' Secure; SameSite=Lax, cookie2=value2; Expires=Sun, 02-Jan-2022 08:54:16 GMT; Domain=.example.org; Path=/;' diff --git a/test/PhpEnvironment/Assets/MockHeadersSent.php b/test/PhpEnvironment/Assets/MockHeadersSent.php new file mode 100644 index 00000000..4ed72378 --- /dev/null +++ b/test/PhpEnvironment/Assets/MockHeadersSent.php @@ -0,0 +1,7 @@ +originalEnvironment['files']; } - public function testSetGetUseProxy() + public function testSetGetUseProxy(): void { $this->remoteAddress->setUseProxy(false); $this->assertFalse($this->remoteAddress->getUseProxy()); } - public function testSetGetDefaultUseProxy() + public function testSetGetDefaultUseProxy(): void { $this->remoteAddress->setUseProxy(); $this->assertTrue($this->remoteAddress->getUseProxy()); } - public function testSetTrustedProxies() + public function testSetTrustedProxies(): void { $result = $this->remoteAddress->setTrustedProxies([ '192.168.0.10', @@ -77,13 +77,13 @@ public function testSetTrustedProxies() $this->assertInstanceOf(RemoteAddr::class, $result); } - public function testGetIpAddress() + public function testGetIpAddress(): void { $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $this->assertEquals('127.0.0.1', $this->remoteAddress->getIpAddress()); } - public function testGetIpAddressFromProxy() + public function testGetIpAddressFromProxy(): void { $this->remoteAddress->setUseProxy(true); $this->remoteAddress->setTrustedProxies([ @@ -95,7 +95,7 @@ public function testGetIpAddressFromProxy() $this->assertEquals('8.8.8.8', $this->remoteAddress->getIpAddress()); } - public function testGetIpAddressFromProxyRemoteAddressNotTrusted() + public function testGetIpAddressFromProxyRemoteAddressNotTrusted(): void { $this->remoteAddress->setUseProxy(true); $this->remoteAddress->setTrustedProxies([ @@ -113,7 +113,7 @@ public function testGetIpAddressFromProxyRemoteAddressNotTrusted() * * @see http://tools.ietf.org/html/draft-ietf-appsawg-http-forwarded-10#section-5.2 */ - public function testGetIpAddressFromProxyFakeData() + public function testGetIpAddressFromProxyFakeData(): void { $this->remoteAddress->setUseProxy(true); $this->remoteAddress->setTrustedProxies([ @@ -135,7 +135,7 @@ public function testGetIpAddressFromProxyFakeData() * This happens when you run a local unit test, or a PHP script with * PHP from the command line. */ - public function testGetIpAddressReturnsEmptyStringOnNoRemoteAddr() + public function testGetIpAddressReturnsEmptyStringOnNoRemoteAddr(): void { // Store the set IP address for later use if (isset($_SERVER['REMOTE_ADDR'])) { diff --git a/test/PhpEnvironment/RequestTest.php b/test/PhpEnvironment/RequestTest.php index 2a014500..86685297 100644 --- a/test/PhpEnvironment/RequestTest.php +++ b/test/PhpEnvironment/RequestTest.php @@ -9,6 +9,8 @@ use Laminas\Http\Headers; use Laminas\Http\PhpEnvironment\Request; use Laminas\Stdlib\Parameters; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function md5; @@ -213,13 +215,8 @@ public static function baseUrlAndPathProvider(): array ]; } - /** - * @dataProvider baseUrlAndPathProvider - * @param array $server - * @param string $baseUrl - * @param string $basePath - */ - public function testBasePathDetection(array $server, $baseUrl, $basePath) + #[DataProvider('baseUrlAndPathProvider')] + public function testBasePathDetection(array $server, string $baseUrl, string $basePath): void { $_SERVER = $server; $request = new Request(); @@ -292,13 +289,8 @@ public static function serverHeaderProvider(): array ]; } - /** - * @dataProvider serverHeaderProvider - * @param array $server - * @param string $name - * @param string $value - */ - public function testHeadersWithMinus(array $server, $name, $value) + #[DataProvider('serverHeaderProvider')] + public function testHeadersWithMinus(array $server, string $name, string|int $value): void { $_SERVER = $server; $request = new Request(); @@ -309,12 +301,8 @@ public function testHeadersWithMinus(array $server, $name, $value) $this->assertEquals($value, $header->getFieldValue($value)); } - /** - * @dataProvider serverHeaderProvider - * @param array $server - * @param string $name - */ - public function testRequestStringHasCorrectHeaderName(array $server, $name) + #[DataProvider('serverHeaderProvider')] + public function testRequestStringHasCorrectHeaderName(array $server, string $name): void { $_SERVER = $server; $request = new Request(); @@ -442,15 +430,13 @@ public static function serverHostnameProvider(): array ]; } - /** - * @dataProvider serverHostnameProvider - * @param array $server - * @param string $expectedHost - * @param string $expectedPort - * @param string $expectedRequestUri - */ - public function testServerHostnameProvider(array $server, $expectedHost, $expectedPort, $expectedRequestUri) - { + #[DataProvider('serverHostnameProvider')] + public function testServerHostnameProvider( + array $server, + string $expectedHost, + string $expectedPort, + string $expectedRequestUri + ): void { $_SERVER = $server; $request = new Request(); @@ -472,10 +458,8 @@ public function testServerHostnameProvider(array $server, $expectedHost, $expect /** * Data provider for testing mapping $_FILES - * - * @return array */ - public static function filesProvider() + public static function filesProvider(): array { return [ // single file @@ -688,19 +672,15 @@ public static function filesProvider() ]; } - /** - * @dataProvider filesProvider - * @param array $files - * @param array $expectedFiles - */ - public function testRequestMapsPhpFies(array $files, array $expectedFiles) + #[DataProvider('filesProvider')] + public function testRequestMapsPhpFies(array $files, array $expectedFiles): void { $_FILES = $files; $request = new Request(); $this->assertEquals($expectedFiles, $request->getFiles()->toArray()); } - public function testParameterRetrievalDefaultValue() + public function testParameterRetrievalDefaultValue(): void { $request = new Request(); $p = new Parameters([ @@ -722,7 +702,7 @@ public function testParameterRetrievalDefaultValue() $this->assertSame($default, $request->getHeader('baz', $default)); } - public function testRetrievingASingleValueForParameters() + public function testRetrievingASingleValueForParameters(): void { $request = new Request(); $p = new Parameters([ @@ -750,10 +730,8 @@ public function testRetrievingASingleValueForParameters() $this->assertSame($h, $request->getHeader('foo')); } - /** - * @group Laminas-480 - */ - public function testBaseurlFallsBackToRootPathIfScriptFilenameIsNotSet() + #[Group('Laminas-480')] + public function testBaseurlFallsBackToRootPathIfScriptFilenameIsNotSet(): void { $request = new Request(); $server = $request->getServer(); @@ -766,7 +744,7 @@ public function testBaseurlFallsBackToRootPathIfScriptFilenameIsNotSet() $this->assertEquals('', $request->getBaseUrl()); } - public function testAllowCustomMethodsFlagCanBeSetWithConstructor() + public function testAllowCustomMethodsFlagCanBeSetWithConstructor(): void { $_SERVER['REQUEST_METHOD'] = 'xcustomx'; @@ -776,10 +754,8 @@ public function testAllowCustomMethodsFlagCanBeSetWithConstructor() new Request(false); } - /** - * @group 6896 - */ - public function testHandlesUppercaseHttpsFlags() + #[Group('6896')] + public function testHandlesUppercaseHttpsFlags(): void { $_SERVER['HTTPS'] = 'OFF'; @@ -788,10 +764,8 @@ public function testHandlesUppercaseHttpsFlags() $this->assertSame('http', $request->getUri()->getScheme()); } - /** - * @group 14 - */ - public function testDetectBaseUrlDoesNotRaiseErrorOnEmptyBaseUrl() + #[Group('14')] + public function testDetectBaseUrlDoesNotRaiseErrorOnEmptyBaseUrl(): void { // This is testing that a PHP error is not raised. It would normally be // raised when we call `getBaseUrl()`; the assertion is essentially @@ -806,7 +780,7 @@ public function testDetectBaseUrlDoesNotRaiseErrorOnEmptyBaseUrl() $this->assertEquals('', $url); } - public function testDetectCorrectBaseUrlForConsoleRequests() + public function testDetectCorrectBaseUrlForConsoleRequests(): void { $_SERVER['argv'] = ['/home/user/package/vendor/bin/phpunit']; $_SERVER['argc'] = 1; diff --git a/test/PhpEnvironment/ResponseTest.php b/test/PhpEnvironment/ResponseTest.php index 48e1a7db..5ac11fe9 100644 --- a/test/PhpEnvironment/ResponseTest.php +++ b/test/PhpEnvironment/ResponseTest.php @@ -7,6 +7,7 @@ use Laminas\Http\Exception\InvalidArgumentException; use Laminas\Http\Exception\RuntimeException; use Laminas\Http\PhpEnvironment\Response; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; class ResponseTest extends TestCase @@ -53,7 +54,7 @@ public function tearDown(): void $_FILES = $this->originalEnvironment['files']; } - public function testReturnsOneOhVersionWhenDetectedInServerSuperglobal() + public function testReturnsOneOhVersionWhenDetectedInServerSuperglobal(): void { // HTTP/1.0 $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0'; @@ -61,7 +62,7 @@ public function testReturnsOneOhVersionWhenDetectedInServerSuperglobal() $this->assertSame(Response::VERSION_10, $response->getVersion()); } - public function testReturnsOneOneVersionWhenDetectedInServerSuperglobal() + public function testReturnsOneOneVersionWhenDetectedInServerSuperglobal(): void { // HTTP/1.1 $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; @@ -69,7 +70,7 @@ public function testReturnsOneOneVersionWhenDetectedInServerSuperglobal() $this->assertSame(Response::VERSION_11, $response->getVersion()); } - public function testFallsBackToVersionOneOhWhenServerSuperglobalVersionIsNotRecognized() + public function testFallsBackToVersionOneOhWhenServerSuperglobalVersionIsNotRecognized(): void { // unknown protocol or version -> fallback to HTTP/1.0 $_SERVER['SERVER_PROTOCOL'] = 'laminas/2.0'; @@ -77,7 +78,7 @@ public function testFallsBackToVersionOneOhWhenServerSuperglobalVersionIsNotReco $this->assertSame(Response::VERSION_10, $response->getVersion()); } - public function testFallsBackToVersionOneOhWhenNoVersionDetectedInServerSuperglobal() + public function testFallsBackToVersionOneOhWhenNoVersionDetectedInServerSuperglobal(): void { // undefined -> fallback to HTTP/1.0 unset($_SERVER['SERVER_PROTOCOL']); @@ -85,7 +86,7 @@ public function testFallsBackToVersionOneOhWhenNoVersionDetectedInServerSuperglo $this->assertSame(Response::VERSION_10, $response->getVersion()); } - public function testCanExplicitlySetVersion() + public function testCanExplicitlySetVersion(): void { $response = new Response(); $response->setVersion(Response::VERSION_11); @@ -98,19 +99,20 @@ public function testCanExplicitlySetVersion() $response->setVersion('laminas/2.0'); } - /** - * @runInSeparateProcess - */ - public function testSendHeadersReturnsInstanceIfHeadersNotAlreadySent() + #[RunInSeparateProcess] + public function testSendHeadersReturnsInstanceIfHeadersNotAlreadySent(): void { $response = new Response(); $this->assertInstanceOf(Response::class, $response->sendHeaders()); } - public function testSendHeadersInvokesHeadersSentHandlerIfHeadersAreAlreadySent() + #[RunInSeparateProcess] + public function testSendHeadersInvokesHeadersSentHandlerIfHeadersAreAlreadySent(): void { + include __DIR__ . '/Assets/MockHeadersSent.php'; + $response = new Response(); - $response->setHeadersSentHandler(function ($response) { + $response->setHeadersSentHandler(function ($response): void { throw new RuntimeException('Cannot send headers, headers already sent'); }); diff --git a/test/RequestTest.php b/test/RequestTest.php index 033be234..1e052abe 100644 --- a/test/RequestTest.php +++ b/test/RequestTest.php @@ -11,16 +11,18 @@ use Laminas\Http\Request; use Laminas\Stdlib\Parameters; use Laminas\Uri\Uri; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use ReflectionClass; use stdClass; +use function str_starts_with; use function strtolower; -use function substr; class RequestTest extends TestCase { - public function testRequestFromStringFactoryCreatesValidRequest() + public function testRequestFromStringFactoryCreatesValidRequest(): void { $string = "GET /foo?myparam=myvalue HTTP/1.1\r\n\r\nSome Content"; $request = Request::fromString($string); @@ -32,7 +34,7 @@ public function testRequestFromStringFactoryCreatesValidRequest() $this->assertEquals('Some Content', $request->getContent()); } - public function testRequestUsesParametersContainerByDefault() + public function testRequestUsesParametersContainerByDefault(): void { $request = new Request(); $this->assertInstanceOf(Parameters::class, $request->getQuery()); @@ -40,7 +42,7 @@ public function testRequestUsesParametersContainerByDefault() $this->assertInstanceOf(Parameters::class, $request->getFiles()); } - public function testRequestAllowsSettingOfParameterContainer() + public function testRequestAllowsSettingOfParameterContainer(): void { $request = new Request(); $p = new Parameters(); @@ -57,7 +59,7 @@ public function testRequestAllowsSettingOfParameterContainer() $this->assertSame($headers, $request->getHeaders()); } - public function testRetrievingASingleValueForParameters() + public function testRetrievingASingleValueForParameters(): void { $request = new Request(); $p = new Parameters([ @@ -81,7 +83,7 @@ public function testRetrievingASingleValueForParameters() $this->assertSame($h, $request->getHeader('foo')); } - public function testParameterRetrievalDefaultValue() + public function testParameterRetrievalDefaultValue(): void { $request = new Request(); $p = new Parameters([ @@ -99,20 +101,20 @@ public function testParameterRetrievalDefaultValue() $this->assertSame($default, $request->getHeader('baz', $default)); } - public function testRequestPersistsRawBody() + public function testRequestPersistsRawBody(): void { $request = new Request(); $request->setContent('foo'); $this->assertEquals('foo', $request->getContent()); } - public function testRequestUsesHeadersContainerByDefault() + public function testRequestUsesHeadersContainerByDefault(): void { $request = new Request(); $this->assertInstanceOf(Headers::class, $request->getHeaders()); } - public function testRequestCanSetHeaders() + public function testRequestCanSetHeaders(): void { $request = new Request(); $headers = new Headers(); @@ -122,25 +124,22 @@ public function testRequestCanSetHeaders() $this->assertSame($headers, $request->getHeaders()); } - public function testRequestCanSetAndRetrieveValidMethod() + public function testRequestCanSetAndRetrieveValidMethod(): void { $request = new Request(); $request->setMethod('POST'); $this->assertEquals('POST', $request->getMethod()); } - public function testRequestCanAlwaysForcesUppecaseMethodName() + public function testRequestCanAlwaysForcesUppecaseMethodName(): void { $request = new Request(); $request->setMethod('get'); $this->assertEquals('GET', $request->getMethod()); } - /** - * @dataProvider uriDataProvider - * @param string $uri - */ - public function testRequestCanSetAndRetrieveUri($uri) + #[DataProvider('uriDataProvider')] + public function testRequestCanSetAndRetrieveUri(string $uri): void { $request = new Request(); $request->setUri($uri); @@ -151,7 +150,7 @@ public function testRequestCanSetAndRetrieveUri($uri) } /** @psalm-return array */ - public function uriDataProvider(): array + public static function uriDataProvider(): array { return [ ['/foo'], @@ -160,7 +159,7 @@ public function uriDataProvider(): array ]; } - public function testRequestSetUriWillThrowExceptionOnInvalidArgument() + public function testRequestSetUriWillThrowExceptionOnInvalidArgument(): void { $request = new Request(); @@ -169,7 +168,7 @@ public function testRequestSetUriWillThrowExceptionOnInvalidArgument() $request->setUri(new stdClass()); } - public function testRequestCanSetAndRetrieveVersion() + public function testRequestCanSetAndRetrieveVersion(): void { $request = new Request(); $this->assertEquals('1.1', $request->getVersion()); @@ -177,7 +176,7 @@ public function testRequestCanSetAndRetrieveVersion() $this->assertEquals('1.0', $request->getVersion()); } - public function testRequestSetVersionWillThrowExceptionOnInvalidArgument() + public function testRequestSetVersionWillThrowExceptionOnInvalidArgument(): void { $request = new Request(); @@ -186,21 +185,18 @@ public function testRequestSetVersionWillThrowExceptionOnInvalidArgument() $request->setVersion('1.2'); } - /** - * @dataProvider getMethods - * @param string $methodName - */ - public function testRequestMethodCheckWorksForAllMethods($methodName) + #[DataProvider('getMethodsProvider')] + public function testRequestMethodCheckWorksForAllMethods(string $methodName): void { $request = new Request(); $request->setMethod($methodName); - foreach ($this->getMethods(false, $methodName) as $testMethodName => $testMethodValue) { + foreach ($this->getMethods($methodName) as $testMethodName => $testMethodValue) { $this->assertEquals($testMethodValue, $request->{'is' . $testMethodName}()); } } - public function testRequestCanBeCastToAString() + public function testRequestCanBeCastToAString(): void { $request = new Request(); $request->setMethod(Request::METHOD_GET); @@ -209,7 +205,7 @@ public function testRequestCanBeCastToAString() $this->assertEquals("GET / HTTP/1.1\r\n\r\nfoo=bar&bar=baz", $request->toString()); } - public function testRequestIsXmlHttpRequest() + public function testRequestIsXmlHttpRequest(): void { $request = new Request(); $this->assertFalse($request->isXmlHttpRequest()); @@ -223,7 +219,7 @@ public function testRequestIsXmlHttpRequest() $this->assertTrue($request->isXmlHttpRequest()); } - public function testRequestIsFlashRequest() + public function testRequestIsFlashRequest(): void { $request = new Request(); $this->assertFalse($request->isFlashRequest()); @@ -237,38 +233,49 @@ public function testRequestIsFlashRequest() $this->assertTrue($request->isFlashRequest()); } - /** - * @group 4893 - */ - public function testRequestsWithoutHttpVersionAreOK() + #[Group('4893')] + public function testRequestsWithoutHttpVersionAreOK(): void { $requestString = 'GET http://www.domain.com/index.php'; $request = Request::fromString($requestString); $this->assertEquals($request::METHOD_GET, $request->getMethod()); } - /** - * @param bool $providerContext - * @param null|string $trueMethod - * @return array - */ - public function getMethods($providerContext, $trueMethod = null) + /** @return array */ + private static function getMethods(string $trueMethod): array + { + $return = []; + foreach (self::getMethodsConstOnRequest() as $cValue) { + $return[strtolower($cValue)] = $trueMethod === $cValue; + } + return $return; + } + + /** @return list */ + private static function getMethodsConstOnRequest(): array { $refClass = new ReflectionClass(Request::class); $return = []; foreach ($refClass->getConstants() as $cName => $cValue) { - if (substr($cName, 0, 6) === 'METHOD') { - if ($providerContext) { - $return[] = [$cValue]; - } else { - $return[strtolower($cValue)] = $trueMethod === $cValue; - } + if (str_starts_with($cName, 'METHOD')) { + $return[] = $cValue; } } + + return $return; + } + + /** @return list> */ + public static function getMethodsProvider(): array + { + $return = []; + foreach (self::getMethodsConstOnRequest() as $cValue) { + $return[] = [$cValue]; + } return $return; } - public function testCustomMethods() + public function testCustomMethods(): void { $request = new Request(); $this->assertTrue($request->getAllowCustomMethods()); @@ -277,7 +284,7 @@ public function testCustomMethods() $this->assertEquals('XCUSTOM', $request->getMethod()); } - public function testDisallowCustomMethods() + public function testDisallowCustomMethods(): void { $request = new Request(); $request->setAllowCustomMethods(false); @@ -288,7 +295,7 @@ public function testDisallowCustomMethods() $request->setMethod('xcustom'); } - public function testCustomMethodsFromString() + public function testCustomMethodsFromString(): void { $request = Request::fromString('X-CUS_TOM someurl'); $this->assertTrue($request->getAllowCustomMethods()); @@ -296,7 +303,7 @@ public function testCustomMethodsFromString() $this->assertEquals('X-CUS_TOM', $request->getMethod()); } - public function testDisallowCustomMethodsFromString() + public function testDisallowCustomMethodsFromString(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A valid request line was not found in the provided string'); @@ -304,13 +311,13 @@ public function testDisallowCustomMethodsFromString() Request::fromString('X-CUS_TOM someurl', false); } - public function testAllowCustomMethodsFlagIsSetByFromString() + public function testAllowCustomMethodsFlagIsSetByFromString(): void { $request = Request::fromString('GET someurl', false); $this->assertFalse($request->getAllowCustomMethods()); } - public function testFromStringFactoryCreatesSingleObjectWithHeaderFolding() + public function testFromStringFactoryCreatesSingleObjectWithHeaderFolding(): void { $request = Request::fromString("GET /foo HTTP/1.1\r\nFake: foo\r\n -bar"); $headers = $request->getHeaders(); @@ -324,10 +331,9 @@ public function testFromStringFactoryCreatesSingleObjectWithHeaderFolding() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testCRLFAttack() + #[Group('ZF2015-04')] + public function testCRLFAttack(): void { $this->expectException(RuntimeException::class); Request::fromString( @@ -335,7 +341,7 @@ public function testCRLFAttack() ); } - public function testGetHeadersDoesNotRaiseExceptionForInvalidHeaderLines() + public function testGetHeadersDoesNotRaiseExceptionForInvalidHeaderLines(): void { $request = Request::fromString("GET /foo HTTP/1.1\r\nHost: example.com\r\nUseragent: h4ckerbot"); diff --git a/test/Response/ResponseStreamTest.php b/test/Response/ResponseStreamTest.php index f0cb9942..fe1f35dc 100644 --- a/test/Response/ResponseStreamTest.php +++ b/test/Response/ResponseStreamTest.php @@ -5,6 +5,7 @@ namespace LaminasTest\Http\Response; use Laminas\Http\Response\Stream; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function fgets; @@ -20,6 +21,7 @@ use const DIRECTORY_SEPARATOR; +#[CoversClass(Stream::class)] class ResponseStreamTest extends TestCase { /** @var null|string */ @@ -37,7 +39,7 @@ public function tearDown(): void } } - public function testResponseFactoryFromStringCreatesValidResponse() + public function testResponseFactoryFromStringCreatesValidResponse(): void { $string = 'HTTP/1.0 200 OK' . "\r\n\r\n" . 'Foo Bar' . "\r\n"; $stream = fopen('php://temp', 'rb+'); @@ -49,11 +51,8 @@ public function testResponseFactoryFromStringCreatesValidResponse() $this->assertEquals("Foo Bar\r\nBar Foo", $response->getBody()); } - /** - * @group 6027 - * @covers \Laminas\Http\Response\Stream::fromStream - */ - public function testResponseFactoryFromEmptyStringCreatesValidResponse() + #[Group('6027')] + public function testResponseFactoryFromEmptyStringCreatesValidResponse(): void { $stream = fopen('php://temp', 'rb+'); fwrite($stream, 'HTTP/1.0 200 OK' . "\r\n\r\n" . 'Foo Bar' . "\r\n" . 'Bar Foo'); @@ -64,7 +63,7 @@ public function testResponseFactoryFromEmptyStringCreatesValidResponse() $this->assertEquals("Foo Bar\r\nBar Foo", $response->getBody()); } - public function testGzipResponse() + public function testGzipResponse(): void { $stream = fopen(__DIR__ . '/../_files/response_gzip', 'rb'); @@ -85,7 +84,7 @@ public function testGzipResponse() $this->assertEquals('f24dd075ba2ebfb3bf21270e3fdc5303', md5($res->getContent())); } - public function test300isRedirect() + public function test300isRedirect(): void { $values = $this->readResponse('response_302'); $response = Stream::fromStream($values['data'], $values['stream']); @@ -133,11 +132,8 @@ public function __toString(): string /** * Helper function: read test response from file - * - * @param string $response - * @return string */ - protected function readResponse($response) + protected function readResponse(string $response): array { $stream = fopen(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $response, 'rb'); diff --git a/test/ResponseTest.php b/test/ResponseTest.php index 4ee89f1e..ee59b28b 100644 --- a/test/ResponseTest.php +++ b/test/ResponseTest.php @@ -9,6 +9,8 @@ use Laminas\Http\Header\GenericHeader; use Laminas\Http\Headers; use Laminas\Http\Response; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use function array_shift; @@ -29,7 +31,7 @@ class ResponseTest extends TestCase { /** @psalm-return iterable */ - public function validHttpVersions(): iterable + public static function validHttpVersions(): iterable { yield 'http/1.0' => ['1.0']; yield 'http/1.1' => ['1.1']; @@ -44,13 +46,13 @@ public function validHttpVersions(): iterable * expectedContent: string * }> */ - public function validResponseHttpVersionProvider(): iterable + public static function validResponseHttpVersionProvider(): iterable { $responseTemplate = "HTTP/%s 200 OK\r\n\r\nFoo Bar"; - foreach ($this->validHttpVersions() as $testCase => $data) { + foreach (self::validHttpVersions() as $testCase => $data) { $version = array_shift($data); yield $testCase => [ - 'response' => sprintf($responseTemplate, $version), + 'string' => sprintf($responseTemplate, $version), 'expectedVersion' => $version, 'expectedStatus' => '200', 'expectedContent' => 'Foo Bar', @@ -59,29 +61,23 @@ public function validResponseHttpVersionProvider(): iterable } /** - * @dataProvider validResponseHttpVersionProvider * @param string $string Response string - * @param string $expectedVersion - * @param string $expectedStatus - * @param string $expectedContent */ + #[DataProvider('validResponseHttpVersionProvider')] public function testResponseFactoryFromStringCreatesValidResponse( - $string, - $expectedVersion, - $expectedStatus, - $expectedContent - ) { + string $string, + string $expectedVersion, + string $expectedStatus, + string $expectedContent + ): void { $response = Response::fromString($string); $this->assertEquals($expectedVersion, $response->getVersion()); $this->assertEquals($expectedStatus, $response->getStatusCode()); $this->assertEquals($expectedContent, $response->getContent()); } - /** - * @dataProvider validHttpVersions - * @param string $version - */ - public function testResponseCanRenderStatusLineUsingDefaultReasonPhrase($version) + #[DataProvider('validHttpVersions')] + public function testResponseCanRenderStatusLineUsingDefaultReasonPhrase(string $version): void { $expected = sprintf('HTTP/%s 404 Not Found', $version); $response = new Response(); @@ -90,11 +86,8 @@ public function testResponseCanRenderStatusLineUsingDefaultReasonPhrase($version $this->assertEquals($expected, $response->renderStatusLine()); } - /** - * @dataProvider validHttpVersions - * @param string $version - */ - public function testResponseCanRenderStatusLineUsingCustomReasonPhrase($version) + #[DataProvider('validHttpVersions')] + public function testResponseCanRenderStatusLineUsingCustomReasonPhrase(string $version): void { $expected = sprintf('HTTP/%s 404 Foo Bar', $version); $response = new Response(); @@ -104,7 +97,7 @@ public function testResponseCanRenderStatusLineUsingCustomReasonPhrase($version) $this->assertEquals($expected, $response->renderStatusLine()); } - public function testInvalidHTTP2VersionString() + public function testInvalidHTTP2VersionString(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A valid response status line was not found in the provided string'); @@ -112,13 +105,13 @@ public function testInvalidHTTP2VersionString() $response = Response::fromString($string); } - public function testResponseUsesHeadersContainerByDefault() + public function testResponseUsesHeadersContainerByDefault(): void { $response = new Response(); $this->assertInstanceOf(Headers::class, $response->getHeaders()); } - public function testRequestCanSetHeaders() + public function testRequestCanSetHeaders(): void { $response = new Response(); $headers = new Headers(); @@ -129,18 +122,15 @@ public function testRequestCanSetHeaders() } /** @psalm-return iterable */ - public function validStatusCode(): iterable + public static function validStatusCode(): iterable { for ($i = 100; $i <= 599; ++$i) { yield $i => [$i]; } } - /** - * @dataProvider validStatusCode - * @param int $statusCode - */ - public function testResponseCanSetStatusCode($statusCode) + #[DataProvider('validStatusCode')] + public function testResponseCanSetStatusCode(int $statusCode): void { $response = new Response(); $this->assertSame(200, $response->getStatusCode()); @@ -148,7 +138,7 @@ public function testResponseCanSetStatusCode($statusCode) $this->assertSame($statusCode, $response->getStatusCode()); } - public function testResponseSetStatusCodeThrowsExceptionOnInvalidCode() + public function testResponseSetStatusCodeThrowsExceptionOnInvalidCode(): void { $response = new Response(); $this->expectException(InvalidArgumentException::class); @@ -156,14 +146,14 @@ public function testResponseSetStatusCodeThrowsExceptionOnInvalidCode() $response->setStatusCode(606); } - public function testResponseGetReasonPhraseWillReturnEmptyPhraseAsDefault() + public function testResponseGetReasonPhraseWillReturnEmptyPhraseAsDefault(): void { $response = new Response(); $response->setCustomStatusCode(998); $this->assertSame('HTTP/1.1 998' . "\r\n\r\n", (string) $response); } - public function testResponseCanSetCustomStatusCode() + public function testResponseCanSetCustomStatusCode(): void { $response = new Response(); $this->assertEquals(200, $response->getStatusCode()); @@ -171,7 +161,7 @@ public function testResponseCanSetCustomStatusCode() $this->assertEquals(999, $response->getStatusCode()); } - public function testResponseSetCustomStatusCodeThrowsExceptionOnInvalidCode() + public function testResponseSetCustomStatusCodeThrowsExceptionOnInvalidCode(): void { $response = new Response(); $this->expectException(InvalidArgumentException::class); @@ -180,7 +170,7 @@ public function testResponseSetCustomStatusCodeThrowsExceptionOnInvalidCode() $response->setStatusCode('foo'); } - public function testResponseEndsAtStatusCode() + public function testResponseEndsAtStatusCode(): void { $string = 'HTTP/1.0 200' . "\r\n\r\n" . 'Foo Bar'; $response = Response::fromString($string); @@ -188,7 +178,7 @@ public function testResponseEndsAtStatusCode() $this->assertEquals('Foo Bar', $response->getContent()); } - public function testResponseHasZeroLengthReasonPhrase() + public function testResponseHasZeroLengthReasonPhrase(): void { // Space after status code is mandatory, // though, reason phrase can be empty. @@ -203,7 +193,7 @@ public function testResponseHasZeroLengthReasonPhrase() $this->assertEquals('OK', $response->getReasonPhrase()); } - public function testGzipResponse() + public function testGzipResponse(): void { $responseTest = file_get_contents(__DIR__ . '/_files/response_gzip'); @@ -214,7 +204,7 @@ public function testGzipResponse() $this->assertEquals('f24dd075ba2ebfb3bf21270e3fdc5303', md5($res->getContent())); } - public function testGzipResponseWithEmptyBody() + public function testGzipResponseWithEmptyBody(): void { $responseTest = <<<'REQ' HTTP/1.1 200 OK @@ -236,7 +226,7 @@ public function testGzipResponseWithEmptyBody() $this->assertSame('', $res->getContent()); } - public function testDeflateResponse() + public function testDeflateResponse(): void { $responseTest = file_get_contents(__DIR__ . '/_files/response_deflate'); @@ -247,7 +237,7 @@ public function testDeflateResponse() $this->assertEquals('ad62c21c3aa77b6a6f39600f6dd553b8', md5($res->getContent())); } - public function testDeflateResponseWithEmptyBody() + public function testDeflateResponseWithEmptyBody(): void { $responseTest = <<<'REQ' HTTP/1.1 200 OK @@ -278,7 +268,7 @@ public function testDeflateResponseWithEmptyBody() * * @link https://getlaminas.org/issues/browse/Laminas-6040 */ - public function testNonStandardDeflateResponseLaminas6040() + public function testNonStandardDeflateResponseLaminas6040(): void { $this->markTestSkipped('Not correctly handling non-RFC complient "deflate" responses'); $responseTest = file_get_contents(__DIR__ . '/_files/response_deflate_iis'); @@ -295,7 +285,7 @@ public function testNonStandardDeflateResponseLaminas6040() * * @link https://framework.zend.com/issues/browse/ZF-12457.html */ - public function testStandardDeflateResponseLaminas12457() + public function testStandardDeflateResponseLaminas12457(): void { $responseTest = file_get_contents(__DIR__ . '/_files/response_deflate_iis_valid'); @@ -306,7 +296,7 @@ public function testStandardDeflateResponseLaminas12457() $this->assertEquals('992ec500e8332df89bbd9b8e998ec8c9', md5($res->getContent())); } - public function testChunkedResponse() + public function testChunkedResponse(): void { $responseTest = file_get_contents(__DIR__ . '/_files/response_chunked'); @@ -317,7 +307,7 @@ public function testChunkedResponse() $this->assertEquals('c0cc9d44790fa2a58078059bab1902a9', md5($res->getContent())); } - public function testChunkedResponseCaseInsensitiveLaminas5438() + public function testChunkedResponseCaseInsensitiveLaminas5438(): void { $responseTest = file_get_contents(__DIR__ . '/_files/response_chunked_case'); @@ -332,7 +322,7 @@ public function testChunkedResponseCaseInsensitiveLaminas5438() * @param int $chunksize the data size of the chunk to create * @return string a chunk of data for embedding inside a chunked response */ - private function makeChunk($chunksize) + private function makeChunk(int $chunksize): string { return sprintf("%d\r\n%s\r\n", $chunksize, str_repeat('W', $chunksize)); } @@ -340,17 +330,14 @@ private function makeChunk($chunksize) /** * @return float the time that calling the getBody function took on the response */ - private function getTimeForGetBody(Response $response) + private function getTimeForGetBody(Response $response): float { $timeStart = microtime(true); $response->getBody(); return microtime(true) - $timeStart; } - /** - * @small - */ - public function testChunkedResponsePerformance() + public function testChunkedResponsePerformance(): void { $headers = new Headers(); $headers->addHeaders([ @@ -388,7 +375,7 @@ public function testChunkedResponsePerformance() $this->assertLessThan(25, min($timings), $errMsg . print_r($timings, true)); } - public function testLineBreaksCompatibility() + public function testLineBreaksCompatibility(): void { $responseTestLf = $this->readResponse('response_lfonly'); $resLf = Response::fromString($responseTestLf); @@ -406,7 +393,7 @@ public function testLineBreaksCompatibility() $this->assertEquals($resLf->getBody(), $resCrlf->getBody(), 'Response bodies do not match'); } - public function test404IsClientErrorAndNotFound() + public function test404IsClientErrorAndNotFound(): void { $responseTest = $this->readResponse('response_404'); $response = Response::fromString($responseTest); @@ -423,7 +410,7 @@ public function test404IsClientErrorAndNotFound() $this->assertFalse($response->isSuccess(), 'Response is an error, but isSuccess() returned true'); } - public function test410IsGone() + public function test410IsGone(): void { $responseTest = $this->readResponse('response_410'); $response = Response::fromString($responseTest); @@ -440,7 +427,7 @@ public function test410IsGone() $this->assertFalse($response->isSuccess(), 'Response is an error, but isSuccess() returned true'); } - public function test500isError() + public function test500isError(): void { $responseTest = $this->readResponse('response_500'); $response = Response::fromString($responseTest); @@ -457,10 +444,8 @@ public function test500isError() $this->assertFalse($response->isSuccess(), 'Response is an error, but isSuccess() returned true'); } - /** - * @group Laminas-5520 - */ - public function test302LocationHeaderMatches() + #[Group('Laminas-5520')] + public function test302LocationHeaderMatches(): void { $headerName = 'Location'; $headerValue = 'http://www.google.com/ig?hl=en'; @@ -471,7 +456,7 @@ public function test302LocationHeaderMatches() $this->assertEquals($headerValue, $responseIis->getHeaders()->get($headerName)->getFieldValue()); } - public function test300isRedirect() + public function test300isRedirect(): void { $response = Response::fromString($this->readResponse('response_302')); @@ -487,7 +472,7 @@ public function test300isRedirect() $this->assertFalse($response->isSuccess(), 'Response is an error, but isSuccess() returned true'); } - public function test200Ok() + public function test200Ok(): void { $response = Response::fromString($this->readResponse('response_deflate')); @@ -503,12 +488,12 @@ public function test200Ok() $this->assertTrue($response->isSuccess(), 'Response is an error, but isSuccess() returned false'); } - public function test100Continue() + public function test100Continue(): void { $this->markTestIncomplete(); } - public function testAutoMessageSet() + public function testAutoMessageSet(): void { $response = Response::fromString($this->readResponse('response_403_nomessage')); @@ -531,7 +516,7 @@ public function testAutoMessageSet() $this->assertFalse($response->isSuccess(), 'Response is an error, but isSuccess() returned true'); } - public function testToString() + public function testToString(): void { $responseStr = $this->readResponse('response_404'); $response = Response::fromString($responseStr); @@ -548,7 +533,7 @@ public function testToString() ); } - public function testToStringGzip() + public function testToStringGzip(): void { $responseStr = $this->readResponse('response_gzip'); $response = Response::fromString($responseStr); @@ -565,7 +550,7 @@ public function testToStringGzip() ); } - public function testGetHeaders() + public function testGetHeaders(): void { $response = Response::fromString($this->readResponse('response_deflate')); $headers = $response->getHeaders(); @@ -579,13 +564,13 @@ public function testGetHeaders() ); } - public function testGetVersion() + public function testGetVersion(): void { $response = Response::fromString($this->readResponse('response_chunked')); $this->assertEquals(1.1, $response->getVersion(), 'Version is expected to be 1.1'); } - public function testUnknownCode() + public function testUnknownCode(): void { $responseStr = $this->readResponse('response_unknown'); $response = Response::fromString($responseStr); @@ -596,7 +581,7 @@ public function testUnknownCode() * Make sure a response with some leading whitespace in the response body * does not get modified (see Laminas-1924) */ - public function testLeadingWhitespaceBody() + public function testLeadingWhitespaceBody(): void { $response = Response::fromString($this->readResponse('response_leadingws')); $this->assertEquals( @@ -612,7 +597,7 @@ public function testLeadingWhitespaceBody() * This can potentially fail on different PHP environments - for example * when mbstring.func_overload is set to overload strlen(). */ - public function testMultibyteChunkedResponse() + public function testMultibyteChunkedResponse(): void { $this->markTestSkipped('Looks like the headers are split with \n and the body with \r\n'); $md5 = 'ab952f1617d0e28724932401f2d3c6ae'; @@ -624,7 +609,7 @@ public function testMultibyteChunkedResponse() /** * Test automatic clean reason phrase */ - public function testOverrideReasonPraseByStatusCode() + public function testOverrideReasonPraseByStatusCode(): void { $response = new Response(); $response->setStatusCode(200); @@ -634,7 +619,7 @@ public function testOverrideReasonPraseByStatusCode() $this->assertEquals('Bad Request', $response->getReasonPhrase()); } - public function testromStringFactoryCreatesSingleObjectWithHeaderFolding() + public function testromStringFactoryCreatesSingleObjectWithHeaderFolding(): void { $request = Response::fromString("HTTP/1.1 200 OK\r\nFake: foo\r\n -bar"); $headers = $request->getHeaders(); @@ -648,10 +633,9 @@ public function testromStringFactoryCreatesSingleObjectWithHeaderFolding() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * - * @group ZF2015-04 */ - public function testPreventsCRLFAttackWhenDeserializing() + #[Group('ZF2015-04')] + public function testPreventsCRLFAttackWhenDeserializing(): void { $this->expectException(RuntimeException::class); Response::fromString( @@ -659,7 +643,7 @@ public function testPreventsCRLFAttackWhenDeserializing() ); } - public function test100ContinueFromString() + public function test100ContinueFromString(): void { $fixture = 'TOKEN=EC%XXXXXXXXXXXXX&TIMESTAMP=2017%2d10%2d10T09%3a02%3a55Z' . "&CORRELATIONID=XXXXXXXXXX&ACK=Success&VERSION=65%2e1&BUILD=XXXXXXXXXX\r\n"; @@ -671,11 +655,8 @@ public function test100ContinueFromString() /** * Helper function: read test response from file - * - * @param string $response - * @return string */ - protected function readResponse($response) + protected function readResponse(string $response): string { return file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $response); }