From ad94742e9ccfc3f7ce64f946af99fbc30bb447b0 Mon Sep 17 00:00:00 2001 From: mesilov Date: Sun, 18 Feb 2024 23:04:24 +0600 Subject: [PATCH 1/5] Change data provider methods to static in tests The data provider methods used in various test cases have been changed to static. This change was applied to "CredentialsTest", "ApplicationStatusTest", "ApplicationProfileTest", "DefaultRequestIdGeneratorTest", and "TimeTest". An additional command has also been added to the Makefile for running unit tests. Signed-off-by: mesilov --- Makefile | 5 ++++- tests/Unit/Application/ApplicationStatusTest.php | 2 +- tests/Unit/Core/Credentials/ApplicationProfileTest.php | 2 +- tests/Unit/Core/Credentials/CredentialsTest.php | 2 +- tests/Unit/Core/Response/DTO/TimeTest.php | 2 +- .../HttpClient/RequestId/DefaultRequestIdGeneratorTest.php | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ee1097e7..6e31904d 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,7 @@ default: @egrep -e '^\S+' ./Makefile | grep -v default | sed -r 's/://' | sed -r 's/^/ - /' phpstan: - vendor/bin/phpstan analyse \ No newline at end of file + vendor/bin/phpstan analyse + +test-unit: + vendor/bin/phpunit --testsuite unit_tests \ No newline at end of file diff --git a/tests/Unit/Application/ApplicationStatusTest.php b/tests/Unit/Application/ApplicationStatusTest.php index d768b0e4..ba6214ce 100644 --- a/tests/Unit/Application/ApplicationStatusTest.php +++ b/tests/Unit/Application/ApplicationStatusTest.php @@ -49,7 +49,7 @@ public function testInitFromString(): void /** * @return \Generator */ - public function statusDataProvider(): Generator + public static function statusDataProvider(): Generator { yield 'free' => [ 'F', diff --git a/tests/Unit/Core/Credentials/ApplicationProfileTest.php b/tests/Unit/Core/Credentials/ApplicationProfileTest.php index 17956aac..27d415f7 100644 --- a/tests/Unit/Core/Credentials/ApplicationProfileTest.php +++ b/tests/Unit/Core/Credentials/ApplicationProfileTest.php @@ -31,7 +31,7 @@ public function testFromArray(array $arr, ?string $expectedException): void $this->assertEquals($prof->getClientSecret(), $arr['BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET']); } - public function arrayDataProvider(): Generator + public static function arrayDataProvider(): Generator { yield 'valid' => [ [ diff --git a/tests/Unit/Core/Credentials/CredentialsTest.php b/tests/Unit/Core/Credentials/CredentialsTest.php index 5d3ccfdb..64438eef 100644 --- a/tests/Unit/Core/Credentials/CredentialsTest.php +++ b/tests/Unit/Core/Credentials/CredentialsTest.php @@ -70,7 +70,7 @@ public function testDomainUrlWithProtocol(): void * @throws \Bitrix24\SDK\Core\Exceptions\InvalidArgumentException * @throws \Bitrix24\SDK\Core\Exceptions\UnknownScopeCodeException */ - public function credentialsDataProviderWithDomainUrlVariants(): Generator + public static function credentialsDataProviderWithDomainUrlVariants(): Generator { yield 'with webhook walid domain url' => [ Credentials::createFromWebhook(new WebhookUrl('https://bitrix24-php-sdk-playground.bitrix24.ru/rest/1/valid-webhook/')), diff --git a/tests/Unit/Core/Response/DTO/TimeTest.php b/tests/Unit/Core/Response/DTO/TimeTest.php index 64f597b2..99a7db9d 100644 --- a/tests/Unit/Core/Response/DTO/TimeTest.php +++ b/tests/Unit/Core/Response/DTO/TimeTest.php @@ -36,7 +36,7 @@ public function testInitFromResponseData(array $result): void /** * @return \Generator */ - public function timingsDataProvider(): Generator + public static function timingsDataProvider(): Generator { yield 'without operating reset at' => [ [ diff --git a/tests/Unit/Infrastructure/HttpClient/RequestId/DefaultRequestIdGeneratorTest.php b/tests/Unit/Infrastructure/HttpClient/RequestId/DefaultRequestIdGeneratorTest.php index fab333b8..48b21e52 100644 --- a/tests/Unit/Infrastructure/HttpClient/RequestId/DefaultRequestIdGeneratorTest.php +++ b/tests/Unit/Infrastructure/HttpClient/RequestId/DefaultRequestIdGeneratorTest.php @@ -26,7 +26,7 @@ public function testExistsRequestId($requestIdKey, $requestId): void unset($_SERVER[$requestIdKey]); } - public function requestIdKeyDataProvider(): Generator + public static function requestIdKeyDataProvider(): Generator { yield 'REQUEST_ID' => [ 'REQUEST_ID', From 6aeacd6f96fd3edf0bdd3471b569d9b5d2d0b82c Mon Sep 17 00:00:00 2001 From: mesilov Date: Sun, 18 Feb 2024 23:13:29 +0600 Subject: [PATCH 2/5] Refactor constants declaration in DefaultRequestIdGenerator Constants in DefaultRequestIdGenerator were refactored to remove 'string' and 'array' type declarations. These changes conform to PHP constants declaration rules, which do not require type specification. Signed-off-by: mesilov --- .../HttpClient/RequestId/DefaultRequestIdGenerator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Infrastructure/HttpClient/RequestId/DefaultRequestIdGenerator.php b/src/Infrastructure/HttpClient/RequestId/DefaultRequestIdGenerator.php index 9b49016d..84defcd0 100644 --- a/src/Infrastructure/HttpClient/RequestId/DefaultRequestIdGenerator.php +++ b/src/Infrastructure/HttpClient/RequestId/DefaultRequestIdGenerator.php @@ -8,9 +8,9 @@ class DefaultRequestIdGenerator implements RequestIdGeneratorInterface { - private const string DEFAULT_REQUEST_ID_HEADER_FIELD_NAME = 'X-Request-ID'; - private const string DEFAULT_QUERY_STRING_PARAMETER_NAME = 'bx24_request_id'; - private const array KEY_NAME_VARIANTS = [ + private const DEFAULT_REQUEST_ID_HEADER_FIELD_NAME = 'X-Request-ID'; + private const DEFAULT_QUERY_STRING_PARAMETER_NAME = 'bx24_request_id'; + private const KEY_NAME_VARIANTS = [ 'REQUEST_ID', 'HTTP_X_REQUEST_ID', 'UNIQUE_ID' From 86f088537301f2190907c09acfbad3cd6e670ae9 Mon Sep 17 00:00:00 2001 From: mesilov Date: Sun, 18 Feb 2024 23:15:39 +0600 Subject: [PATCH 3/5] Update constant declaration in AbstractCrmItem The constant CRM_USERFIELD_PREFIX in the AbstractCrmItem class has been updated to remove the 'string' type declaration, in accordance with PHP's constants declaration rules which do not require specifying the type. Signed-off-by: mesilov --- src/Services/CRM/Common/Result/AbstractCrmItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/CRM/Common/Result/AbstractCrmItem.php b/src/Services/CRM/Common/Result/AbstractCrmItem.php index f7d9c321..84ffb151 100644 --- a/src/Services/CRM/Common/Result/AbstractCrmItem.php +++ b/src/Services/CRM/Common/Result/AbstractCrmItem.php @@ -17,7 +17,7 @@ class AbstractCrmItem extends AbstractItem { - private const string CRM_USERFIELD_PREFIX = 'UF_CRM_'; + private const CRM_USERFIELD_PREFIX = 'UF_CRM_'; /** * @var Currency From 855cd960b7193e19c2df05326cb980f0d1152323 Mon Sep 17 00:00:00 2001 From: mesilov Date: Sun, 18 Feb 2024 23:17:22 +0600 Subject: [PATCH 4/5] Update constant declaration in AbstractCatalogItem The constant CRM_USERFIELD_PREFIX in the AbstractCatalogItem class has been updated to remove the 'string' type declaration, keeping in line with PHP's convention for declaring constants which does not require specifying the type. Signed-off-by: mesilov --- src/Services/Catalog/Common/Result/AbstractCatalogItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/Catalog/Common/Result/AbstractCatalogItem.php b/src/Services/Catalog/Common/Result/AbstractCatalogItem.php index 435beeb4..b1d0138a 100644 --- a/src/Services/Catalog/Common/Result/AbstractCatalogItem.php +++ b/src/Services/Catalog/Common/Result/AbstractCatalogItem.php @@ -13,7 +13,7 @@ abstract class AbstractCatalogItem extends AbstractItem { - private const string CRM_USERFIELD_PREFIX = 'UF_CRM_'; + private const CRM_USERFIELD_PREFIX = 'UF_CRM_'; /** * @var Currency From bad9929eae5d3df471cdfdcf4c4ca05603c8f5b7 Mon Sep 17 00:00:00 2001 From: mesilov Date: Sun, 18 Feb 2024 23:19:58 +0600 Subject: [PATCH 5/5] Update release date and php support in CHANGELOG The release date for version 2.0-beta.1 in the CHANGELOG.md file has been updated. Additionally, the PHP support information has also been changed to reflect the added support for PHP 8.2 and 8.3, and the removal of support for PHP 8.0 and 8.1. Signed-off-by: mesilov --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e31e28c0..7c8ad878 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # bitrix24-php-sdk change log -## 2.0-beta.1 — 25.03.2023 +## 2.0-beta.1 — 18.02.2024 ### Added -* ❗️add php 8.3 support, drop 8.1 and 8.0 support +* ❗️add php 8.3, 8.2 support, drop 8.1 and 8.0 support * add `Symfony\Component\Uid\Uuid` requirements * add contracts for bitrix24 applications based on bitrix24-php-sdk - `Bitrix24\SDK\Application\Contracts`, now added `Bitrix24Account`