diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php
index ce2866f3..9ad27ea8 100644
--- a/.php-cs-fixer.php
+++ b/.php-cs-fixer.php
@@ -9,6 +9,7 @@
->in(__DIR__ . '/src/Services/CRM/VatRates/')
->in(__DIR__ . '/src/Services/CRM/Contact/')
->in(__DIR__ . '/src/Services/CRM/Requisites/')
+ ->in(__DIR__ . '/src/Services/CRM/Activity/')
->name('*.php')
->exclude(['vendor', 'storage', 'docker', 'docs']) // Exclude directories
->ignoreDotFiles(true)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b7f55a8d..45b5f751 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,15 @@
## Unreleased 1.3.0 – 2025.03.31
### Added
+- Added service `Services\AI\Engine\Service\Type` with support methods:
+ - `crm.activity.type.add` - method registers a custom activity type with a name and icon
+ - `crm.activity.type.delete` - delete a custom activity type
+ - `crm.activity.type.list` - get a list of custom task types
+- Added service `Services\AI\Engine\Service\Communication` with support methods:
+ - `crm.activity.communication.fields` - get a description of the communication
+
+### Fixed
+- Fix typehint errors in `src/Services/CRM/Activity/Result/ActivityItemResult.php`
- Added **PHP 8.4** [support](https://github.com/bitrix24/b24phpsdk/issues/120) 🚀
- Added method `Bitrix24\SDK\Services\Main\Service::guardValidateCurrentAuthToken` for validate current auth token with
diff --git a/Makefile b/Makefile
index 14385044..421c8ca5 100644
--- a/Makefile
+++ b/Makefile
@@ -175,6 +175,14 @@ test-integration-scope-entity:
test-integration-scope-ai-admin:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_ai_admin
+.PHONY: test-integration-scope-crm
+test-integration-scope-crm:
+ docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_crm
+
+.PHONY: test-integration-scope-crm-activity
+test-integration-scope-crm-activity:
+ docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_crm_activity
+
# work dev environment
.PHONY: php-dev-server-up
php-dev-server-up:
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index d7b241df..636aa44f 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -11,6 +11,7 @@ parameters:
- tests/Integration/Services/IMOpenLines
- tests/Integration/Services/Main
- tests/Integration/Services/Placement
+ - tests/Integration/Services/CRM
bootstrapFiles:
- tests/bootstrap.php
parallel:
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 624b64f3..c4aa77ce 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -43,6 +43,12 @@
./tests/Integration/Services/AI/
+
+ ./tests/Integration/Services/CRM/
+
+
+ ./tests/Integration/Services/CRM/Activity
+
diff --git a/rector.php b/rector.php
index 402daf01..e5724fd0 100644
--- a/rector.php
+++ b/rector.php
@@ -34,6 +34,8 @@
__DIR__ . '/tests/Integration/Services/Main',
__DIR__ . '/src/Services/Placement',
__DIR__ . '/tests/Integration/Services/Placement',
+ __DIR__ . '/src/Services/CRM',
+ __DIR__ . '/tests/Integration/Services/CRM',
__DIR__ . '/tests/Unit/',
])
->withCache(cacheDirectory: __DIR__ . '.cache/rector')
diff --git a/src/Services/CRM/Activity/ActivityContentType.php b/src/Services/CRM/Activity/ActivityContentType.php
index 57273409..70d345b6 100644
--- a/src/Services/CRM/Activity/ActivityContentType.php
+++ b/src/Services/CRM/Activity/ActivityContentType.php
@@ -22,4 +22,4 @@ enum ActivityContentType: int
case plainText = 1;
case bbCode = 2;
case html = 3;
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ActivityDirectionType.php b/src/Services/CRM/Activity/ActivityDirectionType.php
index 94b893b8..01dce084 100644
--- a/src/Services/CRM/Activity/ActivityDirectionType.php
+++ b/src/Services/CRM/Activity/ActivityDirectionType.php
@@ -21,4 +21,4 @@ enum ActivityDirectionType: int
case default = 0;
case incoming = 1;
case outgoing = 2;
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ActivityFetcherBuilder.php b/src/Services/CRM/Activity/ActivityFetcherBuilder.php
index f21ab419..83baadc1 100644
--- a/src/Services/CRM/Activity/ActivityFetcherBuilder.php
+++ b/src/Services/CRM/Activity/ActivityFetcherBuilder.php
@@ -22,9 +22,6 @@
class ActivityFetcherBuilder extends AbstractServiceBuilder
{
- /**
- * @return \Bitrix24\SDK\Services\CRM\Activity\ReadModel\EmailFetcher
- */
public function emailFetcher(): Activity\ReadModel\EmailFetcher
{
if (!isset($this->serviceCache[__METHOD__])) {
@@ -34,9 +31,6 @@ public function emailFetcher(): Activity\ReadModel\EmailFetcher
return $this->serviceCache[__METHOD__];
}
- /**
- * @return \Bitrix24\SDK\Services\CRM\Activity\ReadModel\OpenLineFetcher
- */
public function openLineFetcher(): Activity\ReadModel\OpenLineFetcher
{
if (!isset($this->serviceCache[__METHOD__])) {
@@ -46,9 +40,6 @@ public function openLineFetcher(): Activity\ReadModel\OpenLineFetcher
return $this->serviceCache[__METHOD__];
}
- /**
- * @return \Bitrix24\SDK\Services\CRM\Activity\ReadModel\VoximplantFetcher
- */
public function voximplantFetcher(): Activity\ReadModel\VoximplantFetcher
{
if (!isset($this->serviceCache[__METHOD__])) {
@@ -58,9 +49,6 @@ public function voximplantFetcher(): Activity\ReadModel\VoximplantFetcher
return $this->serviceCache[__METHOD__];
}
- /**
- * @return \Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher
- */
public function webFormFetcher(): Activity\ReadModel\WebFormFetcher
{
if (!isset($this->serviceCache[__METHOD__])) {
@@ -69,4 +57,4 @@ public function webFormFetcher(): Activity\ReadModel\WebFormFetcher
return $this->serviceCache[__METHOD__];
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ActivityNotifyType.php b/src/Services/CRM/Activity/ActivityNotifyType.php
index 6ecbd718..09f66be7 100644
--- a/src/Services/CRM/Activity/ActivityNotifyType.php
+++ b/src/Services/CRM/Activity/ActivityNotifyType.php
@@ -22,4 +22,4 @@ enum ActivityNotifyType: int
case minutes = 1;
case hours = 2;
case days = 3;
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ActivityPriority.php b/src/Services/CRM/Activity/ActivityPriority.php
index dec4d9de..b0640944 100644
--- a/src/Services/CRM/Activity/ActivityPriority.php
+++ b/src/Services/CRM/Activity/ActivityPriority.php
@@ -22,4 +22,4 @@ enum ActivityPriority: int
case low = 1;
case medium = 2;
case high = 3;
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ActivityStatus.php b/src/Services/CRM/Activity/ActivityStatus.php
index 2678b8ca..f2a8e1ca 100644
--- a/src/Services/CRM/Activity/ActivityStatus.php
+++ b/src/Services/CRM/Activity/ActivityStatus.php
@@ -22,4 +22,4 @@ enum ActivityStatus: int
case waiting = 1;
case finished = 2;
case finishedAutomatically = 3;
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ActivityType.php b/src/Services/CRM/Activity/ActivityType.php
index 46e96a59..b6f2d1b6 100644
--- a/src/Services/CRM/Activity/ActivityType.php
+++ b/src/Services/CRM/Activity/ActivityType.php
@@ -25,4 +25,4 @@ enum ActivityType: int
case letter = 4;
case action = 5;
case userAction = 6;
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ReadModel/EmailFetcher.php b/src/Services/CRM/Activity/ReadModel/EmailFetcher.php
index 0d535df5..082e2ef7 100644
--- a/src/Services/CRM/Activity/ReadModel/EmailFetcher.php
+++ b/src/Services/CRM/Activity/ReadModel/EmailFetcher.php
@@ -25,14 +25,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class EmailFetcher
{
- private BulkItemsReaderInterface $bulkItemsReader;
-
- /**
- * @param BulkItemsReaderInterface $bulkItemsReader
- */
- public function __construct(BulkItemsReaderInterface $bulkItemsReader)
+ public function __construct(private readonly BulkItemsReaderInterface $bulkItemsReader)
{
- $this->bulkItemsReader = $bulkItemsReader;
}
/**
@@ -55,4 +49,4 @@ public function getList(array $order, array $filter, array $select, ?int $limit
yield $cnt => new EmailActivityItemResult($item);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ReadModel/OpenLineFetcher.php b/src/Services/CRM/Activity/ReadModel/OpenLineFetcher.php
index c371b266..74355e9a 100644
--- a/src/Services/CRM/Activity/ReadModel/OpenLineFetcher.php
+++ b/src/Services/CRM/Activity/ReadModel/OpenLineFetcher.php
@@ -25,14 +25,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class OpenLineFetcher
{
- private BulkItemsReaderInterface $bulkItemsReader;
-
- /**
- * @param BulkItemsReaderInterface $bulkItemsReader
- */
- public function __construct(BulkItemsReaderInterface $bulkItemsReader)
+ public function __construct(private readonly BulkItemsReaderInterface $bulkItemsReader)
{
- $this->bulkItemsReader = $bulkItemsReader;
}
/**
@@ -59,4 +53,4 @@ public function getList(array $order, array $filter, array $select, ?int $openLi
yield $cnt => new OpenLineActivityItemResult($item);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ReadModel/VoximplantFetcher.php b/src/Services/CRM/Activity/ReadModel/VoximplantFetcher.php
index 9ffffa82..dfb10abf 100644
--- a/src/Services/CRM/Activity/ReadModel/VoximplantFetcher.php
+++ b/src/Services/CRM/Activity/ReadModel/VoximplantFetcher.php
@@ -25,14 +25,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class VoximplantFetcher
{
- private BulkItemsReaderInterface $bulkItemsReader;
-
- /**
- * @param BulkItemsReaderInterface $bulkItemsReader
- */
- public function __construct(BulkItemsReaderInterface $bulkItemsReader)
+ public function __construct(private readonly BulkItemsReaderInterface $bulkItemsReader)
{
- $this->bulkItemsReader = $bulkItemsReader;
}
/**
@@ -55,4 +49,4 @@ public function getList(array $order, array $filter, array $select, ?int $limit
yield $cnt => new ActivityItemResult($item);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/ReadModel/WebFormFetcher.php b/src/Services/CRM/Activity/ReadModel/WebFormFetcher.php
index b9b205be..6e24da08 100644
--- a/src/Services/CRM/Activity/ReadModel/WebFormFetcher.php
+++ b/src/Services/CRM/Activity/ReadModel/WebFormFetcher.php
@@ -25,14 +25,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class WebFormFetcher
{
- private BulkItemsReaderInterface $bulkItemsReader;
-
- /**
- * @param BulkItemsReaderInterface $bulkItemsReader
- */
- public function __construct(BulkItemsReaderInterface $bulkItemsReader)
+ public function __construct(private readonly BulkItemsReaderInterface $bulkItemsReader)
{
- $this->bulkItemsReader = $bulkItemsReader;
}
/**
@@ -55,8 +49,9 @@ public function getList(array $order, array $filter, array $select, ?int $webFor
} else {
$filter = array_merge($filter, ['PROVIDER_ID' => 'CRM_WEBFORM']);
}
+
foreach ($this->bulkItemsReader->getTraversableList('crm.activity.list', $order, $filter, $select, $limit) as $cnt => $item) {
yield $cnt => new WebFormActivityItemResult($item);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/ActivitiesResult.php b/src/Services/CRM/Activity/Result/ActivitiesResult.php
index 214f5271..2a1b3c1a 100644
--- a/src/Services/CRM/Activity/Result/ActivitiesResult.php
+++ b/src/Services/CRM/Activity/Result/ActivitiesResult.php
@@ -32,4 +32,4 @@ public function getActivities(): array
return $res;
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/ActivityItemResult.php b/src/Services/CRM/Activity/Result/ActivityItemResult.php
index d45507ff..18b6557e 100644
--- a/src/Services/CRM/Activity/Result/ActivityItemResult.php
+++ b/src/Services/CRM/Activity/Result/ActivityItemResult.php
@@ -38,7 +38,7 @@
* @property-read ActivityDirectionType $DIRECTION // with crm_enum_activity direction type
* @property-read int $EDITOR_ID // Editor
* @property-read CarbonImmutable $END_TIME // Completion time
- * @property-read array $FILES // Added files with diskfile type
+ * @property-read int $FILES // Added files with diskfile type
* @property-read int $ID // Activity ID
* @property-read boolean $IS_INCOMING_CHANNEL
* @property-read CarbonImmutable $LAST_UPDATED // Date of the last update date
@@ -67,8 +67,11 @@
* @property-read ActivityStatus $STATUS
* @property-read string $SUBJECT
* @property-read ActivityType $TYPE_ID
- * @property-read array $WEBDAV_ELEMENTS
+ * @property-read int $WEBDAV_ELEMENTS
+ * @property-read int $AUTHOR_ID
+ * @property-read int $AUTOCOMPLETE_RULE
+ * @property-read ActivityPriority $PRIORITY
*/
class ActivityItemResult extends AbstractCrmItem
{
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/ActivityResult.php b/src/Services/CRM/Activity/Result/ActivityResult.php
index c15dcc3c..5c17b6e1 100644
--- a/src/Services/CRM/Activity/Result/ActivityResult.php
+++ b/src/Services/CRM/Activity/Result/ActivityResult.php
@@ -22,4 +22,4 @@ public function activity(): ActivityItemResult
{
return new ActivityItemResult($this->getCoreResponse()->getResponseData()->getResult());
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/ActivityTypeResult.php b/src/Services/CRM/Activity/Result/ActivityTypeResult.php
new file mode 100644
index 00000000..d9adde86
--- /dev/null
+++ b/src/Services/CRM/Activity/Result/ActivityTypeResult.php
@@ -0,0 +1,28 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Bitrix24\SDK\Services\CRM\Activity\Result;
+
+use Bitrix24\SDK\Services\CRM\Common\Result\AbstractCrmItem;
+
+/**
+ * @see https://apidocs.bitrix24.com/api-reference/crm/timeline/activities/types/crm-activity-type-add.html
+ *
+ * @property-read string $TYPE_ID
+ * @property-read string $NAME
+ * @property-read string $IS_CONFIGURABLE_TYPE
+ * @property-read string $ICON_ID
+ */
+class ActivityTypeResult extends AbstractCrmItem
+{
+}
diff --git a/src/Services/CRM/Activity/Result/ActivityTypesResult.php b/src/Services/CRM/Activity/Result/ActivityTypesResult.php
new file mode 100644
index 00000000..74914d48
--- /dev/null
+++ b/src/Services/CRM/Activity/Result/ActivityTypesResult.php
@@ -0,0 +1,42 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Bitrix24\SDK\Services\CRM\Activity\Result;
+
+use Bitrix24\SDK\Core\Result\AbstractResult;
+use Bitrix24\SDK\Core\Exceptions\BaseException;
+
+/**
+ * @see https://apidocs.bitrix24.com/api-reference/crm/timeline/activities/types/crm-activity-type-add.html
+ *
+ * @property-read string $TYPE_ID
+ * @property-read string $NAME
+ * @property-read string $IS_CONFIGURABLE_TYPE
+ * @property-read int $ICON_ID
+ */
+class ActivityTypesResult extends AbstractResult
+{
+ /**
+ * @return \Bitrix24\SDK\Services\CRM\Activity\Result\ActivityTypeResult[]
+ * @throws BaseException
+ */
+ public function getActivityTypes(): array
+ {
+ $res = [];
+ foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) {
+ $res[] = new ActivityTypeResult($item);
+ }
+
+ return $res;
+ }
+}
diff --git a/src/Services/CRM/Activity/Result/CommunicationItemResult.php b/src/Services/CRM/Activity/Result/CommunicationItemResult.php
new file mode 100644
index 00000000..f042f674
--- /dev/null
+++ b/src/Services/CRM/Activity/Result/CommunicationItemResult.php
@@ -0,0 +1,30 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Bitrix24\SDK\Services\CRM\Activity\Result;
+
+use Bitrix24\SDK\Services\CRM\Common\Result\AbstractCrmItem;
+
+/**
+ * @see https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/activity-base/crm-activity-communication-fields.html
+ *
+ * @property-read int $ID
+ * @property-read int $ACTIVITY_ID
+ * @property-read int $ENTITY_ID
+ * @property-read int $ENTITY_TYPE_ID
+ * @property-read string $TYPE
+ * @property-read string $VALUE
+ */
+class CommunicationItemResult extends AbstractCrmItem
+{
+}
diff --git a/src/Services/CRM/Activity/Result/Email/EmailActivityItemResult.php b/src/Services/CRM/Activity/Result/Email/EmailActivityItemResult.php
index 77b9fc53..afab16e3 100644
--- a/src/Services/CRM/Activity/Result/Email/EmailActivityItemResult.php
+++ b/src/Services/CRM/Activity/Result/Email/EmailActivityItemResult.php
@@ -28,4 +28,4 @@ public function __get($offset)
return parent::__get($offset);
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/Email/EmailMeta.php b/src/Services/CRM/Activity/Result/Email/EmailMeta.php
index bb890e6e..3aab9409 100644
--- a/src/Services/CRM/Activity/Result/Email/EmailMeta.php
+++ b/src/Services/CRM/Activity/Result/Email/EmailMeta.php
@@ -25,4 +25,4 @@
*/
class EmailMeta extends AbstractItem
{
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/Email/EmailSettings.php b/src/Services/CRM/Activity/Result/Email/EmailSettings.php
index 8e3a1029..ecbab028 100644
--- a/src/Services/CRM/Activity/Result/Email/EmailSettings.php
+++ b/src/Services/CRM/Activity/Result/Email/EmailSettings.php
@@ -34,4 +34,4 @@ public function __get($offset)
return parent::__get($offset);
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/OpenLine/OpenLineActivityItemResult.php b/src/Services/CRM/Activity/Result/OpenLine/OpenLineActivityItemResult.php
index 5fec9612..e2731598 100644
--- a/src/Services/CRM/Activity/Result/OpenLine/OpenLineActivityItemResult.php
+++ b/src/Services/CRM/Activity/Result/OpenLine/OpenLineActivityItemResult.php
@@ -17,11 +17,8 @@
class OpenLineActivityItemResult extends ActivityItemResult
{
- /**
- * @return \Bitrix24\SDK\Services\CRM\Activity\Result\OpenLine\OpenLineProviderParams
- */
public function getProviderParams(): OpenLineProviderParams
{
return new OpenLineProviderParams($this->PROVIDER_PARAMS['USER_CODE']);
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/OpenLine/OpenLineProviderParams.php b/src/Services/CRM/Activity/Result/OpenLine/OpenLineProviderParams.php
index 8ca1c3f9..66235150 100644
--- a/src/Services/CRM/Activity/Result/OpenLine/OpenLineProviderParams.php
+++ b/src/Services/CRM/Activity/Result/OpenLine/OpenLineProviderParams.php
@@ -16,37 +16,22 @@
class OpenLineProviderParams
{
- private string $userCode;
-
- /**
- * @param string $userCode
- */
- public function __construct(string $userCode)
+ public function __construct(private readonly string $userCode)
{
- $this->userCode = $userCode;
}
- /**
- * @return string
- */
public function getUserCode(): string
{
return $this->userCode;
}
- /**
- * @return int
- */
public function getBitrix24UserId(): int
{
return (int)explode('|', $this->getUserCode())[3];
}
- /**
- * @return string
- */
public function getExternalSystemUserId(): string
{
return explode('|', $this->getUserCode())[2];
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/WebForm/VisitedPageItem.php b/src/Services/CRM/Activity/Result/WebForm/VisitedPageItem.php
index 16b20878..4f7ff01e 100644
--- a/src/Services/CRM/Activity/Result/WebForm/VisitedPageItem.php
+++ b/src/Services/CRM/Activity/Result/WebForm/VisitedPageItem.php
@@ -23,4 +23,3 @@
class VisitedPageItem extends AbstractItem
{
}
-
diff --git a/src/Services/CRM/Activity/Result/WebForm/WebFormActivityItemResult.php b/src/Services/CRM/Activity/Result/WebForm/WebFormActivityItemResult.php
index d36cc0df..9b213df5 100644
--- a/src/Services/CRM/Activity/Result/WebForm/WebFormActivityItemResult.php
+++ b/src/Services/CRM/Activity/Result/WebForm/WebFormActivityItemResult.php
@@ -17,9 +17,6 @@
class WebFormActivityItemResult extends ActivityItemResult
{
- /**
- * @return \Bitrix24\SDK\Services\CRM\Activity\Result\WebForm\WebFormProviderParams
- */
public function getProviderParams(): WebFormProviderParams
{
return new WebFormProviderParams(
@@ -33,4 +30,4 @@ public function getProviderParams(): WebFormProviderParams
$this->PROVIDER_PARAMS['VISITED_PAGES'],
);
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/WebForm/WebFormFieldItem.php b/src/Services/CRM/Activity/Result/WebForm/WebFormFieldItem.php
index 715459d2..6c7c281a 100644
--- a/src/Services/CRM/Activity/Result/WebForm/WebFormFieldItem.php
+++ b/src/Services/CRM/Activity/Result/WebForm/WebFormFieldItem.php
@@ -26,4 +26,3 @@
class WebFormFieldItem extends AbstractItem
{
}
-
diff --git a/src/Services/CRM/Activity/Result/WebForm/WebFormMetadata.php b/src/Services/CRM/Activity/Result/WebForm/WebFormMetadata.php
index c1a9c457..d144137b 100644
--- a/src/Services/CRM/Activity/Result/WebForm/WebFormMetadata.php
+++ b/src/Services/CRM/Activity/Result/WebForm/WebFormMetadata.php
@@ -16,54 +16,27 @@
class WebFormMetadata
{
- private bool $isUsedUserConsent;
- private array $agreements;
- private string $ip;
- private string $link;
-
- /**
- * @param bool $isUsedUserConsent
- * @param array $agreements
- * @param string $ip
- * @param string $link
- */
- public function __construct(bool $isUsedUserConsent, array $agreements, string $ip, string $link)
+ public function __construct(private readonly bool $isUsedUserConsent, private readonly array $agreements, private readonly string $ip, private readonly string $link)
{
- $this->isUsedUserConsent = $isUsedUserConsent;
- $this->agreements = $agreements;
- $this->ip = $ip;
- $this->link = $link;
}
- /**
- * @return bool
- */
public function isUsedUserConsent(): bool
{
return $this->isUsedUserConsent;
}
- /**
- * @return array
- */
public function getAgreements(): array
{
return $this->agreements;
}
- /**
- * @return string
- */
public function getIp(): string
{
return $this->ip;
}
- /**
- * @return string
- */
public function getLink(): string
{
return $this->link;
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Result/WebForm/WebFormProviderParams.php b/src/Services/CRM/Activity/Result/WebForm/WebFormProviderParams.php
index e8c8d572..b1e0cef4 100644
--- a/src/Services/CRM/Activity/Result/WebForm/WebFormProviderParams.php
+++ b/src/Services/CRM/Activity/Result/WebForm/WebFormProviderParams.php
@@ -16,20 +16,8 @@
class WebFormProviderParams
{
- private array $fields;
- private WebFormMetadata $webForm;
- private array $visitedPages;
-
- /**
- * @param array $fields
- * @param \Bitrix24\SDK\Services\CRM\Activity\Result\WebForm\WebFormMetadata $webForm
- * @param array $visitedPages
- */
- public function __construct(array $fields, WebFormMetadata $webForm, array $visitedPages)
+ public function __construct(private readonly array $fields, private readonly WebFormMetadata $webForm, private readonly array $visitedPages)
{
- $this->fields = $fields;
- $this->webForm = $webForm;
- $this->visitedPages = $visitedPages;
}
/**
@@ -45,9 +33,6 @@ public function getFields(): array
return $res;
}
- /**
- * @return \Bitrix24\SDK\Services\CRM\Activity\Result\WebForm\WebFormMetadata
- */
public function getWebForm(): WebFormMetadata
{
return $this->webForm;
@@ -59,10 +44,10 @@ public function getWebForm(): WebFormMetadata
public function getVisitedPages(): array
{
$res = [];
- foreach ($this->visitedPages as $page) {
- $res[] = new VisitedPageItem($page);
+ foreach ($this->visitedPages as $visitedPage) {
+ $res[] = new VisitedPageItem($visitedPage);
}
return $res;
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Service/Activity.php b/src/Services/CRM/Activity/Service/Activity.php
index 6ef0993d..016b6442 100644
--- a/src/Services/CRM/Activity/Service/Activity.php
+++ b/src/Services/CRM/Activity/Service/Activity.php
@@ -32,19 +32,12 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class Activity extends AbstractService
{
- public Batch $batch;
-
/**
* Contact constructor.
- *
- * @param Batch $batch
- * @param CoreInterface $core
- * @param LoggerInterface $log
*/
- public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $log)
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
- $this->batch = $batch;
+ parent::__construct($core, $logger);
}
/**
@@ -98,7 +91,6 @@ public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $
* WEBDAV_ELEMENTS?: string,
* } $fields
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -124,9 +116,7 @@ public function add(array $fields): AddedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/rest_activity/crm_activity_delete.php
*
- * @param int $itemId
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -152,7 +142,6 @@ public function delete(int $itemId): DeletedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/rest_activity/crm_activity_fields.php
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -171,9 +160,7 @@ public function fields(): FieldsResult
*
* @link https://training.bitrix24.com/rest_help/crm/rest_activity/crm_activity_get.php
*
- * @param int $entityId
*
- * @return ActivityResult
* @throws BaseException
* @throws TransportException
*/
@@ -292,9 +279,7 @@ public function get(int $entityId): ActivityResult
* } $filter
*
* @param array $select = ['ID','OWNER_ID','OWNER_TYPE_ID','TYPE_ID','PROVIDER_ID','PROVIDER_TYPE_ID','PROVIDER_GROUP_ID','ASSOCIATED_ENTITY_ID','SUBJECT','START_TIME','END_TIME','DEADLINE','COMPLETED','STATUS','RESPONSIBLE_ID','PRIORITY','NOTIFY_TYPE','NOTIFY_VALUE','DESCRIPTION','DESCRIPTION_TYPE','DIRECTION','LOCATION','CREATED','AUTHOR_ID','LAST_UPDATED','EDITOR_ID','SETTINGS','ORIGIN_ID','ORIGINATOR_ID','RESULT_STATUS','RESULT_STREAM','RESULT_SOURCE_ID','PROVIDER_PARAMS','PROVIDER_DATA','RESULT_MARK','RESULT_VALUE','RESULT_SUM','RESULT_CURRENCY_ID','AUTOCOMPLETE_RULE','BINDINGS','COMMUNICATIONS','FILES','WEBDAV_ELEMENTS','COMMUNICATIONS']
- * @param int $start
*
- * @return ActivitiesResult
* @throws BaseException
* @throws TransportException
*/
@@ -323,7 +308,6 @@ public function list(array $order, array $filter, array $select, int $start): Ac
*
* @see https://training.bitrix24.com/rest_help/crm/rest_activity/crm_activity_update.php
*
- * @param int $itemId
* @param array{
* ID?: int,
* OWNER_ID?: int,
@@ -370,7 +354,6 @@ public function list(array $order, array $filter, array $select, int $start): Ac
* WEBDAV_ELEMENTS?: string,
* } $fields
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -441,7 +424,6 @@ public function update(int $itemId, array $fields): UpdatedItemResult
* WEBDAV_ELEMENTS?: string,
* } $filter
*
- * @return int
* @throws BaseException
* @throws TransportException
*/
@@ -449,4 +431,4 @@ public function countByFilter(array $filter = []): int
{
return $this->list([], $filter, ['ID'], 1)->getCoreResponse()->getResponseData()->getPagination()->getTotal();
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Service/ActivityType.php b/src/Services/CRM/Activity/Service/ActivityType.php
new file mode 100644
index 00000000..f38fce8e
--- /dev/null
+++ b/src/Services/CRM/Activity/Service/ActivityType.php
@@ -0,0 +1,108 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Bitrix24\SDK\Services\CRM\Activity\Service;
+
+use Bitrix24\SDK\Attributes\ApiEndpointMetadata;
+use Bitrix24\SDK\Attributes\ApiServiceMetadata;
+use Bitrix24\SDK\Core\Contracts\CoreInterface;
+use Bitrix24\SDK\Core\Credentials\Scope;
+use Bitrix24\SDK\Core\Exceptions\BaseException;
+use Bitrix24\SDK\Core\Exceptions\TransportException;
+use Bitrix24\SDK\Core\Result\AddedItemResult;
+use Bitrix24\SDK\Core\Result\DeletedItemResult;
+use Bitrix24\SDK\Services\AbstractService;
+use Bitrix24\SDK\Services\CRM\Activity\Result\ActivityTypesResult;
+use Psr\Log\LoggerInterface;
+
+#[ApiServiceMetadata(new Scope(['crm']))]
+class ActivityType extends AbstractService
+{
+ /**
+ * Contact constructor.
+ */
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
+ {
+ parent::__construct($core, $logger);
+ }
+
+ /**
+ * The method registers a custom activity type with a name and icon.
+ *
+ * @link https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/types/crm-activity-type-add
+ *
+ * @throws BaseException
+ * @throws TransportException
+ */
+ #[ApiEndpointMetadata(
+ 'crm.activity.type.add',
+ 'https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/types/crm-activity-type-add',
+ 'The method registers a custom activity type with a name and icon.'
+ )]
+ public function add(array $fields): AddedItemResult
+ {
+ return new AddedItemResult(
+ $this->core->call(
+ 'crm.activity.type.add',
+ [
+ 'fields' => $fields,
+ ]
+ )
+ );
+ }
+
+ /**
+ * Delete a custom case type.
+ *
+ * @link https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/types/crm-activity-type-delete.html
+ *
+ * @throws BaseException
+ * @throws TransportException
+ */
+ #[ApiEndpointMetadata(
+ 'crm.activity.type.delete',
+ 'https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/types/crm-activity-type-delete.html',
+ 'Delete a custom activity type.'
+ )]
+ public function delete(string $itemId): DeletedItemResult
+ {
+ return new DeletedItemResult(
+ $this->core->call(
+ 'crm.activity.type.delete',
+ [
+ 'TYPE_ID' => $itemId,
+ ]
+ )
+ );
+ }
+
+ /**
+ * Get a list of custom task types.
+ *
+ * @link https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/types/crm-activity-type-list.html
+ *
+ * @throws BaseException
+ * @throws TransportException
+ */
+ #[ApiEndpointMetadata(
+ 'crm.activity.type.list',
+ 'https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/types/crm-activity-type-list.html',
+ 'Get a list of custom task types.'
+ )]
+ public function list(): ActivityTypesResult
+ {
+ return new ActivityTypesResult(
+ $this->core->call('crm.activity.type.list')
+ );
+ }
+}
diff --git a/src/Services/CRM/Activity/Service/Batch.php b/src/Services/CRM/Activity/Service/Batch.php
index 06dba9b6..c781123b 100644
--- a/src/Services/CRM/Activity/Service/Batch.php
+++ b/src/Services/CRM/Activity/Service/Batch.php
@@ -122,7 +122,6 @@ class Batch extends AbstractBatchService
* WEBDAV_ELEMENTS?: string,
* } $filter
* @param array $select = ['ID','OWNER_ID','OWNER_TYPE_ID','TYPE_ID','PROVIDER_ID','PROVIDER_TYPE_ID','PROVIDER_GROUP_ID','ASSOCIATED_ENTITY_ID','SUBJECT','START_TIME','END_TIME','DEADLINE','COMPLETED','STATUS','RESPONSIBLE_ID','PRIORITY','NOTIFY_TYPE','NOTIFY_VALUE','DESCRIPTION','DESCRIPTION_TYPE','DIRECTION','LOCATION','CREATED','AUTHOR_ID','LAST_UPDATED','EDITOR_ID','SETTINGS','ORIGIN_ID','ORIGINATOR_ID','RESULT_STATUS','RESULT_STREAM','RESULT_SOURCE_ID','PROVIDER_PARAMS','PROVIDER_DATA','RESULT_MARK','RESULT_VALUE','RESULT_SUM','RESULT_CURRENCY_ID','AUTOCOMPLETE_RULE','BINDINGS','COMMUNICATIONS','FILES','WEBDAV_ELEMENTS','COMMUNICATIONS']
- * @param int|null $limit
*
* @return Generator
* @throws BaseException
@@ -213,6 +212,7 @@ public function add(array $activities): Generator
'fields' => $activity,
];
}
+
foreach ($this->batch->addEntityItems('crm.activity.add', $items) as $key => $item) {
yield $key => new AddedItemBatchResult($item);
}
@@ -237,4 +237,4 @@ public function delete(array $itemId): Generator
yield $key => new DeletedItemBatchResult($item);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/CRM/Activity/Service/Communication.php b/src/Services/CRM/Activity/Service/Communication.php
new file mode 100644
index 00000000..a0180745
--- /dev/null
+++ b/src/Services/CRM/Activity/Service/Communication.php
@@ -0,0 +1,54 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Bitrix24\SDK\Services\CRM\Activity\Service;
+
+use Bitrix24\SDK\Attributes\ApiEndpointMetadata;
+use Bitrix24\SDK\Attributes\ApiServiceMetadata;
+use Bitrix24\SDK\Core\Contracts\CoreInterface;
+use Bitrix24\SDK\Core\Credentials\Scope;
+use Bitrix24\SDK\Core\Exceptions\BaseException;
+use Bitrix24\SDK\Core\Exceptions\TransportException;
+use Bitrix24\SDK\Services\AbstractService;
+use Bitrix24\SDK\Core\Result\FieldsResult;
+use Psr\Log\LoggerInterface;
+
+#[ApiServiceMetadata(new Scope(['crm']))]
+class Communication extends AbstractService
+{
+ /**
+ * Contact constructor.
+ */
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
+ {
+ parent::__construct($core, $logger);
+ }
+
+ /**
+ * Get a description of the communication.
+ *
+ * @link https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/activity-base/crm-activity-communication-fields.html
+ *
+ * @throws BaseException
+ * @throws TransportException
+ */
+ #[ApiEndpointMetadata(
+ 'crm.activity.communication.fields',
+ 'https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/activity-base/crm-activity-communication-fields.html',
+ 'Get a description of the communication.'
+ )]
+ public function fields(): FieldsResult
+ {
+ return new FieldsResult($this->core->call('crm.activity.communication.fields'));
+ }
+}
diff --git a/src/Services/CRM/CRMServiceBuilder.php b/src/Services/CRM/CRMServiceBuilder.php
index 40856782..597076d7 100644
--- a/src/Services/CRM/CRMServiceBuilder.php
+++ b/src/Services/CRM/CRMServiceBuilder.php
@@ -210,9 +210,6 @@ public function contactUserfield(): Contact\Service\ContactUserfield
return $this->serviceCache[__METHOD__];
}
- /**
- * @return Deal\Service\DealProductRows
- */
public function dealProductRows(): Deal\Service\DealProductRows
{
if (!isset($this->serviceCache[__METHOD__])) {
@@ -296,6 +293,32 @@ public function activityFetcher(): Activity\ActivityFetcherBuilder
return $this->serviceCache[__METHOD__];
}
+ public function activityType(): Activity\Service\ActivityType
+ {
+ if (!isset($this->serviceCache[__METHOD__])) {
+ $this->serviceCache[__METHOD__] = new Activity\Service\ActivityType(
+ new Activity\Service\Batch($this->batch, $this->log),
+ $this->core,
+ $this->log
+ );
+ }
+
+ return $this->serviceCache[__METHOD__];
+ }
+
+ public function communication(): Activity\Service\Communication
+ {
+ if (!isset($this->serviceCache[__METHOD__])) {
+ $this->serviceCache[__METHOD__] = new Activity\Service\Communication(
+ new Activity\Service\Batch($this->batch, $this->log),
+ $this->core,
+ $this->log
+ );
+ }
+
+ return $this->serviceCache[__METHOD__];
+ }
+
public function item(): Item\Service\Item
{
if (!isset($this->serviceCache[__METHOD__])) {
diff --git a/src/Services/CRM/Common/CardFieldConfiguration.php b/src/Services/CRM/Common/CardFieldConfiguration.php
index 3745fda1..87c2550a 100644
--- a/src/Services/CRM/Common/CardFieldConfiguration.php
+++ b/src/Services/CRM/Common/CardFieldConfiguration.php
@@ -15,12 +15,10 @@
readonly class CardFieldConfiguration
{
- public string $name;
/**
* @param non-empty-string $name
*/
- public function __construct(string $name)
+ public function __construct(public string $name)
{
- $this->name = $name;
}
}
\ No newline at end of file
diff --git a/src/Services/CRM/Common/CardSectionConfiguration.php b/src/Services/CRM/Common/CardSectionConfiguration.php
index 385155e1..9c363773 100644
--- a/src/Services/CRM/Common/CardSectionConfiguration.php
+++ b/src/Services/CRM/Common/CardSectionConfiguration.php
@@ -17,9 +17,6 @@
readonly class CardSectionConfiguration
{
- public string $name;
- public string $title;
- public string $type;
public array $elements;
/**
@@ -29,7 +26,7 @@
* @param non-empty-string $type
* @throws InvalidArgumentException
*/
- public function __construct(string $name, string $title, array $elements, string $type = 'section')
+ public function __construct(public string $name, public string $title, array $elements, public string $type = 'section')
{
foreach ($elements as $element) {
if (!$element instanceof CardFieldConfiguration) {
@@ -43,9 +40,6 @@ public function __construct(string $name, string $title, array $elements, string
}
}
- $this->name = $name;
- $this->title = $title;
- $this->type = $type;
$this->elements = $elements;
}
diff --git a/src/Services/CRM/Common/CompanyConnection.php b/src/Services/CRM/Common/CompanyConnection.php
index a052eced..77326775 100644
--- a/src/Services/CRM/Common/CompanyConnection.php
+++ b/src/Services/CRM/Common/CompanyConnection.php
@@ -15,19 +15,11 @@
readonly class CompanyConnection
{
- public int $companyId;
- public int $sort;
- public bool $isPrimary;
-
/**
* @param positive-int $companyId
* @param positive-int $sort
- * @param bool $isPrimary
*/
- public function __construct(int $companyId, int $sort = 100, bool $isPrimary = false)
+ public function __construct(public int $companyId, public int $sort = 100, public bool $isPrimary = false)
{
- $this->companyId = $companyId;
- $this->sort = $sort;
- $this->isPrimary = $isPrimary;
}
}
\ No newline at end of file
diff --git a/src/Services/CRM/Common/ContactConnection.php b/src/Services/CRM/Common/ContactConnection.php
index d59dd6c0..99a4af4c 100644
--- a/src/Services/CRM/Common/ContactConnection.php
+++ b/src/Services/CRM/Common/ContactConnection.php
@@ -15,19 +15,11 @@
readonly class ContactConnection
{
- public int $contactId;
- public int $sort;
- public bool $isPrimary;
-
/**
* @param positive-int $contactId
* @param positive-int $sort
- * @param bool $isPrimary
*/
- public function __construct(int $contactId, int $sort = 100, bool $isPrimary = false)
+ public function __construct(public int $contactId, public int $sort = 100, public bool $isPrimary = false)
{
- $this->contactId = $contactId;
- $this->sort = $sort;
- $this->isPrimary = $isPrimary;
}
}
\ No newline at end of file
diff --git a/src/Services/CRM/Common/Result/AbstractCrmItem.php b/src/Services/CRM/Common/Result/AbstractCrmItem.php
index cf130122..f5e096f4 100644
--- a/src/Services/CRM/Common/Result/AbstractCrmItem.php
+++ b/src/Services/CRM/Common/Result/AbstractCrmItem.php
@@ -36,6 +36,7 @@
class AbstractCrmItem extends AbstractItem
{
private Currency $currency;
+
private const CRM_USERFIELD_PREFIX = 'UF_CRM_';
/**
@@ -98,6 +99,7 @@ public function __get($offset)
if ($this->data[$offset] !== '' && $this->data[$offset] !== null && $this->data[$offset] !== '0') {
return (int)$this->data[$offset];
}
+
return null;
case 'EXPORT':
case 'HAS_PHONE':
@@ -160,11 +162,13 @@ public function __get($offset)
$var = $this->data[$offset] * 100;
return new Money((string)$var, new Currency($this->currency->getCode()));
}
+
return null;
case 'RESULT_CURRENCY_ID':
if ($this->data[$offset] !== '' && $this->data[$offset] !== null) {
return new Currency($this->data[$offset]);
}
+
return null;
case 'PHONE':
if (!$this->isKeyExists($offset)) {
@@ -175,6 +179,7 @@ public function __get($offset)
foreach ($this->data[$offset] as $item) {
$items[] = new Phone($item);
}
+
return $items;
case 'EMAIL':
if (!$this->isKeyExists($offset)) {
@@ -185,6 +190,7 @@ public function __get($offset)
foreach ($this->data[$offset] as $item) {
$items[] = new Email($item);
}
+
return $items;
case 'WEB':
if (!$this->isKeyExists($offset)) {
@@ -195,6 +201,7 @@ public function __get($offset)
foreach ($this->data[$offset] as $item) {
$items[] = new Website($item);
}
+
return $items;
case 'IM':
if (!$this->isKeyExists($offset)) {
@@ -205,6 +212,7 @@ public function __get($offset)
foreach ($this->data[$offset] as $item) {
$items[] = new InstantMessenger($item);
}
+
return $items;
case 'currencyId':
case 'accountCurrencyId':
@@ -214,6 +222,7 @@ public function __get($offset)
if ($this->data[$offset] !== null) {
return DealSemanticStage::from($this->data[$offset]);
}
+
return null;
case 'DISCOUNT_TYPE_ID':
return DiscountType::from($this->data[$offset]);
@@ -242,7 +251,6 @@ public function __get($offset)
/**
* get userfield by field name
*
- * @param string $fieldName
*
* @return mixed|null
* @throws UserfieldNotFoundException
@@ -252,6 +260,7 @@ protected function getKeyWithUserfieldByFieldName(string $fieldName): mixed
if (!str_starts_with($fieldName, self::CRM_USERFIELD_PREFIX)) {
$fieldName = self::CRM_USERFIELD_PREFIX . $fieldName;
}
+
if (!$this->isKeyExists($fieldName)) {
throw new UserfieldNotFoundException(sprintf('crm userfield not found by field name %s', $fieldName));
}
@@ -262,7 +271,7 @@ protected function getKeyWithUserfieldByFieldName(string $fieldName): mixed
public function __construct(array $data, Currency $currency = null)
{
parent::__construct($data);
- if ($currency !== null) {
+ if ($currency instanceof \Money\Currency) {
$this->currency = $currency;
}
}
diff --git a/src/Services/CRM/Common/Result/ElementCardConfiguration/CardConfigurationsResult.php b/src/Services/CRM/Common/Result/ElementCardConfiguration/CardConfigurationsResult.php
index 701fd511..70fd8dec 100644
--- a/src/Services/CRM/Common/Result/ElementCardConfiguration/CardConfigurationsResult.php
+++ b/src/Services/CRM/Common/Result/ElementCardConfiguration/CardConfigurationsResult.php
@@ -31,6 +31,7 @@ public function getSections(): array
if ($item === null) {
continue;
}
+
$res[] = new ConfigurationItemResult($item);
}
diff --git a/src/Services/CRM/Company/Result/CompanyItemResult.php b/src/Services/CRM/Company/Result/CompanyItemResult.php
index 94bb6287..5c83f246 100644
--- a/src/Services/CRM/Company/Result/CompanyItemResult.php
+++ b/src/Services/CRM/Company/Result/CompanyItemResult.php
@@ -85,7 +85,6 @@
class CompanyItemResult extends AbstractCrmItem
{
/**
- * @param string $userfieldName
*
* @return mixed|null
* @throws UserfieldNotFoundException
diff --git a/src/Services/CRM/Company/Service/Batch.php b/src/Services/CRM/Company/Service/Batch.php
index 3274ad40..737a8214 100644
--- a/src/Services/CRM/Company/Service/Batch.php
+++ b/src/Services/CRM/Company/Service/Batch.php
@@ -33,7 +33,6 @@ class Batch extends AbstractBatchService
* @param array $order - order of company items
* @param array $filter = ['ID','TITLE','COMPANY_TYPE','LOGO','ADDRESS','ADDRESS_2','ADDRESS_CITY','ADDRESS_POSTAL_CODE','ADDRESS_REGION','ADDRESS_PROVINCE','ADDRESS_COUNTRY','ADDRESS_COUNTRY_CODE','ADDRESS_LOC_ADDR_ID','ADDRESS_LEGAL','REG_ADDRESS','REG_ADDRESS_2','REG_ADDRESS_CITY','REG_ADDRESS_POSTAL_CODE','REG_ADDRESS_REGION','REG_ADDRESS_PROVINCE','REG_ADDRESS_COUNTRY','REG_ADDRESS_COUNTRY_CODE','REG_ADDRESS_LOC_ADDR_ID','BANKING_DETAILS','INDUSTRY','EMPLOYEES','CURRENCY_ID','REVENUE','OPENED','COMMENTS','HAS_PHONE','HAS_EMAIL','HAS_IMOL','IS_MY_COMPANY','ASSIGNED_BY_ID','CREATED_BY_ID','MODIFY_BY_ID','DATE_CREATE','DATE_MODIFY','CONTACT_ID','LEAD_ID','ORIGINATOR_ID','ORIGIN_ID','ORIGIN_VERSION','UTM_SOURCE','UTM_MEDIUM','UTM_CAMPAIGN','UTM_CONTENT','UTM_TERM','LAST_ACTIVITY_TIME','LAST_ACTIVITY_BY','PHONE','EMAIL','WEB','IM','LINK']
* @param array $select = ['ID','TITLE','COMPANY_TYPE','LOGO','ADDRESS','ADDRESS_2','ADDRESS_CITY','ADDRESS_POSTAL_CODE','ADDRESS_REGION','ADDRESS_PROVINCE','ADDRESS_COUNTRY','ADDRESS_COUNTRY_CODE','ADDRESS_LOC_ADDR_ID','ADDRESS_LEGAL','REG_ADDRESS','REG_ADDRESS_2','REG_ADDRESS_CITY','REG_ADDRESS_POSTAL_CODE','REG_ADDRESS_REGION','REG_ADDRESS_PROVINCE','REG_ADDRESS_COUNTRY','REG_ADDRESS_COUNTRY_CODE','REG_ADDRESS_LOC_ADDR_ID','BANKING_DETAILS','INDUSTRY','EMPLOYEES','CURRENCY_ID','REVENUE','OPENED','COMMENTS','HAS_PHONE','HAS_EMAIL','HAS_IMOL','IS_MY_COMPANY','ASSIGNED_BY_ID','CREATED_BY_ID','MODIFY_BY_ID','DATE_CREATE','DATE_MODIFY','CONTACT_ID','LEAD_ID','ORIGINATOR_ID','ORIGIN_ID','ORIGIN_VERSION','UTM_SOURCE','UTM_MEDIUM','UTM_CAMPAIGN','UTM_CONTENT','UTM_TERM','LAST_ACTIVITY_TIME','LAST_ACTIVITY_BY','PHONE','EMAIL','WEB','IM','LINK']
- * @param int|null $limit
*
* @return Generator
* @throws BaseException
@@ -145,6 +144,7 @@ public function add(array $companies): Generator
'fields' => $company,
];
}
+
foreach ($this->batch->addEntityItems('crm.company.add', $items) as $key => $item) {
yield $key => new AddedItemBatchResult($item);
}
diff --git a/src/Services/CRM/Company/Service/Company.php b/src/Services/CRM/Company/Service/Company.php
index d1fd1a59..cc648937 100644
--- a/src/Services/CRM/Company/Service/Company.php
+++ b/src/Services/CRM/Company/Service/Company.php
@@ -31,19 +31,12 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class Company extends AbstractService
{
- public Batch $batch;
-
/**
* Deal constructor.
- *
- * @param Batch $batch
- * @param CoreInterface $core
- * @param LoggerInterface $log
*/
- public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $log)
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
- $this->batch = $batch;
+ parent::__construct($core, $logger);
}
/**
@@ -51,7 +44,6 @@ public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $
*
* @link https://apidocs.bitrix24.com/api-reference/crm/companies/crm-company-fields.html
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -131,7 +123,6 @@ public function fields(): FieldsResult
* REGISTER_SONET_EVENT?: string
* } $params
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -158,9 +149,7 @@ public function add(array $fields, array $params = []): AddedItemResult
*
* @link https://apidocs.bitrix24.com/api-reference/crm/companies/crm-company-get.html
*
- * @param int $id
*
- * @return CompanyResult
* @throws BaseException
* @throws TransportException
*/
@@ -179,9 +168,7 @@ public function get(int $id): CompanyResult
*
* @link https://apidocs.bitrix24.com/api-reference/crm/companies/crm-company-delete.html
*
- * @param int $id
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -214,7 +201,6 @@ public function delete(int $id): DeletedItemResult
*
* @throws BaseException
* @throws TransportException
- * @return CompaniesResult
*/
#[ApiEndpointMetadata(
'crm.company.list',
@@ -241,7 +227,6 @@ public function list(array $order = [], array $filter = [], array $select = [],
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_update.php
*
- * @param int $id
* @param array{
* TITLE?: string,
* COMPANY_TYPE?: string,
@@ -304,7 +289,6 @@ public function list(array $order = [], array $filter = [], array $select = [],
* REGISTER_SONET_EVENT?: string
* } $params
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -386,7 +370,6 @@ public function update(int $id, array $fields, array $params = []): UpdatedItemR
* IM?: string,
* LINK?: string,
* } $filter
- * @return int
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Company/Service/CompanyContact.php b/src/Services/CRM/Company/Service/CompanyContact.php
index b0c875bc..e7613367 100644
--- a/src/Services/CRM/Company/Service/CompanyContact.php
+++ b/src/Services/CRM/Company/Service/CompanyContact.php
@@ -36,7 +36,6 @@ class CompanyContact extends AbstractService
*
* @link https://apidocs.bitrix24.com/api-reference/crm/companies/contacts/crm-company-contact-fields.html
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -66,19 +65,20 @@ public function fields(): FieldsResult
public function setItems(int $companyId, array $contactConnections): UpdatedItemResult
{
$items = [];
- foreach ($contactConnections as $item) {
- if (!$item instanceof ContactConnection) {
+ foreach ($contactConnections as $contactConnection) {
+ if (!$contactConnection instanceof ContactConnection) {
throw new InvalidArgumentException(
- sprintf('array item «%s» must be «%s» type', gettype($item), ContactConnection::class)
+ sprintf('array item «%s» must be «%s» type', gettype($contactConnection), ContactConnection::class)
);
}
$items[] = [
- 'CONTACT_ID' => $item->contactId,
- 'SORT' => $item->sort,
- 'IS_PRIMARY' => $item->isPrimary ? 'Y' : 'N'
+ 'CONTACT_ID' => $contactConnection->contactId,
+ 'SORT' => $contactConnection->sort,
+ 'IS_PRIMARY' => $contactConnection->isPrimary ? 'Y' : 'N'
];
}
+
if ($items === []) {
throw new InvalidArgumentException('empty contact connections array');
}
@@ -138,14 +138,14 @@ public function deleteItems(int $companyId): DeletedItemResult
'https://apidocs.bitrix24.com/api-reference/crm/companies/contacts/crm-company-contact-add.html',
'Add Contact to the Specified Company'
)]
- public function add(int $companyId, ContactConnection $connection): UpdatedItemResult
+ public function add(int $companyId, ContactConnection $contactConnection): UpdatedItemResult
{
return new UpdatedItemResult($this->core->call('crm.company.contact.add', [
'id' => $companyId,
'fields' => [
- 'CONTACT_ID' => $connection->contactId,
- 'SORT' => $connection->sort,
- 'IS_PRIMARY' => $connection->isPrimary ? 'Y' : 'N'
+ 'CONTACT_ID' => $contactConnection->contactId,
+ 'SORT' => $contactConnection->sort,
+ 'IS_PRIMARY' => $contactConnection->isPrimary ? 'Y' : 'N'
]
]));
}
diff --git a/src/Services/CRM/Company/Service/CompanyDetailsConfiguration.php b/src/Services/CRM/Company/Service/CompanyDetailsConfiguration.php
index ce18a7ea..d7450c04 100644
--- a/src/Services/CRM/Company/Service/CompanyDetailsConfiguration.php
+++ b/src/Services/CRM/Company/Service/CompanyDetailsConfiguration.php
@@ -122,6 +122,7 @@ public function setPersonal(array $cardConfiguration, ?int $userId = null): Upda
)
);
}
+
$rawData[] = $sectionItem->toArray();
}
@@ -156,6 +157,7 @@ public function setGeneral(array $cardConfiguration): UpdatedItemResult
)
);
}
+
$rawData[] = $sectionItem->toArray();
}
diff --git a/src/Services/CRM/Company/Service/CompanyUserfield.php b/src/Services/CRM/Company/Service/CompanyUserfield.php
index 10af13df..08cbb600 100644
--- a/src/Services/CRM/Company/Service/CompanyUserfield.php
+++ b/src/Services/CRM/Company/Service/CompanyUserfield.php
@@ -32,12 +32,9 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class CompanyUserfield extends AbstractService
{
- private UserfieldConstraints $userfieldConstraints;
-
- public function __construct(UserfieldConstraints $userfieldConstraints, CoreInterface $core, LoggerInterface $log)
+ public function __construct(private readonly UserfieldConstraints $userfieldConstraints, CoreInterface $core, LoggerInterface $logger)
{
- $this->userfieldConstraints = $userfieldConstraints;
- parent::__construct($core, $log);
+ parent::__construct($core, $logger);
}
/**
@@ -67,7 +64,6 @@ public function __construct(UserfieldConstraints $userfieldConstraints, CoreInte
* SETTINGS?: array,
* } $userfieldItemFields
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
* @throws UserfieldNameIsTooLongException
@@ -95,9 +91,7 @@ public function add(array $userfieldItemFields): AddedItemResult
/**
* Get Custom Company Field by ID
*
- * @param int $userfieldItemId
*
- * @return CompanyUserfieldResult
* @throws BaseException
* @throws TransportException
* @link https://apidocs.bitrix24.com/api-reference/crm/companies/userfields/crm-company-userfield-get.html
@@ -165,7 +159,6 @@ public function get(int $userfieldItemId): CompanyUserfieldResult
* LIST?: string,
* SETTINGS?: string,
* } $filter
- * @return CompanyUserfieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -184,9 +177,7 @@ public function list(array $order = [], array $filter = []): CompanyUserfieldsRe
/**
* Delete Custom Field for Companies
*
- * @param int $userfieldId
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
* @link https://apidocs.bitrix24.com/api-reference/crm/companies/userfields/crm-company-userfield-delete.html
@@ -212,7 +203,6 @@ public function delete(int $userfieldId): DeletedItemResult
/**
* Update Existing Custom Field for Companies
*
- * @param int $userfieldItemId
* @param array{
* ID?: string,
* ENTITY_ID?: string,
@@ -234,8 +224,6 @@ public function delete(int $userfieldId): DeletedItemResult
* LIST?: string,
* SETTINGS?: string,
* } $userfieldFieldsToUpdate
- * @param ?array $list
- * @return \Bitrix24\SDK\Core\Result\UpdatedItemResult
* @throws BaseException
* @throws TransportException
* @link https://apidocs.bitrix24.com/api-reference/crm/companies/userfields/crm-company-userfield-update.html
diff --git a/src/Services/CRM/Contact/Result/ContactItemResult.php b/src/Services/CRM/Contact/Result/ContactItemResult.php
index 81baca16..4a500c25 100644
--- a/src/Services/CRM/Contact/Result/ContactItemResult.php
+++ b/src/Services/CRM/Contact/Result/ContactItemResult.php
@@ -76,7 +76,6 @@
class ContactItemResult extends AbstractCrmItem
{
/**
- * @param string $userfieldName
*
* @return mixed|null
* @throws UserfieldNotFoundException
diff --git a/src/Services/CRM/Contact/Service/Batch.php b/src/Services/CRM/Contact/Service/Batch.php
index 4f966265..a74742a3 100644
--- a/src/Services/CRM/Contact/Service/Batch.php
+++ b/src/Services/CRM/Contact/Service/Batch.php
@@ -130,7 +130,6 @@ class Batch extends AbstractBatchService
* IM?: string,
* } $filter
* @param array $select = ['ID','HONORIFIC','NAME','SECOND_NAME','LAST_NAME','PHOTO','BIRTHDATE','TYPE_ID','SOURCE_ID','SOURCE_DESCRIPTION','POST','ADDRESS','ADDRESS_2','ADDRESS_CITY','ADDRESS_POSTAL_CODE','ADDRESS_REGION','ADDRESS_PROVINCE','ADDRESS_COUNTRY','ADDRESS_COUNTRY_CODE','ADDRESS_LOC_ADDR_ID','COMMENTS','OPENED','EXPORT','HAS_PHONE','HAS_EMAIL','HAS_IMOL','ASSIGNED_BY_ID','CREATED_BY_ID','MODIFY_BY_ID','DATE_CREATE','DATE_MODIFY','COMPANY_ID','COMPANY_IDS','LEAD_ID','ORIGINATOR_ID','ORIGIN_ID','ORIGIN_VERSION','FACE_ID','UTM_SOURCE','UTM_MEDIUM','UTM_CAMPAIGN','UTM_CONTENT','UTM_TERM','PHONE','EMAIL','WEB','IM']
- * @param int|null $limit
*
* @return Generator
* @throws BaseException
@@ -225,6 +224,7 @@ public function add(array $contacts): Generator
'fields' => $contact,
];
}
+
foreach ($this->batch->addEntityItems('crm.contact.add', $items) as $key => $item) {
yield $key => new AddedItemBatchResult($item);
}
diff --git a/src/Services/CRM/Contact/Service/Contact.php b/src/Services/CRM/Contact/Service/Contact.php
index d282648e..158b8c79 100644
--- a/src/Services/CRM/Contact/Service/Contact.php
+++ b/src/Services/CRM/Contact/Service/Contact.php
@@ -31,19 +31,12 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class Contact extends AbstractService
{
- public Batch $batch;
-
/**
* Contact constructor.
- *
- * @param Batch $batch
- * @param CoreInterface $core
- * @param LoggerInterface $log
*/
- public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $log)
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
- $this->batch = $batch;
+ parent::__construct($core, $logger);
}
/**
@@ -105,7 +98,6 @@ public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $
* REGISTER_SONET_EVENT?: string
* } $params
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -132,9 +124,7 @@ public function add(array $fields, array $params = ['REGISTER_SONET_EVENT' => 'N
*
* @link https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_delete.php
*
- * @param int $contactId
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -160,7 +150,6 @@ public function delete(int $contactId): DeletedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_fields.php
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -179,9 +168,7 @@ public function fields(): FieldsResult
*
* @link https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_get.php
*
- * @param int $contactId
*
- * @return ContactResult
* @throws BaseException
* @throws TransportException
*/
@@ -307,9 +294,7 @@ public function get(int $contactId): ContactResult
* IM?: string,
* } $filter
* @param array $select = ['ID','HONORIFIC','NAME','SECOND_NAME','LAST_NAME','PHOTO','BIRTHDATE','TYPE_ID','SOURCE_ID','SOURCE_DESCRIPTION','POST','ADDRESS','ADDRESS_2','ADDRESS_CITY','ADDRESS_POSTAL_CODE','ADDRESS_REGION','ADDRESS_PROVINCE','ADDRESS_COUNTRY','ADDRESS_COUNTRY_CODE','ADDRESS_LOC_ADDR_ID','COMMENTS','OPENED','EXPORT','HAS_PHONE','HAS_EMAIL','HAS_IMOL','ASSIGNED_BY_ID','CREATED_BY_ID','MODIFY_BY_ID','DATE_CREATE','DATE_MODIFY','COMPANY_ID','COMPANY_IDS','LEAD_ID','ORIGINATOR_ID','ORIGIN_ID','ORIGIN_VERSION','FACE_ID','UTM_SOURCE','UTM_MEDIUM','UTM_CAMPAIGN','UTM_CONTENT','UTM_TERM','PHONE','EMAIL','WEB','IM']
- * @param int $start
*
- * @return ContactsResult
* @throws BaseException
* @throws TransportException
*/
@@ -334,7 +319,6 @@ public function list(array $order, array $filter, array $select, int $start): Co
}
/**
- * @param int $contactId
* @param array{
* ID?: int,
* HONORIFIC?: string,
@@ -389,7 +373,6 @@ public function list(array $order, array $filter, array $select, int $start): Co
* REGISTER_SONET_EVENT?: string
* } $params
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -463,7 +446,6 @@ public function update(int $contactId, array $fields, array $params = []): Updat
* IM?: string,
* } $filter
*
- * @return int
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
diff --git a/src/Services/CRM/Contact/Service/ContactCompany.php b/src/Services/CRM/Contact/Service/ContactCompany.php
index 3eaeea19..3ffb2770 100644
--- a/src/Services/CRM/Contact/Service/ContactCompany.php
+++ b/src/Services/CRM/Contact/Service/ContactCompany.php
@@ -34,7 +34,6 @@ class ContactCompany extends AbstractService
*
* @link https://apidocs.bitrix24.com/api-reference/crm/contacts/company/crm-contact-company-fields.html
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -64,19 +63,20 @@ public function fields(): FieldsResult
public function setItems(int $contactId, array $companyConnections): UpdatedItemResult
{
$items = [];
- foreach ($companyConnections as $item) {
- if (!$item instanceof CompanyConnection) {
+ foreach ($companyConnections as $companyConnection) {
+ if (!$companyConnection instanceof CompanyConnection) {
throw new InvalidArgumentException(
- sprintf('array item «%s» must be «%s» type', gettype($item), CompanyConnection::class)
+ sprintf('array item «%s» must be «%s» type', gettype($companyConnection), CompanyConnection::class)
);
}
$items[] = [
- 'COMPANY_ID' => $item->companyId,
- 'SORT' => $item->sort,
- 'IS_PRIMARY' => $item->isPrimary ? 'Y' : 'N'
+ 'COMPANY_ID' => $companyConnection->companyId,
+ 'SORT' => $companyConnection->sort,
+ 'IS_PRIMARY' => $companyConnection->isPrimary ? 'Y' : 'N'
];
}
+
if ($items === []) {
throw new InvalidArgumentException('empty company connections array');
}
@@ -118,14 +118,14 @@ public function get(int $contactId): ContactCompanyConnectionResult
'https://apidocs.bitrix24.com/api-reference/crm/contacts/company/crm-contact-company-add.html',
'Add a Company to the Specified Contact'
)]
- public function add(int $contactId, CompanyConnection $connection): UpdatedItemResult
+ public function add(int $contactId, CompanyConnection $companyConnection): UpdatedItemResult
{
return new UpdatedItemResult($this->core->call('crm.contact.company.add', [
'id' => $contactId,
'fields' => [
- 'COMPANY_ID' => $connection->companyId,
- 'SORT' => $connection->sort,
- 'IS_PRIMARY' => $connection->isPrimary ? 'Y' : 'N'
+ 'COMPANY_ID' => $companyConnection->companyId,
+ 'SORT' => $companyConnection->sort,
+ 'IS_PRIMARY' => $companyConnection->isPrimary ? 'Y' : 'N'
]
]));
}
diff --git a/src/Services/CRM/Contact/Service/ContactUserfield.php b/src/Services/CRM/Contact/Service/ContactUserfield.php
index ac1c51c3..bc4fd1d1 100644
--- a/src/Services/CRM/Contact/Service/ContactUserfield.php
+++ b/src/Services/CRM/Contact/Service/ContactUserfield.php
@@ -32,12 +32,9 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class ContactUserfield extends AbstractService
{
- private UserfieldConstraints $userfieldConstraints;
-
- public function __construct(UserfieldConstraints $userfieldConstraints, CoreInterface $core, LoggerInterface $log)
+ public function __construct(private readonly UserfieldConstraints $userfieldConstraints, CoreInterface $core, LoggerInterface $logger)
{
- $this->userfieldConstraints = $userfieldConstraints;
- parent::__construct($core, $log);
+ parent::__construct($core, $logger);
}
/**
@@ -84,7 +81,6 @@ public function __construct(UserfieldConstraints $userfieldConstraints, CoreInte
* SETTINGS?: string,
* } $filter
*
- * @return ContactUserfieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -133,7 +129,6 @@ public function list(array $order, array $filter): ContactUserfieldsResult
* SETTINGS?: string,
* } $userfieldItemFields
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
* @throws UserfieldNameIsTooLongException
@@ -162,9 +157,7 @@ public function add(array $userfieldItemFields): AddedItemResult
/**
* Deleted user field for contacts.
*
- * @param int $userfieldId
*
- * @return \Bitrix24\SDK\Core\Result\DeletedItemResult
* @throws BaseException
* @throws TransportException
* @link https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_userfield_delete.php
@@ -190,9 +183,7 @@ public function delete(int $userfieldId): DeletedItemResult
/**
* Returns a user field for contacts by ID.
*
- * @param int $contactUserfieldItemId
*
- * @return ContactUserfieldResult
* @throws BaseException
* @throws TransportException
* @link https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_userfield_get.php
@@ -217,10 +208,7 @@ public function get(int $contactUserfieldItemId): ContactUserfieldResult
/**
* Updates an existing user field for contacts.
*
- * @param int $contactUserfieldItemId
- * @param array $userfieldFieldsToUpdate
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
* @link https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_userfield_update.php
diff --git a/src/Services/CRM/Deal/Result/DealCategoryStatusResult.php b/src/Services/CRM/Deal/Result/DealCategoryStatusResult.php
index 0f9166f5..a1b597d3 100644
--- a/src/Services/CRM/Deal/Result/DealCategoryStatusResult.php
+++ b/src/Services/CRM/Deal/Result/DealCategoryStatusResult.php
@@ -25,7 +25,6 @@
class DealCategoryStatusResult extends AbstractResult
{
/**
- * @return string
* @throws BaseException
*/
public function getDealCategoryTypeId(): string
diff --git a/src/Services/CRM/Deal/Result/DealItemResult.php b/src/Services/CRM/Deal/Result/DealItemResult.php
index c0cf41ce..577f0d00 100644
--- a/src/Services/CRM/Deal/Result/DealItemResult.php
+++ b/src/Services/CRM/Deal/Result/DealItemResult.php
@@ -68,7 +68,6 @@
class DealItemResult extends AbstractCrmItem
{
/**
- * @param string $userfieldName
*
* @return mixed|null
* @throws \Bitrix24\SDK\Services\CRM\Userfield\Exceptions\UserfieldNotFoundException
diff --git a/src/Services/CRM/Deal/Result/DealProductRowItemsResult.php b/src/Services/CRM/Deal/Result/DealProductRowItemsResult.php
index f0b1a69f..ed78dc27 100644
--- a/src/Services/CRM/Deal/Result/DealProductRowItemsResult.php
+++ b/src/Services/CRM/Deal/Result/DealProductRowItemsResult.php
@@ -26,12 +26,9 @@
*/
class DealProductRowItemsResult extends AbstractResult
{
- private Currency $currency;
-
- public function __construct(Response $coreResponse,Currency $currency)
+ public function __construct(Response $coreResponse,private readonly Currency $currency)
{
parent::__construct($coreResponse);
- $this->currency = $currency;
}
/**
diff --git a/src/Services/CRM/Deal/Service/Batch.php b/src/Services/CRM/Deal/Service/Batch.php
index 62bc9134..391807ea 100644
--- a/src/Services/CRM/Deal/Service/Batch.php
+++ b/src/Services/CRM/Deal/Service/Batch.php
@@ -28,19 +28,11 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class Batch
{
- protected BatchOperationsInterface $batch;
- protected LoggerInterface $log;
-
/**
* Batch constructor.
- *
- * @param BatchOperationsInterface $batch
- * @param LoggerInterface $log
*/
- public function __construct(BatchOperationsInterface $batch, LoggerInterface $log)
+ public function __construct(protected BatchOperationsInterface $batch, protected LoggerInterface $log)
{
- $this->batch = $batch;
- $this->log = $log;
}
/**
@@ -134,7 +126,6 @@ public function __construct(BatchOperationsInterface $batch, LoggerInterface $lo
* UTM_TERM?: string,
* } $filter
* @param array $select = ['ID','TITLE','TYPE_ID','CATEGORY_ID','STAGE_ID','STAGE_SEMANTIC_ID','IS_NEW','IS_RECURRING','IS_RETURN_CUSTOMER','IS_REPEATED_APPROACH','PROBABILITY','CURRENCY_ID','OPPORTUNITY','IS_MANUAL_OPPORTUNITY','TAX_VALUE','COMPANY_ID','CONTACT_ID','CONTACT_IDS','QUOTE_ID','BEGINDATE','CLOSEDATE','OPENED','CLOSED','COMMENTS','ASSIGNED_BY_ID','CREATED_BY_ID','MODIFY_BY_ID','DATE_CREATE','DATE_MODIFY','SOURCE_ID','SOURCE_DESCRIPTION','LEAD_ID','ADDITIONAL_INFO','LOCATION_ID','ORIGINATOR_ID','ORIGIN_ID','UTM_SOURCE','UTM_MEDIUM','UTM_CAMPAIGN','UTM_CONTENT','UTM_TERM']
- * @param int|null $limit
*
* @return Generator|DealItemResult[]
* @throws BaseException
@@ -218,11 +209,12 @@ public function list(array $order, array $filter, array $select, ?int $limit = n
public function add(array $deals): Generator
{
$items = [];
- foreach ($deals as $contact) {
+ foreach ($deals as $deal) {
$items[] = [
- 'fields' => $contact,
+ 'fields' => $deal,
];
}
+
foreach ($this->batch->addEntityItems('crm.deal.add', $items) as $key => $item) {
yield $key => new AddedItemBatchResult($item);
}
diff --git a/src/Services/CRM/Deal/Service/Deal.php b/src/Services/CRM/Deal/Service/Deal.php
index 0f602bab..0ac81c8e 100644
--- a/src/Services/CRM/Deal/Service/Deal.php
+++ b/src/Services/CRM/Deal/Service/Deal.php
@@ -31,19 +31,12 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class Deal extends AbstractService
{
- public Batch $batch;
-
/**
* Deal constructor.
- *
- * @param Batch $batch
- * @param CoreInterface $core
- * @param LoggerInterface $log
*/
- public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $log)
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
- $this->batch = $batch;
+ parent::__construct($core, $logger);
}
/**
@@ -93,7 +86,6 @@ public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $
* REGISTER_SONET_EVENT?: string
* } $params
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -120,9 +112,7 @@ public function add(array $fields, array $params = []): AddedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_delete.php
*
- * @param int $id
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -148,7 +138,6 @@ public function delete(int $id): DeletedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_fields.php
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -167,9 +156,7 @@ public function fields(): FieldsResult
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_get.php
*
- * @param int $id
*
- * @return DealResult
* @throws BaseException
* @throws TransportException
*/
@@ -195,7 +182,6 @@ public function get(int $id): DealResult
*
* @throws BaseException
* @throws TransportException
- * @return DealsResult
*/
#[ApiEndpointMetadata(
'crm.deal.list',
@@ -222,7 +208,6 @@ public function list(array $order, array $filter, array $select, int $startItem
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_update.php
*
- * @param int $id
* @param array{
* ID?: int,
* TITLE?: string,
@@ -265,7 +250,6 @@ public function list(array $order, array $filter, array $select, int $startItem
* REGISTER_SONET_EVENT?: string
* } $params
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -329,7 +313,6 @@ public function update(int $id, array $fields, array $params = []): UpdatedItemR
* UTM_TERM?: string
* } $filter
*
- * @return int
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Deal/Service/DealCategory.php b/src/Services/CRM/Deal/Service/DealCategory.php
index da8908ae..7a1584aa 100644
--- a/src/Services/CRM/Deal/Service/DealCategory.php
+++ b/src/Services/CRM/Deal/Service/DealCategory.php
@@ -43,7 +43,6 @@ class DealCategory extends AbstractService
* SORT?: int,
* } $fields
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -69,9 +68,7 @@ public function add(array $fields): AddedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/category/crm_dealcategory_delete.php
*
- * @param int $categoryId
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -97,7 +94,6 @@ public function delete(int $categoryId): DeletedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/category/crm_dealcategory_fields.php
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -115,7 +111,6 @@ public function fields(): FieldsResult
* The method reads settings for general deal category
*
* @link https://training.bitrix24.com/rest_help/crm/category/crm_dealcategory_default_get.php
- * @return DealCategoryResult
* @throws BaseException
* @throws TransportException
*/
@@ -138,7 +133,6 @@ public function getDefaultCategorySettings(): DealCategoryResult
* NAME?: string,
* } $parameters
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -158,9 +152,7 @@ public function setDefaultCategorySettings(array $parameters): UpdatedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/category/crm_dealcategory_get.php
*
- * @param int $categoryId
*
- * @return DealCategoryResult
* @throws BaseException
* @throws TransportException
*/
@@ -186,12 +178,7 @@ public function get(int $categoryId): DealCategoryResult
*
* @link https://training.bitrix24.com/rest_help/crm/category/crm_dealcategory_list.php
*
- * @param array $order
- * @param array $filter
- * @param array $select
- * @param int $start
*
- * @return DealCategoriesResult
* @throws BaseException
* @throws TransportException
*/
@@ -220,9 +207,7 @@ public function list(array $order, array $filter, array $select, int $start): De
*
* @link https://training.bitrix24.com/rest_help/crm/category/crm_dealcategory_status.php
*
- * @param int $categoryId
*
- * @return DealCategoryStatusResult
* @throws BaseException
* @throws TransportException
*/
@@ -248,7 +233,6 @@ public function getStatus(int $categoryId): DealCategoryStatusResult
*
* @link https://training.bitrix24.com/rest_help/crm/category/crm_dealcategory_update.php
*
- * @param int $categoryId
* @param array{
* ID?: int,
* CREATED_DATE?: string,
@@ -257,7 +241,6 @@ public function getStatus(int $categoryId): DealCategoryStatusResult
* SORT?: int,
* } $fields
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Deal/Service/DealContact.php b/src/Services/CRM/Deal/Service/DealContact.php
index 0e5eb038..35e56dbf 100644
--- a/src/Services/CRM/Deal/Service/DealContact.php
+++ b/src/Services/CRM/Deal/Service/DealContact.php
@@ -33,10 +33,6 @@ class DealContact extends AbstractService
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_contact_add.php
*
- * @param int $dealId
- * @param int $contactId
- * @param bool $isPrimary
- * @param int $sort
*
* @throws BaseException
* @throws TransportException
@@ -85,9 +81,7 @@ public function fields(): FieldsResult
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_contact_items_get.php
*
- * @param int $dealId
*
- * @return DealContactItemsResult
* @throws BaseException
* @throws TransportException
*/
@@ -113,9 +107,7 @@ public function itemsGet(int $dealId): DealContactItemsResult
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_contact_items_delete.php
*
- * @param int $dealId
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -141,14 +133,12 @@ public function itemsDelete(int $dealId): DeletedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_contact_items_set.php
*
- * @param int $dealId
* @param array $contactItems
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -175,10 +165,7 @@ public function itemsSet(int $dealId, array $contactItems): UpdatedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_contact_delete.php
*
- * @param int $dealId
- * @param int $contactId
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Deal/Service/DealProductRows.php b/src/Services/CRM/Deal/Service/DealProductRows.php
index ec6bf9ce..66b4ceb6 100644
--- a/src/Services/CRM/Deal/Service/DealProductRows.php
+++ b/src/Services/CRM/Deal/Service/DealProductRows.php
@@ -32,7 +32,6 @@ class DealProductRows extends AbstractService
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_productrows_get.php
*
- * @param int $dealId
* @param Currency|null $currency
* @throws BaseException
* @throws TransportException
@@ -44,7 +43,7 @@ class DealProductRows extends AbstractService
)]
public function get(int $dealId, Currency $currency = null): DealProductRowItemsResult
{
- if ($currency === null) {
+ if (!$currency instanceof \Money\Currency) {
$res = $this->core->call('batch', [
'halt' => 0,
'cmd' => [
@@ -56,6 +55,7 @@ public function get(int $dealId, Currency $currency = null): DealProductRowItems
$currency = new Currency($data['result']['deal']['CURRENCY_ID']);
return new DealProductRowItemsResult($res,$currency);
}
+
return new DealProductRowItemsResult(
$this->core->call(
'crm.deal.productrows.get',
@@ -73,7 +73,6 @@ public function get(int $dealId, Currency $currency = null): DealProductRowItems
*
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_productrows_set.php
*
- * @param int $dealId
* @param array $productRows
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Deal/Service/DealUserfield.php b/src/Services/CRM/Deal/Service/DealUserfield.php
index c59d42fc..01c95e90 100644
--- a/src/Services/CRM/Deal/Service/DealUserfield.php
+++ b/src/Services/CRM/Deal/Service/DealUserfield.php
@@ -32,13 +32,11 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class DealUserfield extends AbstractService
{
- private UserfieldConstraints $userfieldConstraints;
-
- public function __construct(UserfieldConstraints $userfieldConstraints, CoreInterface $core, LoggerInterface $log)
+ public function __construct(private readonly UserfieldConstraints $userfieldConstraints, CoreInterface $core, LoggerInterface $logger)
{
- $this->userfieldConstraints = $userfieldConstraints;
- parent::__construct($core, $log);
+ parent::__construct($core, $logger);
}
+
/**
* Returns list of user deal fields by filter.
*
@@ -85,7 +83,6 @@ public function __construct(UserfieldConstraints $userfieldConstraints, CoreInte
* SETTINGS?: string,
* } $filter
*
- * @return \Bitrix24\SDK\Services\CRM\Deal\Result\DealUserfieldsResult
* @throws BaseException
* @throws TransportException
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_userfield_list.php
@@ -135,7 +132,6 @@ public function list(array $order, array $filter): DealUserfieldsResult
* SETTINGS?: string,
* } $userfieldItemFields
*
- * @return \Bitrix24\SDK\Core\Result\AddedItemResult
* @throws BaseException
* @throws TransportException
* @throws UserfieldNameIsTooLongException
@@ -164,9 +160,7 @@ public function add(array $userfieldItemFields): AddedItemResult
/**
* Deleted userfield for deals
*
- * @param int $userfieldId
*
- * @return \Bitrix24\SDK\Core\Result\DeletedItemResult
* @throws BaseException
* @throws TransportException
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_userfield_delete.php
@@ -192,9 +186,7 @@ public function delete(int $userfieldId): DeletedItemResult
/**
* Returns a userfield for deal by ID.
*
- * @param int $userfieldItemId
*
- * @return DealUserfieldResult
* @throws BaseException
* @throws TransportException
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_userfield_get.php
@@ -219,10 +211,7 @@ public function get(int $userfieldItemId): DealUserfieldResult
/**
* Updates an existing user field for deals.
*
- * @param int $userfieldItemId
- * @param array $userfieldFieldsToUpdate
*
- * @return \Bitrix24\SDK\Core\Result\UpdatedItemResult
* @throws BaseException
* @throws TransportException
* @link https://training.bitrix24.com/rest_help/crm/deals/crm_deal_userfield_update.php
diff --git a/src/Services/CRM/Duplicates/Result/DuplicateResult.php b/src/Services/CRM/Duplicates/Result/DuplicateResult.php
index 3683f454..801f4570 100644
--- a/src/Services/CRM/Duplicates/Result/DuplicateResult.php
+++ b/src/Services/CRM/Duplicates/Result/DuplicateResult.php
@@ -24,11 +24,7 @@ public function hasDuplicateContacts(): bool
return false;
}
- if (count($this->getCoreResponse()->getResponseData()->getResult()['CONTACT']) > 1) {
- return true;
- }
-
- return false;
+ return count($this->getCoreResponse()->getResponseData()->getResult()['CONTACT']) > 1;
}
public function hasOneContact(): bool
@@ -37,11 +33,7 @@ public function hasOneContact(): bool
return false;
}
- if (count($this->getCoreResponse()->getResponseData()->getResult()['CONTACT']) === 1) {
- return true;
- }
-
- return false;
+ return count($this->getCoreResponse()->getResponseData()->getResult()['CONTACT']) === 1;
}
/**
diff --git a/src/Services/CRM/Duplicates/Service/Duplicate.php b/src/Services/CRM/Duplicates/Service/Duplicate.php
index aaf4ea87..c20b6a2c 100644
--- a/src/Services/CRM/Duplicates/Service/Duplicate.php
+++ b/src/Services/CRM/Duplicates/Service/Duplicate.php
@@ -26,7 +26,6 @@ class Duplicate extends AbstractService
{
/**
* @param array $phones
- * @param EntityType|null $entityType
* @return DuplicateResult
* @throws BaseException
* @throws TransportException
@@ -48,8 +47,6 @@ public function findByPhone(array $phones, ?EntityType $entityType = null): mixe
/**
* @param array $emails
- * @param EntityType|null $entityType
- * @return DuplicateResult
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Item/Service/Batch.php b/src/Services/CRM/Item/Service/Batch.php
index 546765ab..99ca0ef2 100644
--- a/src/Services/CRM/Item/Service/Batch.php
+++ b/src/Services/CRM/Item/Service/Batch.php
@@ -26,13 +26,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class Batch
{
- protected BatchOperationsInterface $batch;
- protected LoggerInterface $log;
-
- public function __construct(BatchOperationsInterface $batch, LoggerInterface $log)
+ public function __construct(protected BatchOperationsInterface $batch, protected LoggerInterface $log)
{
- $this->batch = $batch;
- $this->log = $log;
}
/**
@@ -83,6 +78,7 @@ public function add(int $entityTypeId, array $items): Generator
'fields' => $item,
];
}
+
foreach ($this->batch->addEntityItems('crm.item.add', $rawItems) as $key => $item) {
yield $key => new ItemItemResult($item->getResult()['item']);
}
diff --git a/src/Services/CRM/Item/Service/Item.php b/src/Services/CRM/Item/Service/Item.php
index 5425be81..073283ed 100644
--- a/src/Services/CRM/Item/Service/Item.php
+++ b/src/Services/CRM/Item/Service/Item.php
@@ -30,12 +30,9 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class Item extends AbstractService
{
- public Batch $batch;
-
- public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $log)
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
- $this->batch = $batch;
+ parent::__construct($core, $logger);
}
/**
@@ -44,9 +41,6 @@ public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $
* @link https://training.bitrix24.com/rest_help/crm/dynamic/methodscrmitem/crm_item_add.php
*
*
- * @param int $entityTypeId
- * @param array $fields
- * @return ItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -73,10 +67,7 @@ public function add(int $entityTypeId, array $fields): ItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/dynamic/methodscrmitem/crm_item_delete.php
*
- * @param int $entityTypeId
- * @param int $id
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -99,8 +90,6 @@ public function delete(int $entityTypeId, int $id): DeletedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/dynamic/methodscrmitem/crm_item_fields.php
*
- * @param int $entityTypeId
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Lead/Result/LeadItemResult.php b/src/Services/CRM/Lead/Result/LeadItemResult.php
index a6afa868..c762ce50 100644
--- a/src/Services/CRM/Lead/Result/LeadItemResult.php
+++ b/src/Services/CRM/Lead/Result/LeadItemResult.php
@@ -86,7 +86,6 @@
class LeadItemResult extends AbstractCrmItem
{
/**
- * @param string $userfieldName
*
* @return mixed|null
* @throws \Bitrix24\SDK\Services\CRM\Userfield\Exceptions\UserfieldNotFoundException
diff --git a/src/Services/CRM/Lead/Service/Batch.php b/src/Services/CRM/Lead/Service/Batch.php
index 7b6e546c..c2810193 100644
--- a/src/Services/CRM/Lead/Service/Batch.php
+++ b/src/Services/CRM/Lead/Service/Batch.php
@@ -27,19 +27,11 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class Batch
{
- protected BatchOperationsInterface $batch;
- protected LoggerInterface $log;
-
/**
* Batch constructor.
- *
- * @param BatchOperationsInterface $batch
- * @param LoggerInterface $log
*/
- public function __construct(BatchOperationsInterface $batch, LoggerInterface $log)
+ public function __construct(protected BatchOperationsInterface $batch, protected LoggerInterface $log)
{
- $this->batch = $batch;
- $this->log = $log;
}
/**
@@ -133,7 +125,6 @@ public function __construct(BatchOperationsInterface $batch, LoggerInterface $lo
* UTM_TERM?: string,
* } $filter
* @param array $select = ['ID','TITLE','TYPE_ID','CATEGORY_ID','STAGE_ID','STAGE_SEMANTIC_ID','IS_NEW','IS_RECURRING','IS_RETURN_CUSTOMER','IS_REPEATED_APPROACH','PROBABILITY','CURRENCY_ID','OPPORTUNITY','IS_MANUAL_OPPORTUNITY','TAX_VALUE','COMPANY_ID','CONTACT_ID','CONTACT_IDS','QUOTE_ID','BEGINDATE','CLOSEDATE','OPENED','CLOSED','COMMENTS','ASSIGNED_BY_ID','CREATED_BY_ID','MODIFY_BY_ID','DATE_CREATE','DATE_MODIFY','SOURCE_ID','SOURCE_DESCRIPTION','LEAD_ID','ADDITIONAL_INFO','LOCATION_ID','ORIGINATOR_ID','ORIGIN_ID','UTM_SOURCE','UTM_MEDIUM','UTM_CAMPAIGN','UTM_CONTENT','UTM_TERM']
- * @param int|null $limit
*
* @return Generator
* @throws BaseException
@@ -222,6 +213,7 @@ public function add(array $leads): Generator
'fields' => $lead,
];
}
+
foreach ($this->batch->addEntityItems('crm.lead.add', $items) as $key => $item) {
yield $key => new AddedItemBatchResult($item);
}
diff --git a/src/Services/CRM/Lead/Service/Lead.php b/src/Services/CRM/Lead/Service/Lead.php
index 02d9716c..35fae039 100644
--- a/src/Services/CRM/Lead/Service/Lead.php
+++ b/src/Services/CRM/Lead/Service/Lead.php
@@ -30,19 +30,12 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class Lead extends AbstractService
{
- public Batch $batch;
-
/**
* Lead constructor.
- *
- * @param Batch $batch
- * @param CoreInterface $core
- * @param LoggerInterface $log
*/
- public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $log)
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
- $this->batch = $batch;
+ parent::__construct($core, $logger);
}
/**
@@ -112,7 +105,6 @@ public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $
* REGISTER_SONET_EVENT?: string
* } $params
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -139,9 +131,7 @@ public function add(array $fields, array $params = []): AddedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/leads/crm_lead_delete.php
*
- * @param int $id
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -167,7 +157,6 @@ public function delete(int $id): DeletedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/leads/crm_lead_fields.php
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -186,9 +175,7 @@ public function fields(): FieldsResult
*
* @link https://training.bitrix24.com/rest_help/crm/leads/crm_lead_get.php
*
- * @param int $id
*
- * @return LeadResult
* @throws BaseException
* @throws TransportException
*/
@@ -214,7 +201,6 @@ public function get(int $id): LeadResult
*
* @throws BaseException
* @throws TransportException
- * @return LeadsResult
*/
#[ApiEndpointMetadata(
'crm.lead.list',
@@ -241,7 +227,6 @@ public function list(array $order, array $filter, array $select, int $startItem
*
* @link https://training.bitrix24.com/rest_help/crm/leads/crm_lead_update.php
*
- * @param int $id
* @param array{
* ID?: int,
* TITLE?: string,
@@ -304,7 +289,6 @@ public function list(array $order, array $filter, array $select, int $startItem
* REGISTER_SONET_EVENT?: string
* } $params
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -388,7 +372,6 @@ public function update(int $id, array $fields, array $params = []): UpdatedItemR
* LINK?: string
* } $filter
*
- * @return int
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
diff --git a/src/Services/CRM/Product/Service/Batch.php b/src/Services/CRM/Product/Service/Batch.php
index c4f7ac88..75a9402d 100644
--- a/src/Services/CRM/Product/Service/Batch.php
+++ b/src/Services/CRM/Product/Service/Batch.php
@@ -36,7 +36,6 @@ class Batch extends AbstractBatchService
* ID?: int
* } $filter
* @param array $select = ['ID','CATALOG_ID','PRICE','CURRENCY_ID','NAME','CODE','DESCRIPTION','DESCRIPTION_TYPE','ACTIVE','SECTION_ID','SORT','VAT_ID','VAT_INCLUDED','MEASURE','XML_ID','PREVIEW_PICTURE','DETAIL_PICTURE','DATE_CREATE','TIMESTAMP_X','MODIFIED_BY','CREATED_BY']
- * @param int|null $limit
*
* @return Generator
* @throws BaseException
@@ -104,6 +103,7 @@ public function add(array $products): Generator
'fields' => $product,
];
}
+
foreach ($this->batch->addEntityItems('crm.product.add', $items) as $key => $item) {
yield $key => new AddedItemBatchResult($item);
}
diff --git a/src/Services/CRM/Product/Service/Product.php b/src/Services/CRM/Product/Service/Product.php
index bf027036..8528403c 100644
--- a/src/Services/CRM/Product/Service/Product.php
+++ b/src/Services/CRM/Product/Service/Product.php
@@ -31,19 +31,12 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class Product extends AbstractService
{
- public Batch $batch;
-
/**
* Product constructor.
- *
- * @param Batch $batch
- * @param CoreInterface $core
- * @param LoggerInterface $log
*/
- public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $log)
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
- $this->batch = $batch;
+ parent::__construct($core, $logger);
}
/**
@@ -75,7 +68,6 @@ public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $
* CREATED_BY?: int
* } $fields
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -101,9 +93,7 @@ public function add(array $fields): AddedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/products/crm_product_delete.php
*
- * @param int $productId
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -129,9 +119,7 @@ public function delete(int $productId): DeletedItemResult
*
* @link https://training.bitrix24.com/rest_help/crm/products/crm_product_get.php
*
- * @param int $id
*
- * @return ProductResult
* @throws BaseException
* @throws TransportException
*/
@@ -150,7 +138,6 @@ public function get(int $id): ProductResult
*
* @link https://training.bitrix24.com/rest_help/crm/products/crm_product_fields.php
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -174,7 +161,6 @@ public function fields(): FieldsResult
* @param array $select = ['ID','CATALOG_ID','PRICE','CURRENCY_ID','NAME','CODE','DESCRIPTION','DESCRIPTION_TYPE','ACTIVE','SECTION_ID','SORT','VAT_ID','VAT_INCLUDED','MEASURE','XML_ID','PREVIEW_PICTURE','DETAIL_PICTURE','DATE_CREATE','TIMESTAMP_X','MODIFIED_BY','CREATED_BY']
* @param int $startItem - entity number to start from (usually returned in 'next' field of previous 'crm.product.list' API call)
*
- * @return ProductsResult
* @throws BaseException
* @throws TransportException
*/
@@ -203,7 +189,6 @@ public function list(array $order, array $filter, array $select, int $startItem
*
* @link https://training.bitrix24.com/rest_help/crm/products/crm_product_update.php
*
- * @param int $id
* @param array{
* ID?: int,
* CATALOG_ID?: int,
@@ -228,7 +213,6 @@ public function list(array $order, array $filter, array $select, int $startItem
* CREATED_BY?: int
* } $fields
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -277,7 +261,6 @@ public function update(int $id, array $fields): UpdatedItemResult
* CREATED_BY?: int
* } $filter
*
- * @return int
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Requisites/Service/Batch.php b/src/Services/CRM/Requisites/Service/Batch.php
index 78954e60..cbbb1190 100644
--- a/src/Services/CRM/Requisites/Service/Batch.php
+++ b/src/Services/CRM/Requisites/Service/Batch.php
@@ -26,12 +26,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class Batch
{
- protected BatchOperationsInterface $batch;
- protected LoggerInterface $log;
- public function __construct(BatchOperationsInterface $batch, LoggerInterface $log)
+ public function __construct(protected BatchOperationsInterface $batch, protected LoggerInterface $log)
{
- $this->batch = $batch;
- $this->log = $log;
}
/**
diff --git a/src/Services/CRM/Requisites/Service/Requisite.php b/src/Services/CRM/Requisites/Service/Requisite.php
index c446a35f..4ede750b 100644
--- a/src/Services/CRM/Requisites/Service/Requisite.php
+++ b/src/Services/CRM/Requisites/Service/Requisite.php
@@ -33,12 +33,9 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class Requisite extends AbstractService
{
- public Batch $batch;
-
- public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $log)
+ public function __construct(public Batch $batch, CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
- $this->batch = $batch;
+ parent::__construct($core, $logger);
}
/**
@@ -46,7 +43,6 @@ public function __construct(Batch $batch, CoreInterface $core, LoggerInterface $
*
* @link https://training.bitrix24.com/rest_help/crm/requisite/crm_requisite_fields.php
*
- * @return FieldsResult
* @throws BaseException
* @throws TransportException
*/
@@ -146,7 +142,6 @@ public function fields(): FieldsResult
* @param array $select = ['ID','ENTITY_TYPE_ID','ENTITY_ID','PRESET_ID','DATE_CREATE','DATE_MODIFY','CREATED_BY_ID','MODIFY_BY_ID','NAME','CODE','XML_ID','ORIGINATOR_ID','ACTIVE','ADDRESS_ONLY','SORT','RQ_NAME','RQ_FIRST_NAME','RQ_LAST_NAME','RQ_SECOND_NAME','RQ_COMPANY_ID','RQ_COMPANY_NAME','RQ_COMPANY_FULL_NAME','RQ_COMPANY_REG_DATE','RQ_DIRECTOR','RQ_ACCOUNTANT','RQ_CEO_NAME','RQ_CEO_WORK_POS','RQ_CONTACT','RQ_EMAIL','RQ_PHONE','RQ_FAX','RQ_IDENT_TYPE','RQ_IDENT_DOC','RQ_IDENT_DOC_SER','RQ_IDENT_DOC_NUM','RQ_IDENT_DOC_PERS_NUM','RQ_IDENT_DOC_DATE','RQ_IDENT_DOC_ISSUED_BY','RQ_IDENT_DOC_DEP_CODE','RQ_INN','RQ_KPP','RQ_USRLE','RQ_IFNS','RQ_OGRN','RQ_OGRNIP','RQ_OKPO','RQ_OKTMO','RQ_OKVED','RQ_EDRPOU','RQ_DRFO','RQ_KBE','RQ_IIN','RQ_BIN','RQ_ST_CERT_SER','RQ_ST_CERT_NUM','RQ_ST_CERT_DATE','RQ_VAT_PAYER','RQ_VAT_ID','RQ_VAT_CERT_SER','RQ_VAT_CERT_NUM','RQ_VAT_CERT_DATE','RQ_RESIDENCE_COUNTRY','RQ_BASE_DOC','RQ_REGON','RQ_KRS','RQ_PESEL','RQ_LEGAL_FORM','RQ_SIRET','RQ_SIREN','RQ_CAPITAL','RQ_RCS','RQ_CNPJ','RQ_STATE_REG','RQ_MNPL_REG','RQ_CPF']
* @param integer $startItem - entity number to start from (usually returned in 'next' field of previous 'crm.requisite.list' API call)
*
- * @return RequisitesResult
* @throws BaseException
* @throws TransportException
*/
@@ -232,7 +227,6 @@ public function list(array $order, array $filter, array $select, int $startItem
* IM?: string,
* LINK?: string
* } $fields
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -291,7 +285,6 @@ public function get(int $id): RequisiteResult
*
* @param non-negative-int $id
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -318,7 +311,6 @@ public function delete(int $id): DeletedItemResult
*
* @link https://apidocs.bitrix24.com/api-reference/crm/requisites/universal/crm-requisite-update.html
*
- * @param int $id
* @param array{
* ID?: int,
* TITLE?: string,
@@ -377,7 +369,6 @@ public function delete(int $id): DeletedItemResult
* LINK?: string
* } $fields
*
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Requisites/Service/RequisitePreset.php b/src/Services/CRM/Requisites/Service/RequisitePreset.php
index b8407271..e43bf05b 100644
--- a/src/Services/CRM/Requisites/Service/RequisitePreset.php
+++ b/src/Services/CRM/Requisites/Service/RequisitePreset.php
@@ -35,9 +35,9 @@
#[ApiServiceMetadata(new Scope(['crm']))]
class RequisitePreset extends AbstractService
{
- public function __construct(CoreInterface $core, LoggerInterface $log)
+ public function __construct(CoreInterface $core, LoggerInterface $logger)
{
- parent::__construct($core, $log);
+ parent::__construct($core, $logger);
}
/**
@@ -112,7 +112,6 @@ public function list(
*
* @link https://apidocs.bitrix24.com/api-reference/crm/requisites/presets/crm-requisite-preset-add.html
*
- * @return AddedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -149,7 +148,6 @@ public function add(
*
* @link https://apidocs.bitrix24.com/api-reference/crm/requisites/presets/crm-requisite-preset-countries.html
*
- * @return CountriesResult
* @throws BaseException
* @throws TransportException
*/
@@ -168,9 +166,7 @@ public function countries(): CountriesResult
*
* @link https://apidocs.bitrix24.com/api-reference/crm/requisites/presets/crm-requisite-preset-delete.html
*
- * @param int $id
*
- * @return DeletedItemResult
* @throws BaseException
* @throws TransportException
*/
@@ -196,7 +192,6 @@ public function delete(int $id): DeletedItemResult
*
* @link https://apidocs.bitrix24.com/api-reference/crm/requisites/presets/crm-requisite-preset-get.html
*
- * @param int $id
*
* @throws BaseException
* @throws TransportException
@@ -216,7 +211,6 @@ public function get(int $id): RequisitePresetResult
*
* @link https://apidocs.bitrix24.com/api-reference/crm/requisites/presets/crm-requisite-preset-update.html
*
- * @param int $id
* @param array{
* ID?: int,
* ENTITY_TYPE_ID?: int,
@@ -230,7 +224,6 @@ public function get(int $id): RequisitePresetResult
* SORT?: int,
* XML_ID?: string,
* } $fields
- * @return UpdatedItemResult
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Settings/Service/Settings.php b/src/Services/CRM/Settings/Service/Settings.php
index a99a7e1d..b17c1d6f 100644
--- a/src/Services/CRM/Settings/Service/Settings.php
+++ b/src/Services/CRM/Settings/Service/Settings.php
@@ -25,7 +25,6 @@
class Settings extends AbstractService
{
/**
- * @return SettingsModeResult
* @throws BaseException
* @throws TransportException
*/
diff --git a/src/Services/CRM/Userfield/Result/AbstractUserfieldItemResult.php b/src/Services/CRM/Userfield/Result/AbstractUserfieldItemResult.php
index 97cef6b2..1c0ca2a0 100644
--- a/src/Services/CRM/Userfield/Result/AbstractUserfieldItemResult.php
+++ b/src/Services/CRM/Userfield/Result/AbstractUserfieldItemResult.php
@@ -43,8 +43,6 @@ class AbstractUserfieldItemResult extends AbstractCrmItem
/**
* get userfield name without prefix UF_CRM_
- *
- * @return string
*/
public function getOriginalFieldName(): string
{
diff --git a/src/Services/CRM/Userfield/Service/Userfield.php b/src/Services/CRM/Userfield/Service/Userfield.php
index e855723b..488cba67 100644
--- a/src/Services/CRM/Userfield/Service/Userfield.php
+++ b/src/Services/CRM/Userfield/Service/Userfield.php
@@ -29,7 +29,6 @@ class Userfield extends AbstractService
* Returns list of user field types.
*
* @link https://training.bitrix24.com/rest_help/crm/userfields/crm_userfield_types.php
- * @return UserfieldTypesResult
* @throws BaseException
* @throws TransportException
*/
@@ -47,7 +46,6 @@ public function types(): UserfieldTypesResult
* Returns field description for user fields.
*
* @link https://training.bitrix24.com/rest_help/crm/userfields/crm_userfield_fields.php
- * @return \Bitrix24\SDK\Core\Result\FieldsResult
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
@@ -65,7 +63,6 @@ public function fields(): FieldsResult
* Returns field description for "enumeration" user field type (list).
*
* @link https://training.bitrix24.com/rest_help/crm/userfields/crm_userfield_enumeration_fields.php
- * @return \Bitrix24\SDK\Core\Result\FieldsResult
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
@@ -84,9 +81,7 @@ public function enumerationFields(): FieldsResult
*
* @link https://training.bitrix24.com/rest_help/crm/userfields/crm_userfield_settings_fields.php
*
- * @param string $userfieldTypeId
*
- * @return \Bitrix24\SDK\Core\Result\FieldsResult
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
diff --git a/src/Services/CRM/Userfield/Service/UserfieldConstraints.php b/src/Services/CRM/Userfield/Service/UserfieldConstraints.php
index cfe254fd..f013a3c0 100644
--- a/src/Services/CRM/Userfield/Service/UserfieldConstraints.php
+++ b/src/Services/CRM/Userfield/Service/UserfieldConstraints.php
@@ -28,14 +28,13 @@
{
/**
* @param non-empty-string $userfieldName
- * @return void
* @throws UserfieldNameIsTooLongException
* @throws InvalidArgumentException
*/
public function validName(string $userfieldName): void
{
$userfieldName = trim($userfieldName);
- if (empty($userfieldName)) {
+ if ($userfieldName === '' || $userfieldName === '0') {
throw new InvalidArgumentException('userfield name can not be empty');
}
diff --git a/src/Services/CRM/VatRates/Service/Vat.php b/src/Services/CRM/VatRates/Service/Vat.php
index 54745375..69c4366c 100644
--- a/src/Services/CRM/VatRates/Service/Vat.php
+++ b/src/Services/CRM/VatRates/Service/Vat.php
@@ -48,16 +48,16 @@ public function fields(): FieldsResult
'https://apidocs.bitrix24.com/api-reference/crm/auxiliary/vat/crm-vat-add.html',
'Add VAT Rate crm.vat.add'
)]
- public function add(string $name, Percentage $rate, int $sort = 100, bool $isActive = true): AddedItemResult
+ public function add(string $name, Percentage $percentage, int $sort = 100, bool $isActive = true): AddedItemResult
{
return new AddedItemResult(
$this->core->call('crm.vat.add', [
'fields' => [
'TIMESTAMP_X' => (new DateTime())->format(DATE_ATOM),
- 'ACTIVE' => $isActive === true ? 'Y' : 'N',
+ 'ACTIVE' => $isActive ? 'Y' : 'N',
'C_SORT' => $sort,
'NAME' => $name,
- 'RATE' => (string)$rate
+ 'RATE' => (string)$percentage
]
])
);
@@ -76,7 +76,7 @@ public function add(string $name, Percentage $rate, int $sort = 100, bool $isAct
public function update(
int $vatId,
?string $name = null,
- ?Percentage $rate = null,
+ ?Percentage $percentage = null,
?int $sort = null,
?bool $isActive = null
): UpdatedItemResult {
@@ -84,15 +84,19 @@ public function update(
if ($name !== null) {
$data['NAME'] = $name;
}
- if ($rate !== null) {
- $data['RATE'] = (string)$rate;
+
+ if ($percentage instanceof \MoneyPHP\Percentage\Percentage) {
+ $data['RATE'] = (string)$percentage;
}
+
if ($sort !== null) {
$data['SORT'] = $sort;
}
+
if ($isActive !== null) {
$data['ACTIVE'] = $isActive ? 'Y' : 'N';
}
+
if ($data === []) {
throw new InvalidArgumentException('you must set minimum one argument to update');
}
diff --git a/tests/CustomAssertions/AnnotationsParser.php b/tests/CustomAssertions/AnnotationsParser.php
new file mode 100644
index 00000000..1bec3ab8
--- /dev/null
+++ b/tests/CustomAssertions/AnnotationsParser.php
@@ -0,0 +1,33 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+namespace Bitrix24\SDK\Tests\CustomAssertions;
+
+use Typhoon\Reflection\TyphoonReflector;
+
+class AnnotationsParser
+{
+ public function parse(string $resultItemClassName): array {
+ // parse keys from phpdoc annotation
+ $props = TyphoonReflector::build()->reflectClass($resultItemClassName)->properties();
+ $propsFromAnnotations = [];
+ foreach ($props as $meta) {
+ if ($meta->isAnnotated() && !$meta->isNative()) {
+ $propsFromAnnotations[] = $meta->id->name;
+ }
+ }
+ sort($propsFromAnnotations);
+
+ return $propsFromAnnotations;
+ }
+}
\ No newline at end of file
diff --git a/tests/CustomAssertions/CustomBitrix24Assertions.php b/tests/CustomAssertions/CustomBitrix24Assertions.php
index fb588da5..895ba4bd 100644
--- a/tests/CustomAssertions/CustomBitrix24Assertions.php
+++ b/tests/CustomAssertions/CustomBitrix24Assertions.php
@@ -231,7 +231,8 @@ protected function assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
if (str_contains($fieldCode, '_IDS') ||
str_contains($fieldCode, 'PHOTO') ||
str_contains($fieldCode, 'SETTINGS') ||
- str_contains($fieldCode, '_PICTURE')) {
+ str_contains($fieldCode, '_PICTURE') ||
+ str_contains($fieldCode, '_PARAMS')) {
$this->assertTrue(
str_contains($propsFromAnnotations[$fieldCode], 'array'),
sprintf(
diff --git a/tests/Integration/Services/CRM/Activity/PhantomMethods/ActivityTypePhantomMethods.php b/tests/Integration/Services/CRM/Activity/PhantomMethods/ActivityTypePhantomMethods.php
new file mode 100644
index 00000000..b8c7c51c
--- /dev/null
+++ b/tests/Integration/Services/CRM/Activity/PhantomMethods/ActivityTypePhantomMethods.php
@@ -0,0 +1,91 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+namespace Bitrix24\SDK\Tests\Integration\Services\CRM\Activity\PhantomMethods;
+
+use Bitrix24\SDK\Services\CRM\Activity\Service\ActivityType;
+use Bitrix24\SDK\Tests\Integration\Fabric;
+
+class ActivityTypePhantomMethods
+{
+ private readonly ActivityType $activityTypeService;
+
+ /**
+ * ActivityTypePhantomMethods constructor.
+ */
+ public function __construct()
+ {
+ $this->activityTypeService = Fabric::getServiceBuilder(true)->getCRMScope()->activityType();
+ }
+
+ /**
+ * Get Activity type fields from list response
+ */
+ public function getFields(): array
+ {
+ $list = $this->activityTypeService->list()->getActivityTypes();
+ $fields = [];
+
+ if ($list !== [] && is_array($list)) {
+
+ $res = $list[0]->getIterator()->getArrayCopy();
+
+ $i = 0;
+ foreach (array_keys($res) as $key) {
+ $fields[$i] = $key;
+ $i++;
+ }
+
+ unset($i);
+ }
+
+ return $fields;
+ }
+
+ /**
+ * Get Activity type fields description from list response
+ */
+ public function getFieldsDescription(): array
+ {
+ $list = $this->activityTypeService->list()->getActivityTypes();
+ $fields = [];
+
+ if ($list !== [] && is_array($list)) {
+
+ $res = $list[0]->getIterator()->getArrayCopy();
+
+ $i = 0;
+ foreach ($res as $key => $value) {
+ $type = '';
+
+ if (is_string($value)) {
+ $type = 'string';
+ } elseif (is_int($value)) {
+ $type = 'int';
+ } elseif (is_bool($value)) {
+ $type = 'bool';
+ } elseif (is_array($value)) {
+ $type = 'array';
+ }
+
+ $fields[$key] = ['type' => $type];
+
+ $i++;
+ }
+
+ unset($i);
+ }
+
+ return $fields;
+ }
+}
diff --git a/tests/Integration/Services/CRM/Activity/ReadModel/EmailFetcherTest.php b/tests/Integration/Services/CRM/Activity/ReadModel/EmailFetcherTest.php
index b9855548..4f0332a3 100644
--- a/tests/Integration/Services/CRM/Activity/ReadModel/EmailFetcherTest.php
+++ b/tests/Integration/Services/CRM/Activity/ReadModel/EmailFetcherTest.php
@@ -17,14 +17,13 @@
use Bitrix24\SDK\Tests\Integration\Fabric;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher::class)]
class EmailFetcherTest extends TestCase
{
private EmailFetcher $emailFetcher;
/**
- * @return void
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
- * @covers \Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher::getList
*/
public function testGetListWithAllResults(): void
{
@@ -39,10 +38,11 @@ public function testGetListWithAllResults(): void
// $item->SUBJECT,
// ) . PHP_EOL);
}
+
$this->assertTrue(true);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->emailFetcher = Fabric::getServiceBuilder()->getCRMScope()->activityFetcher()->emailFetcher();
}
diff --git a/tests/Integration/Services/CRM/Activity/ReadModel/OpenLineFetcherTest.php b/tests/Integration/Services/CRM/Activity/ReadModel/OpenLineFetcherTest.php
index c4ad949f..4548a7ee 100644
--- a/tests/Integration/Services/CRM/Activity/ReadModel/OpenLineFetcherTest.php
+++ b/tests/Integration/Services/CRM/Activity/ReadModel/OpenLineFetcherTest.php
@@ -17,14 +17,13 @@
use Bitrix24\SDK\Tests\Integration\Fabric;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher::class)]
class OpenLineFetcherTest extends TestCase
{
private OpenLineFetcher $openLineFetcher;
/**
- * @return void
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
- * @covers \Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher::getList
*/
public function testGetListWithAllResults(): void
{
@@ -39,10 +38,11 @@ public function testGetListWithAllResults(): void
// $item->SUBJECT,
// ) . PHP_EOL);
}
+
$this->assertTrue(true);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->openLineFetcher = Fabric::getServiceBuilder()->getCRMScope()->activityFetcher()->openLineFetcher();
}
diff --git a/tests/Integration/Services/CRM/Activity/ReadModel/VoximplantFetcherTest.php b/tests/Integration/Services/CRM/Activity/ReadModel/VoximplantFetcherTest.php
index 273739f3..cdb9f58a 100644
--- a/tests/Integration/Services/CRM/Activity/ReadModel/VoximplantFetcherTest.php
+++ b/tests/Integration/Services/CRM/Activity/ReadModel/VoximplantFetcherTest.php
@@ -18,14 +18,13 @@
use Bitrix24\SDK\Tests\Integration\Fabric;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher::class)]
class VoximplantFetcherTest extends TestCase
{
private VoximplantFetcher $voximplantFetcher;
/**
- * @return void
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
- * @covers \Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher::getList
*/
public function testGetListWithAllResults(): void
{
@@ -40,10 +39,11 @@ public function testGetListWithAllResults(): void
// $item->SUBJECT,
// ) . PHP_EOL);
}
+
$this->assertTrue(true);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->voximplantFetcher = Fabric::getServiceBuilder()->getCRMScope()->activityFetcher()->voximplantFetcher();
}
diff --git a/tests/Integration/Services/CRM/Activity/ReadModel/WebFormFetcherTest.php b/tests/Integration/Services/CRM/Activity/ReadModel/WebFormFetcherTest.php
index 92bc50e7..41cf8d11 100644
--- a/tests/Integration/Services/CRM/Activity/ReadModel/WebFormFetcherTest.php
+++ b/tests/Integration/Services/CRM/Activity/ReadModel/WebFormFetcherTest.php
@@ -17,14 +17,13 @@
use Bitrix24\SDK\Tests\Integration\Fabric;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher::class)]
class WebFormFetcherTest extends TestCase
{
private WebFormFetcher $webFormFetcher;
/**
- * @return void
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
- * @covers \Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher::getList
*/
public function testGetListWithAllWebFormResults(): void
{
@@ -39,10 +38,11 @@ public function testGetListWithAllWebFormResults(): void
// $item->SUBJECT,
// ) . PHP_EOL);
}
+
$this->assertTrue(true);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->webFormFetcher = Fabric::getServiceBuilder()->getCRMScope()->activityFetcher()->webFormFetcher();
}
diff --git a/tests/Integration/Services/CRM/Activity/Service/ActivityTest.php b/tests/Integration/Services/CRM/Activity/Service/ActivityTest.php
index 7a05a2c0..d2a7cc08 100644
--- a/tests/Integration/Services/CRM/Activity/Service/ActivityTest.php
+++ b/tests/Integration/Services/CRM/Activity/Service/ActivityTest.php
@@ -15,21 +15,15 @@
use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Exceptions\TransportException;
-use Bitrix24\SDK\Services\CRM\Activity\ActivityContentType;
-use Bitrix24\SDK\Services\CRM\Activity\ActivityDirectionType;
use Bitrix24\SDK\Services\CRM\Activity\Result\ActivityItemResult;
use Bitrix24\SDK\Services\CRM\Activity\Service\Activity;
use Bitrix24\SDK\Services\CRM\Activity\ActivityType;
use Bitrix24\SDK\Services\CRM\Contact\Service\Contact;
-use Bitrix24\SDK\Services\CRM\Deal\Result\DealItemResult;
-use Bitrix24\SDK\Services\CRM\Deal\Result\DealProductRowItemResult;
use Bitrix24\SDK\Tests\Builders\DemoDataGenerator;
use Bitrix24\SDK\Tests\Integration\Fabric;
-use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
-use Typhoon\Reflection\TyphoonReflector;
use Bitrix24\SDK\Tests\CustomAssertions\CustomBitrix24Assertions;
use Bitrix24\SDK\Core;
@@ -46,13 +40,14 @@ class ActivityTest extends TestCase
use CustomBitrix24Assertions;
private Activity $activityService;
+
private Contact $contactService;
- private array $contactId;
- private array $activityId;
public function testAllSystemFieldsAnnotated(): void
{
- $propListFromApi = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($this->activityService->fields()->getFieldsDescription()));
+ $propListFromApi = (new Core\Fields\FieldsFilter())->filterSystemFields(
+ array_keys($this->activityService->fields()->getFieldsDescription())
+ );
$this->assertBitrix24AllResultItemFieldsAnnotated($propListFromApi, ActivityItemResult::class);
}
@@ -70,7 +65,6 @@ public function testAllSystemFieldsHasValidTypeAnnotation():void
public function testGet(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
- $this->contactId[] = $contactId;
$newActivity = [
'OWNER_ID' => $contactId,
@@ -92,7 +86,6 @@ public function testGet(): void
'RESULT_CURRENCY_ID' => 'USD'
];
$activityId = $this->activityService->add($newActivity)->getId();
- $this->activityId[] = $activityId;
$activity = $this->activityService->get($activityId)->activity();
@@ -107,8 +100,7 @@ public function testGet(): void
public function testAdd(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
- $this->contactId[] = $contactId;
- $this->activityId[] = $this->activityService->add(
+ $this->activityService->add(
[
'OWNER_ID' => $contactId,
'OWNER_TYPE_ID' => 3,
@@ -138,7 +130,6 @@ public function testAdd(): void
public function testDelete(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
- $this->contactId[] = $contactId;
$activityId = $this->activityService->add(
[
'OWNER_ID' => $contactId,
@@ -162,7 +153,6 @@ public function testDelete(): void
}
/**
- * @covers Contact::fields
* @throws BaseException
* @throws TransportException
*/
@@ -178,7 +168,6 @@ public function testFields(): void
public function testList(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
- $this->contactId[] = $contactId;
$newActivity = [];
for ($i = 1; $i < 10; $i++) {
@@ -199,10 +188,10 @@ public function testList(): void
],
],
];
- $this->activityId[] = $this->activityService->add($newActivity[$i])->getId();;
+ $this->activityService->add($newActivity[$i])->getId();;
}
- $res = $this->activityService->list(
+ $activitiesResult = $this->activityService->list(
['ID' => 'DESC'],
[
'OWNER_ID' => $contactId,
@@ -212,7 +201,7 @@ public function testList(): void
);
- $this->assertEquals(count($newActivity), count($res->getActivities()));
+ $this->assertEquals(count($newActivity), count($activitiesResult->getActivities()));
}
/**
@@ -222,7 +211,6 @@ public function testList(): void
public function testUpdate(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
- $this->contactId[] = $contactId;
$newActivity = [
'OWNER_ID' => $contactId,
@@ -242,7 +230,6 @@ public function testUpdate(): void
],
];
$activityId = $this->activityService->add($newActivity)->getId();
- $this->activityId[] = $activityId;
$subject = 'qqqqq';
$this->activityService->update($activityId, [
@@ -259,7 +246,6 @@ public function testUpdate(): void
public function testCountByFilter(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
- $this->contactId[] = $contactId;
$newActivity = [];
for ($i = 1; $i < 10; $i++) {
@@ -280,7 +266,7 @@ public function testCountByFilter(): void
],
],
];
- $this->activityId[] = $this->activityService->add($newActivity[$i])->getId();;
+ $this->activityService->add($newActivity[$i])->getId();;
}
$this->assertEquals(
@@ -293,19 +279,13 @@ public function testCountByFilter(): void
);
}
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->activityService->batch->delete($this->activityId) as $result) {
- }
- foreach ($this->contactService->batch->delete($this->contactId) as $result) {
- }
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->activityService = Fabric::getServiceBuilder()->getCRMScope()->activity();
$this->contactService = Fabric::getServiceBuilder()->getCRMScope()->contact();
- $this->contactId = [];
- $this->activityId = [];
}
}
\ No newline at end of file
diff --git a/tests/Integration/Services/CRM/Activity/Service/ActivityTypeTest.php b/tests/Integration/Services/CRM/Activity/Service/ActivityTypeTest.php
new file mode 100644
index 00000000..f7e86d06
--- /dev/null
+++ b/tests/Integration/Services/CRM/Activity/Service/ActivityTypeTest.php
@@ -0,0 +1,160 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Bitrix24\SDK\Tests\Integration\Services\CRM\Activity\Service;
+
+use Bitrix24\SDK\Core\Exceptions\BaseException;
+use Bitrix24\SDK\Core\Exceptions\TransportException;
+use Bitrix24\SDK\Services\CRM\Activity\Service\ActivityType;
+use Bitrix24\SDK\Services\CRM\Activity\Result\ActivityTypeResult;
+use Bitrix24\SDK\Tests\Integration\Fabric;
+use PHPUnit\Framework\Attributes\CoversMethod;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\TestCase;
+use Bitrix24\SDK\Tests\CustomAssertions\CustomBitrix24Assertions;
+use Bitrix24\SDK\Tests\CustomAssertions\AnnotationsParser;
+use Bitrix24\SDK\Tests\Integration\Services\CRM\Activity\PhantomMethods\ActivityTypePhantomMethods;
+
+
+#[CoversClass(ActivityType::class)]
+#[CoversMethod(ActivityType::class, 'add')]
+#[CoversMethod(ActivityType::class, 'delete')]
+#[CoversMethod(ActivityType::class, 'list')]
+class ActivityTypeTest extends TestCase
+{
+ use CustomBitrix24Assertions;
+
+ private ActivityType $activityTypeService;
+
+ private array $activityTypeIds;
+
+ protected function setUp(): void
+ {
+ $this->activityTypeService = Fabric::getServiceBuilder(true)->getCRMScope()->activityType();
+ $this->activityTypeIds = [];
+ }
+
+ protected function tearDown(): void
+ {
+ foreach ($this->activityTypeIds as $activityTypeId) {
+ $this->activityTypeService->delete($activityTypeId);
+ }
+ }
+
+ public function testAllSystemFieldsAnnotated(): void
+ {
+
+ $b24fields = (new ActivityTypePhantomMethods())->getFields();
+ $annotationFields = (new AnnotationsParser())->parse(ActivityTypeResult::class);
+
+ $this->assertEqualsCanonicalizing(
+ $b24fields,
+ $annotationFields,
+ sprintf(
+ 'in phpdocs annotations for class «%s» we not found fields from actual api response: %s',
+ ActivityTypeResult::class,
+ implode(', ', array_values(array_diff($b24fields, $annotationFields)))
+ )
+ );
+ }
+
+ public function testAllSystemFieldsHasValidTypeAnnotation():void
+ {
+ $this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
+ (new ActivityTypePhantomMethods())->getFieldsDescription(),
+ ActivityTypeResult::class
+ );
+ }
+
+ /**
+ * @throws BaseException
+ * @throws TransportException
+ */
+ public function testAdd(): void
+ {
+ $int = time();
+
+ $this->activityTypeService->add(
+ [
+ 'TYPE_ID' => 'TYPENAME_' . $int,
+ 'NAME' => 'NAME_' . $int,
+ ]
+ )->getId();
+
+ $activityTypesResult = $this->activityTypeService->list();
+ $res = $activityTypesResult->getActivityTypes();
+
+
+ $this->assertNotEmpty($res, 'List of activity types should not be empty.');
+
+ // successfully add activity type and get lis
+ $found = false;
+
+ foreach ($res as $re) {
+ if ($re->NAME == 'NAME_' . $int) {
+ $found = true;
+ break;
+ }
+ }
+
+ $this->assertTrue($found, 'Expected activity type not found in the list.');
+ }
+
+ /**
+ * @throws BaseException
+ * @throws TransportException
+ */
+ public function testDelete(): void
+ {
+ $int = time();
+ $int += 1;
+
+ $typeId = 'TYPENAME_' . $int;
+
+ $this->activityTypeService->add(
+ [
+ 'TYPE_ID' => $typeId,
+ 'NAME' => 'NAME_' . $int,
+ ]
+ )->getId();
+
+ $this->assertTrue($this->activityTypeService->delete($typeId)->isSuccess());
+ }
+
+ /**
+ * @throws BaseException
+ * @throws TransportException
+ */
+ public function testList(): void
+ {
+ for ($i = 0; $i < 3; $i++) {
+
+ $int = time();
+ $int = $int + 2 + $i;
+
+ $newActivityType[$i] = [
+ 'TYPE_ID' => 'TEST_' . $int,
+ 'NAME' => 'NAME_' . $int,
+ ];
+
+ $this->activityTypeService->add($newActivityType[$i])->getId();
+ $this->activityTypeIds[] = $newActivityType[$i]['TYPE_ID'];
+ }
+
+ $activityTypesResult = $this->activityTypeService->list();
+
+ $isResCountGreatherThenZero = $activityTypesResult->getActivityTypes() !== [];
+
+ $this->assertTrue($isResCountGreatherThenZero);
+ }
+}
diff --git a/tests/Integration/Services/CRM/Activity/Service/BatchTest.php b/tests/Integration/Services/CRM/Activity/Service/BatchTest.php
index f2d32bd1..3bba2433 100644
--- a/tests/Integration/Services/CRM/Activity/Service/BatchTest.php
+++ b/tests/Integration/Services/CRM/Activity/Service/BatchTest.php
@@ -21,18 +21,22 @@
use Bitrix24\SDK\Tests\Integration\Fabric;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Activity\Service\Batch::class)]
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Contact\Service\Batch::class)]
class BatchTest extends TestCase
{
private Contact $contactService;
+
private Activity $activityService;
+
private const BATCH_TEST_ELEMENTS_COUNT = 60;
+
private array $contactId;
/**
- * @testdox Batch add deals
- * @covers \Bitrix24\SDK\Services\CRM\Activity\Service\Batch::add()
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch add activities')]
public function testBatchAdd(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
@@ -65,20 +69,21 @@ public function testBatchAdd(): void
$cnt++;
$activityId[] = $item->getId();
}
+
self::assertEquals(count($items), $cnt);
$cnt = 0;
foreach ($this->activityService->batch->delete($activityId) as $cnt => $deleteResult) {
$cnt++;
}
+
self::assertEquals(count($items), $cnt);
}
/**
- * @testdox Batch delete activities
- * @covers \Bitrix24\SDK\Services\CRM\Activity\Service\Batch::delete()
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch delete activities')]
public function testBatchDelete(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
@@ -111,12 +116,14 @@ public function testBatchDelete(): void
$cnt++;
$activityId[] = $item->getId();
}
+
self::assertEquals(count($items), $cnt);
$cnt = 0;
foreach ($this->activityService->batch->delete($activityId) as $cnt => $deleteResult) {
$cnt++;
}
+
self::assertEquals(count($items), $cnt);
@@ -131,11 +138,10 @@ public function testBatchDelete(): void
}
/**
- * @testdox Batch list deals
- * @covers \Bitrix24\SDK\Services\CRM\Contact\Service\Batch::list()
* @throws BaseException
* @throws TransportException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch list activities')]
public function testBatchList(): void
{
$contactId = $this->contactService->add(['NAME' => 'test contact'])->getId();
@@ -174,6 +180,7 @@ public function testBatchList(): void
foreach ($this->activityService->batch->list(['ID' => 'DESC'], ['OWNER_ID' => $contactId], ['*']) as $item) {
$itemsCnt++;
}
+
$this->assertEquals(
count($activityId),
$itemsCnt,
@@ -185,12 +192,12 @@ public function testBatchList(): void
);
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->contactService->batch->delete($this->contactId);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->activityService = Fabric::getServiceBuilder()->getCRMScope()->activity();
$this->contactService = Fabric::getServiceBuilder()->getCRMScope()->contact();
diff --git a/tests/Integration/Services/CRM/Activity/Service/CommunicationTest.php b/tests/Integration/Services/CRM/Activity/Service/CommunicationTest.php
new file mode 100644
index 00000000..3670affc
--- /dev/null
+++ b/tests/Integration/Services/CRM/Activity/Service/CommunicationTest.php
@@ -0,0 +1,61 @@
+
+ *
+ * For the full copyright and license information, please view the MIT-LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Bitrix24\SDK\Tests\Integration\Services\CRM\Activity\Service;
+
+use Bitrix24\SDK\Core\Exceptions\BaseException;
+use Bitrix24\SDK\Core\Exceptions\TransportException;
+use Bitrix24\SDK\Services\CRM\Activity\Service\Communication;
+use Bitrix24\SDK\Tests\Integration\Fabric;
+use PHPUnit\Framework\Attributes\CoversMethod;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\TestCase;
+use Bitrix24\SDK\Tests\CustomAssertions\CustomBitrix24Assertions;
+use Bitrix24\SDK\Core;
+use Bitrix24\SDK\Services\CRM\Activity\Result\CommunicationItemResult;
+
+#[CoversClass(Communication::class)]
+#[CoversMethod(Communication::class, 'fields')]
+class CommunicationTest extends TestCase
+{
+ use CustomBitrix24Assertions;
+
+ private Communication $communicationService;
+
+ protected function setUp(): void
+ {
+ $this->communicationService = Fabric::getServiceBuilder()->getCRMScope()->communication();
+ }
+
+ public function testAllSystemFieldsAnnotated(): void
+ {
+ $propListFromApi = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($this->communicationService->fields()->getFieldsDescription()));
+ $this->assertBitrix24AllResultItemFieldsAnnotated($propListFromApi, CommunicationItemResult::class);
+ }
+
+ public function testAllSystemFieldsHasValidTypeAnnotation():void
+ {
+ $this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
+ $this->communicationService->fields()->getFieldsDescription(),
+ CommunicationItemResult::class);
+ }
+
+ /**
+ * @throws BaseException
+ * @throws TransportException
+ */
+ public function testFields(): void
+ {
+ self::assertIsArray($this->communicationService->fields()->getFieldsDescription());
+ }
+}
\ No newline at end of file
diff --git a/tests/Integration/Services/CRM/Company/Service/BatchTest.php b/tests/Integration/Services/CRM/Company/Service/BatchTest.php
index c9e082db..f39e8219 100644
--- a/tests/Integration/Services/CRM/Company/Service/BatchTest.php
+++ b/tests/Integration/Services/CRM/Company/Service/BatchTest.php
@@ -33,17 +33,16 @@
class BatchTest extends TestCase
{
private ServiceBuilder $sb;
+
private array $createdCompanies = [];
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->sb->getCRMScope()->company()->batch->delete($this->createdCompanies) as $result) {
- }
}
public function testBatchList(): void
@@ -54,6 +53,7 @@ public function testBatchList(): void
for ($i = 1; $i <= $newCompaniesCount; $i++) {
$companies[] = ['TITLE' => 'TITLE-' . sprintf('Acme Inc - %s', time()), 'UTM_SOURCE' => $utmSource];
}
+
$cnt = 0;
foreach ($this->sb->getCRMScope()->company()->batch->add($companies) as $item) {
$this->createdCompanies[] = $item->getId();
@@ -66,6 +66,7 @@ public function testBatchList(): void
) {
$addedCompanies[] = $item->ID;
}
+
$this->assertEquals($newCompaniesCount, count($addedCompanies));
}
@@ -77,11 +78,13 @@ public function testBatchAdd(): void
for ($i = 1; $i <= $newCompaniesCount; $i++) {
$companies[] = ['TITLE' => 'TITLE-' . sprintf('Acme Inc - %s', time()), 'UTM_SOURCE' => $utmSource];
}
+
$newCompanies = [];
foreach ($this->sb->getCRMScope()->company()->batch->add($companies) as $item) {
$this->createdCompanies[] = $item->getId();
$newCompanies[] = $item->getId();
}
+
foreach (
$this->sb->getCRMScope()->company()->batch->list([], ['UTM_SOURCE' => $utmSource], ['ID', 'TITLE']) as $item
) {
@@ -99,15 +102,18 @@ public function testBatchDelete(): void
for ($i = 1; $i <= $newCompaniesCount; $i++) {
$companies[] = ['TITLE' => 'TITLE-' . sprintf('Acme Inc - %s', time()), 'UTM_SOURCE' => $utmSource];
}
+
$newCompanies = [];
foreach ($this->sb->getCRMScope()->company()->batch->add($companies) as $item) {
$newCompanies[] = $item->getId();
}
+
$deletedCnt = 0;
foreach ($this->sb->getCRMScope()->company()->batch->delete($newCompanies) as $result) {
$this->assertTrue($result->isSuccess());
$deletedCnt++;
}
+
$this->assertEquals($newCompaniesCount, $deletedCnt);
$this->assertEquals(0, $this->sb->getCRMScope()->company()->countByFilter(['UTM_SOURCE' => $utmSource]));
}
@@ -120,6 +126,7 @@ public function testBatchUpdate(): void
for ($i = 1; $i <= $newCompaniesCount; $i++) {
$companies[] = ['TITLE' => 'TITLE-' . sprintf('Acme Inc - %s', time()), 'UTM_SOURCE' => $utmSource];
}
+
$newCompanies = [];
foreach ($this->sb->getCRMScope()->company()->batch->add($companies) as $item) {
$this->createdCompanies[] = $item->getId();
diff --git a/tests/Integration/Services/CRM/Company/Service/CompanyContactTest.php b/tests/Integration/Services/CRM/Company/Service/CompanyContactTest.php
index 335db892..1638abc6 100644
--- a/tests/Integration/Services/CRM/Company/Service/CompanyContactTest.php
+++ b/tests/Integration/Services/CRM/Company/Service/CompanyContactTest.php
@@ -40,20 +40,16 @@ class CompanyContactTest extends TestCase
private ServiceBuilder $sb;
private array $createdCompanies = [];
+
private array $createdContacts = [];
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->sb->getCRMScope()->company()->batch->delete($this->createdCompanies) as $result) {
- }
-
- foreach ($this->sb->getCRMScope()->contact()->batch->delete($this->createdContacts) as $result) {
- }
}
public function testSet(): void
@@ -74,8 +70,8 @@ public function testSet(): void
$connectedId = [$contactIdOne, $contactIdTwo];
$connectedContacts = $this->sb->getCRMScope()->companyContact()->get($companyId)->getContactConnections();
- foreach ($connectedContacts as $item) {
- $this->assertContains($item->CONTACT_ID, $connectedId);
+ foreach ($connectedContacts as $connectedContact) {
+ $this->assertContains($connectedContact->CONTACT_ID, $connectedId);
}
}
@@ -107,8 +103,8 @@ public function testAdd(): void
$connectedId = [$contactIdOne, $contactIdTwo];
$connectedContacts = $this->sb->getCRMScope()->companyContact()->get($companyId)->getContactConnections();
- foreach ($connectedContacts as $item) {
- $this->assertContains($item->CONTACT_ID, $connectedId);
+ foreach ($connectedContacts as $connectedContact) {
+ $this->assertContains($connectedContact->CONTACT_ID, $connectedId);
}
}
diff --git a/tests/Integration/Services/CRM/Company/Service/CompanyDetailsConfigurationTest.php b/tests/Integration/Services/CRM/Company/Service/CompanyDetailsConfigurationTest.php
index da9c1ae5..0d1401ea 100644
--- a/tests/Integration/Services/CRM/Company/Service/CompanyDetailsConfigurationTest.php
+++ b/tests/Integration/Services/CRM/Company/Service/CompanyDetailsConfigurationTest.php
@@ -41,14 +41,15 @@ class CompanyDetailsConfigurationTest extends TestCase
private ServiceBuilder $sb;
private array $createdCompanies = [];
+
private array $createdContacts = [];
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->sb->getCRMScope()->companyDetailsConfiguration()->resetGeneral();
}
@@ -141,8 +142,8 @@ public function testGetPersonal(): void
);
- $currentUserId = $this->sb->getMainScope()->main()->getCurrentUserProfile()->getUserProfile()->ID;
- $cardConfig = $this->sb->getCRMScope()->companyDetailsConfiguration()->getGeneral($currentUserId);
+ $this->sb->getMainScope()->main()->getCurrentUserProfile()->getUserProfile()->ID;
+ $this->sb->getCRMScope()->companyDetailsConfiguration()->getGeneral();
// todo fix after we get valid cardConfig
$this->assertTrue(true);
diff --git a/tests/Integration/Services/CRM/Company/Service/CompanyTest.php b/tests/Integration/Services/CRM/Company/Service/CompanyTest.php
index 4b43e901..307c2e1e 100644
--- a/tests/Integration/Services/CRM/Company/Service/CompanyTest.php
+++ b/tests/Integration/Services/CRM/Company/Service/CompanyTest.php
@@ -46,20 +46,19 @@ class CompanyTest extends TestCase
use CustomBitrix24Assertions;
private ServiceBuilder $sb;
+
private Faker\Generator $faker;
private array $createdCompanies = [];
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
$this->faker = Faker\Factory::create();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->sb->getCRMScope()->company()->batch->delete($this->createdCompanies) as $result) {
- }
}
#[TestDox('method crm.company.fields')]
@@ -75,9 +74,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation(): void
{
$allFields = $this->sb->getCRMScope()->company()->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
$systemFields,
@@ -120,11 +117,11 @@ public function testAdd(): void
$this->createdCompanies[] = $companyId;
$this->assertGreaterThan(1, $companyId);
- $addedCompany = $this->sb->getCRMScope()->company()->get($companyId)->company();
+ $companyItemResult = $this->sb->getCRMScope()->company()->get($companyId)->company();
- $this->assertEquals($companyTitle, $addedCompany->TITLE);
- $this->assertEquals($email, $addedCompany->EMAIL[0]->VALUE);
- $this->assertEquals($phone, $addedCompany->PHONE[0]->VALUE);
+ $this->assertEquals($companyTitle, $companyItemResult->TITLE);
+ $this->assertEquals($email, $companyItemResult->EMAIL[0]->VALUE);
+ $this->assertEquals($phone, $companyItemResult->PHONE[0]->VALUE);
}
#[TestDox('method crm.company.get')]
@@ -140,8 +137,8 @@ public function testGet(): void
$this->createdCompanies[] = $companyId;
$this->assertGreaterThan(1, $companyId);
- $addedCompany = $this->sb->getCRMScope()->company()->get($companyId)->company();
- $this->assertEquals($companyTitle, $addedCompany->TITLE);
+ $companyItemResult = $this->sb->getCRMScope()->company()->get($companyId)->company();
+ $this->assertEquals($companyTitle, $companyItemResult->TITLE);
}
#[TestDox('method crm.company.delete')]
@@ -171,8 +168,8 @@ public function testList(): void
)->getId();
$this->createdCompanies[] = $companyId;
- $companies = $this->sb->getCRMScope()->company()->list();
- $this->assertGreaterThan(1, count($companies->getCompanies()));
+ $companiesResult = $this->sb->getCRMScope()->company()->list();
+ $this->assertGreaterThan(1, count($companiesResult->getCompanies()));
}
#[TestDox('method crm.company.update')]
@@ -200,11 +197,13 @@ public function testCountByFilter(): void
for ($i = 1; $i <= $newCompaniesCount; $i++) {
$companies[] = ['TITLE' => 'TITLE-' . sprintf('Acme Inc - %s', time()), 'UTM_SOURCE' => $utmSource];
}
+
$cnt = 0;
foreach ($this->sb->getCRMScope()->company()->batch->add($companies) as $item) {
$this->createdCompanies[] = $item->getId();
$cnt++;
}
+
self::assertEquals(count($companies), $cnt);
$this->assertEquals(
diff --git a/tests/Integration/Services/CRM/Company/Service/CompanyUserfieldTest.php b/tests/Integration/Services/CRM/Company/Service/CompanyUserfieldTest.php
index fd98f6e5..21198923 100644
--- a/tests/Integration/Services/CRM/Company/Service/CompanyUserfieldTest.php
+++ b/tests/Integration/Services/CRM/Company/Service/CompanyUserfieldTest.php
@@ -40,20 +40,18 @@ class CompanyUserfieldTest extends TestCase
private ServiceBuilder $sb;
private array $createdCompanies = [];
+
private array $createdUserfields = [];
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->sb->getCRMScope()->company()->batch->delete($this->createdCompanies) as $result) {
- }
-
- foreach ($this->createdUserfields as $fieldId) {
- $this->sb->getCRMScope()->companyUserfield()->delete($fieldId);
+ foreach ($this->createdUserfields as $createdUserfield) {
+ $this->sb->getCRMScope()->companyUserfield()->delete($createdUserfield);
}
}
@@ -68,11 +66,11 @@ public function testCompanyUserfieldAdd(array $uf): void
{
$fieldId = $this->sb->getCRMScope()->companyUserfield()->add($uf)->getId();
$this->createdUserfields[] = $fieldId;
- $addedField = $this->sb->getCRMScope()->companyUserfield()->get($fieldId)->userfieldItem();
+ $companyUserfieldItemResult = $this->sb->getCRMScope()->companyUserfield()->get($fieldId)->userfieldItem();
- $this->assertTrue(str_contains($addedField->FIELD_NAME, $uf['FIELD_NAME']));
- $this->assertEquals($uf['USER_TYPE_ID'], $addedField->USER_TYPE_ID);
- $this->assertEquals($uf['XML_ID'], $addedField->XML_ID);
+ $this->assertTrue(str_contains($companyUserfieldItemResult->FIELD_NAME, (string) $uf['FIELD_NAME']));
+ $this->assertEquals($uf['USER_TYPE_ID'], $companyUserfieldItemResult->USER_TYPE_ID);
+ $this->assertEquals($uf['XML_ID'], $companyUserfieldItemResult->XML_ID);
}
#[TestDox('crm.company.userfield.get')]
@@ -80,11 +78,11 @@ public function testCompanyUserfieldAdd(array $uf): void
public function testCompanyUserfieldGet(array $uf): void
{
$fieldId = $this->sb->getCRMScope()->companyUserfield()->add($uf)->getId();
- $addedField = $this->sb->getCRMScope()->companyUserfield()->get($fieldId)->userfieldItem();
+ $companyUserfieldItemResult = $this->sb->getCRMScope()->companyUserfield()->get($fieldId)->userfieldItem();
- $this->assertTrue(str_contains($addedField->FIELD_NAME, $uf['FIELD_NAME']));
- $this->assertEquals($uf['USER_TYPE_ID'], $addedField->USER_TYPE_ID);
- $this->assertEquals($uf['XML_ID'], $addedField->XML_ID);
+ $this->assertTrue(str_contains($companyUserfieldItemResult->FIELD_NAME, (string) $uf['FIELD_NAME']));
+ $this->assertEquals($uf['USER_TYPE_ID'], $companyUserfieldItemResult->USER_TYPE_ID);
+ $this->assertEquals($uf['XML_ID'], $companyUserfieldItemResult->XML_ID);
}
#[TestDox('crm.company.userfield.list')]
@@ -93,13 +91,13 @@ public function testCompanyUserfieldList(): void
$newFields[] = (new SystemUserfieldBuilder())->build();
$newFields[] = (new SystemUserfieldBuilder('integer'))->build();
- foreach ($newFields as $field) {
- $addedResult = $this->sb->getCRMScope()->companyUserfield()->add($field);
+ foreach ($newFields as $newField) {
+ $addedResult = $this->sb->getCRMScope()->companyUserfield()->add($newField);
$this->createdUserfields[] = $addedResult->getId();
}
- $fields = $this->sb->getCRMScope()->companyUserfield()->list();
- $this->assertGreaterThanOrEqual(2, $fields->getUserfields());
+ $companyUserfieldsResult = $this->sb->getCRMScope()->companyUserfield()->list();
+ $this->assertGreaterThanOrEqual(2, $companyUserfieldsResult->getUserfields());
}
#[TestDox('crm.company.userfield.delete')]
@@ -107,8 +105,8 @@ public function testCompanyUserfieldList(): void
public function testCompanyUserfieldDelete(array $uf): void
{
$fieldId = $this->sb->getCRMScope()->companyUserfield()->add($uf)->getId();
- $addedField = $this->sb->getCRMScope()->companyUserfield()->get($fieldId)->userfieldItem();
- $this->assertTrue(str_contains($addedField->FIELD_NAME, $uf['FIELD_NAME']));
+ $companyUserfieldItemResult = $this->sb->getCRMScope()->companyUserfield()->get($fieldId)->userfieldItem();
+ $this->assertTrue(str_contains($companyUserfieldItemResult->FIELD_NAME, (string) $uf['FIELD_NAME']));
$this->assertTrue($this->sb->getCRMScope()->companyUserfield()->delete($fieldId)->isSuccess());
@@ -122,13 +120,13 @@ public function testCompanyUserfieldUpdate(array $uf): void
{
$fieldId = $this->sb->getCRMScope()->companyUserfield()->add($uf)->getId();
$this->createdUserfields[] = $fieldId;
- $addedField = $this->sb->getCRMScope()->companyUserfield()->get($fieldId)->userfieldItem();
+ $companyUserfieldItemResult = $this->sb->getCRMScope()->companyUserfield()->get($fieldId)->userfieldItem();
- $this->assertTrue(str_contains($addedField->FIELD_NAME, $uf['FIELD_NAME']));
- $this->assertEquals($uf['USER_TYPE_ID'], $addedField->USER_TYPE_ID);
- $this->assertEquals($uf['XML_ID'], $addedField->XML_ID);
+ $this->assertTrue(str_contains($companyUserfieldItemResult->FIELD_NAME, (string) $uf['FIELD_NAME']));
+ $this->assertEquals($uf['USER_TYPE_ID'], $companyUserfieldItemResult->USER_TYPE_ID);
+ $this->assertEquals($uf['XML_ID'], $companyUserfieldItemResult->XML_ID);
- $newXmlId = 'new' . $addedField->XML_ID;
+ $newXmlId = 'new' . $companyUserfieldItemResult->XML_ID;
$this->assertTrue(
$this->sb->getCRMScope()->companyUserfield()->update(
diff --git a/tests/Integration/Services/CRM/Contact/Service/ContactBatchTest.php b/tests/Integration/Services/CRM/Contact/Service/ContactBatchTest.php
index af252f53..b63490ae 100644
--- a/tests/Integration/Services/CRM/Contact/Service/ContactBatchTest.php
+++ b/tests/Integration/Services/CRM/Contact/Service/ContactBatchTest.php
@@ -26,6 +26,7 @@
*
* @package Bitrix24\SDK\Tests\Integration\Services\CRM\Contact\Service
*/
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Contact\Service\Batch::class)]
class ContactBatchTest extends TestCase
{
private const TEST_SEGMENT_ELEMENTS_COUNT = 400;
@@ -35,7 +36,6 @@ class ContactBatchTest extends TestCase
/**
* @throws BaseException
* @throws TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Contact\Service\Batch::list()
*/
public function testBatchList(): void
{
@@ -45,13 +45,13 @@ public function testBatchList(): void
foreach ($this->contactService->batch->list([], ['>ID' => '1'], ['ID', 'NAME'], 1) as $item) {
$cnt++;
}
+
self::assertGreaterThanOrEqual(1, $cnt);
}
/**
* @throws BaseException
* @throws TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Contact\Service\Batch::add()
*/
public function testBatchAdd(): void
{
@@ -59,6 +59,7 @@ public function testBatchAdd(): void
for ($i = 1; $i < 60; $i++) {
$contacts[] = ['NAME' => 'name-' . $i];
}
+
$cnt = 0;
foreach ($this->contactService->batch->add($contacts) as $item) {
$cnt++;
@@ -68,9 +69,7 @@ public function testBatchAdd(): void
}
/**
- * @return void
* @throws BaseException
- * @covers \Bitrix24\SDK\Services\CRM\Contact\Service\Batch::update()
*/
public function testBatchUpdate(): void
{
@@ -89,12 +88,14 @@ public function testBatchUpdate(): void
]
];
}
+
$cnt = 0;
$contactId = [];
foreach ($this->contactService->batch->add($contacts) as $item) {
$cnt++;
$contactId[] = $item->getId();
}
+
self::assertEquals(count($contacts), $cnt);
// generate update data
@@ -113,6 +114,7 @@ public function testBatchUpdate(): void
$cnt++;
$this->assertTrue($item->isSuccess());
}
+
self::assertEquals(count($contacts), $cnt);
// delete contacts
@@ -121,10 +123,11 @@ public function testBatchUpdate(): void
$cnt++;
$this->assertTrue($item->isSuccess());
}
+
self::assertEquals(count($contacts), $cnt);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->contactService = Fabric::getServiceBuilder()->getCRMScope()->contact();
}
diff --git a/tests/Integration/Services/CRM/Contact/Service/ContactCompanyTest.php b/tests/Integration/Services/CRM/Contact/Service/ContactCompanyTest.php
index 7a528a3e..974ced52 100644
--- a/tests/Integration/Services/CRM/Contact/Service/ContactCompanyTest.php
+++ b/tests/Integration/Services/CRM/Contact/Service/ContactCompanyTest.php
@@ -44,20 +44,16 @@ class ContactCompanyTest extends TestCase
private ServiceBuilder $sb;
private array $createdCompanies = [];
+
private array $createdContacts = [];
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->sb->getCRMScope()->company()->batch->delete($this->createdCompanies) as $result) {
- }
-
- foreach ($this->sb->getCRMScope()->contact()->batch->delete($this->createdContacts) as $result) {
- }
}
@@ -86,9 +82,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation(): void
{
$allFields = $this->sb->getCRMScope()->contactCompany()->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
$systemFields,
@@ -121,8 +115,8 @@ public function testSet(): void
// read and check
$companies = $this->sb->getCRMScope()->contactCompany()->get($contactId)->getCompanyConnections();
- foreach ($companies as $item) {
- $this->assertContains($item->COMPANY_ID, $newCompanyId);
+ foreach ($companies as $company) {
+ $this->assertContains($company->COMPANY_ID, $newCompanyId);
}
}
@@ -161,8 +155,8 @@ public function testAdd(): void
// read and check
$companies = $this->sb->getCRMScope()->contactCompany()->get($contactId)->getCompanyConnections();
- foreach ($companies as $item) {
- $this->assertContains($item->COMPANY_ID, $newCompanyId);
+ foreach ($companies as $company) {
+ $this->assertContains($company->COMPANY_ID, $newCompanyId);
}
}
diff --git a/tests/Integration/Services/CRM/Contact/Service/ContactTest.php b/tests/Integration/Services/CRM/Contact/Service/ContactTest.php
index a24da1f4..ae95a8b3 100644
--- a/tests/Integration/Services/CRM/Contact/Service/ContactTest.php
+++ b/tests/Integration/Services/CRM/Contact/Service/ContactTest.php
@@ -46,6 +46,7 @@ class ContactTest extends TestCase
use CustomBitrix24Assertions;
private Contact $contactService;
+
private Faker\Generator $faker;
/**
@@ -90,9 +91,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation():void
{
$allFields = $this->contactService->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
$systemFields,
@@ -127,11 +126,11 @@ public function testList(): void
*/
public function testUpdate(): void
{
- $contact = $this->contactService->add(['NAME' => 'test']);
+ $addedItemResult = $this->contactService->add(['NAME' => 'test']);
$newName = 'test2';
- self::assertTrue($this->contactService->update($contact->getId(), ['NAME' => $newName], [])->isSuccess());
- self::assertEquals($newName, $this->contactService->get($contact->getId())->contact()->NAME);
+ self::assertTrue($this->contactService->update($addedItemResult->getId(), ['NAME' => $newName], [])->isSuccess());
+ self::assertEquals($newName, $this->contactService->get($addedItemResult->getId())->contact()->NAME);
}
/**
@@ -149,16 +148,12 @@ public function testCountByFilter(): void
$contacts[] = ['NAME' => 'name-' . $i];
}
- foreach ($this->contactService->batch->add($contacts) as $item) {
- }
-
$totalAfter = $this->contactService->countByFilter();
$this->assertEquals($totalBefore + $newContactsCount, $totalAfter);
}
/**
- * @return void
* @throws Core\Exceptions\TransportException
* @throws Core\Exceptions\BaseException
*/
@@ -179,7 +174,6 @@ public function testGetEmail(): void
}
/**
- * @return void
* @throws Core\Exceptions\TransportException
* @throws Core\Exceptions\BaseException
*/
@@ -200,7 +194,6 @@ public function testGetPhone(): void
}
/**
- * @return void
* @throws Core\Exceptions\TransportException
* @throws Core\Exceptions\BaseException
*/
@@ -221,7 +214,6 @@ public function testGetInstantMessenger(): void
}
/**
- * @return void
* @throws Core\Exceptions\TransportException
* @throws Core\Exceptions\BaseException
*/
@@ -241,7 +233,7 @@ public function testGetWebsite(): void
])->getId())->contact()->WEB[0]->VALUE);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->contactService = Fabric::getServiceBuilder()->getCRMScope()->contact();
$this->faker = Faker\Factory::create();
diff --git a/tests/Integration/Services/CRM/Contact/Service/ContactUserfieldTest.php b/tests/Integration/Services/CRM/Contact/Service/ContactUserfieldTest.php
index 13204f6c..a3a9c781 100644
--- a/tests/Integration/Services/CRM/Contact/Service/ContactUserfieldTest.php
+++ b/tests/Integration/Services/CRM/Contact/Service/ContactUserfieldTest.php
@@ -18,6 +18,7 @@
use Generator;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Contact\Service\ContactUserfield::class)]
class ContactUserfieldTest extends TestCase
{
protected ContactUserfield $contactUserfieldService;
@@ -25,7 +26,7 @@ class ContactUserfieldTest extends TestCase
/**
* @throws \Exception
*/
- public function systemUserfieldsDemoDataDataProvider(): Generator
+ public static function systemUserfieldsDemoDataDataProvider(): Generator
{
yield 'user type id string' => [
[
@@ -64,61 +65,47 @@ public function systemUserfieldsDemoDataDataProvider(): Generator
}
/**
- * @param array $newUserFieldItem
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
* @throws \Bitrix24\SDK\Services\CRM\Userfield\Exceptions\UserfieldNameIsTooLongException
- * @covers ContactUserfield::add
- * @dataProvider systemUserfieldsDemoDataDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('systemUserfieldsDemoDataDataProvider')]
public function testAdd(array $newUserFieldItem): void
{
self::assertGreaterThanOrEqual(1, $this->contactUserfieldService->add($newUserFieldItem)->getId());
}
- /**
- * @param array $newUserFieldItem
- *
- * @dataProvider systemUserfieldsDemoDataDataProvider
- * @covers ContactUserfield::delete
- */
+
+ #[\PHPUnit\Framework\Attributes\DataProvider('systemUserfieldsDemoDataDataProvider')]
public function testDelete(array $newUserFieldItem): void
{
$newUserfieldId = $this->contactUserfieldService->add($newUserFieldItem)->getId();
$this->assertTrue($this->contactUserfieldService->delete($newUserfieldId)->isSuccess());
}
- /**
- * @param array $newUserFieldItem
- *
- * @dataProvider systemUserfieldsDemoDataDataProvider
- * @covers ContactUserfield::get
- */
+
+ #[\PHPUnit\Framework\Attributes\DataProvider('systemUserfieldsDemoDataDataProvider')]
public function testGet(array $newUserFieldItem): void
{
$newUserfieldId = $this->contactUserfieldService->add($newUserFieldItem)->getId();
- $ufField = $this->contactUserfieldService->get($newUserfieldId)->userfieldItem();
- $this->assertEquals($newUserfieldId, $ufField->ID);
- $this->assertEquals($newUserFieldItem['USER_TYPE_ID'], $ufField->USER_TYPE_ID);
- $this->assertEquals('UF_CRM_' . $newUserFieldItem['FIELD_NAME'], $ufField->FIELD_NAME);
- $this->assertEquals($newUserFieldItem['XML_ID'], $ufField->XML_ID);
+ $contactUserfieldItemResult = $this->contactUserfieldService->get($newUserfieldId)->userfieldItem();
+ $this->assertEquals($newUserfieldId, $contactUserfieldItemResult->ID);
+ $this->assertEquals($newUserFieldItem['USER_TYPE_ID'], $contactUserfieldItemResult->USER_TYPE_ID);
+ $this->assertEquals('UF_CRM_' . $newUserFieldItem['FIELD_NAME'], $contactUserfieldItemResult->FIELD_NAME);
+ $this->assertEquals($newUserFieldItem['XML_ID'], $contactUserfieldItemResult->XML_ID);
}
- /**
- * @param array $newUserFieldItem
- *
- * @dataProvider systemUserfieldsDemoDataDataProvider
- * @covers ContactUserfield::update
- */
+
+ #[\PHPUnit\Framework\Attributes\DataProvider('systemUserfieldsDemoDataDataProvider')]
public function testUpdate(array $newUserFieldItem): void
{
$newUserfieldId = $this->contactUserfieldService->add($newUserFieldItem)->getId();
- $ufFieldBefore = $this->contactUserfieldService->get($newUserfieldId)->userfieldItem();
- $this->assertEquals($newUserfieldId, $ufFieldBefore->ID);
- $this->assertEquals($newUserFieldItem['USER_TYPE_ID'], $ufFieldBefore->USER_TYPE_ID);
- $this->assertEquals('UF_CRM_' . $newUserFieldItem['FIELD_NAME'], $ufFieldBefore->FIELD_NAME);
- $this->assertEquals($newUserFieldItem['XML_ID'], $ufFieldBefore->XML_ID);
+ $contactUserfieldItemResult = $this->contactUserfieldService->get($newUserfieldId)->userfieldItem();
+ $this->assertEquals($newUserfieldId, $contactUserfieldItemResult->ID);
+ $this->assertEquals($newUserFieldItem['USER_TYPE_ID'], $contactUserfieldItemResult->USER_TYPE_ID);
+ $this->assertEquals('UF_CRM_' . $newUserFieldItem['FIELD_NAME'], $contactUserfieldItemResult->FIELD_NAME);
+ $this->assertEquals($newUserFieldItem['XML_ID'], $contactUserfieldItemResult->XML_ID);
$this->assertTrue(
$this->contactUserfieldService->update(
@@ -130,21 +117,20 @@ public function testUpdate(array $newUserFieldItem): void
);
$ufFieldAfter = $this->contactUserfieldService->get($newUserfieldId)->userfieldItem();
- $this->assertEquals($ufFieldBefore->EDIT_FORM_LABEL['en'] . 'QQQ', $ufFieldAfter->EDIT_FORM_LABEL['en']);
+ $this->assertEquals($contactUserfieldItemResult->EDIT_FORM_LABEL['en'] . 'QQQ', $ufFieldAfter->EDIT_FORM_LABEL['en']);
}
/**
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Contact\Service\ContactUserfield::list
*/
public function testList(): void
{
- $ufFields = $this->contactUserfieldService->list([], []);
- $this->assertGreaterThanOrEqual(0, count($ufFields->getUserfields()));
+ $contactUserfieldsResult = $this->contactUserfieldService->list([], []);
+ $this->assertGreaterThanOrEqual(0, count($contactUserfieldsResult->getUserfields()));
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->contactUserfieldService = Fabric::getServiceBuilder()->getCRMScope()->contactUserfield();
}
diff --git a/tests/Integration/Services/CRM/Contact/Service/ContactUserfieldUseCaseTest.php b/tests/Integration/Services/CRM/Contact/Service/ContactUserfieldUseCaseTest.php
index e61f7ae3..2bce1080 100644
--- a/tests/Integration/Services/CRM/Contact/Service/ContactUserfieldUseCaseTest.php
+++ b/tests/Integration/Services/CRM/Contact/Service/ContactUserfieldUseCaseTest.php
@@ -23,20 +23,21 @@
class ContactUserfieldUseCaseTest extends TestCase
{
protected Contact $contactService;
+
protected ContactUserfield $contactUserfieldService;
+
protected int $contactUserfieldId;
/**
* @throws BaseException
* @throws TransportException
- * @covers Contact::add
*/
public function testOperationsWithUserfieldFromContactItem(): void
{
// get userfield metadata
- $ufMetadata = $this->contactUserfieldService->get($this->contactUserfieldId)->userfieldItem();
- $ufOriginalFieldName = $ufMetadata->getOriginalFieldName();
- $ufFieldName = $ufMetadata->FIELD_NAME;
+ $contactUserfieldItemResult = $this->contactUserfieldService->get($this->contactUserfieldId)->userfieldItem();
+ $ufOriginalFieldName = $contactUserfieldItemResult->getOriginalFieldName();
+ $ufFieldName = $contactUserfieldItemResult->FIELD_NAME;
// add contact with uf value
$fieldNameValue = 'test field value';
@@ -59,8 +60,8 @@ public function testOperationsWithUserfieldFromContactItem(): void
]
)->isSuccess()
);
- $updatedContact = $this->contactService->get($contact->ID)->contact();
- $this->assertEquals($newUfValue, $updatedContact->getUserfieldByFieldName($ufOriginalFieldName));
+ $contactItemResult = $this->contactService->get($contact->ID)->contact();
+ $this->assertEquals($newUfValue, $contactItemResult->getUserfieldByFieldName($ufOriginalFieldName));
}
/**
@@ -69,7 +70,7 @@ public function testOperationsWithUserfieldFromContactItem(): void
* @throws \Bitrix24\SDK\Core\Exceptions\InvalidArgumentException
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
- public function setUp(): void
+ protected function setUp(): void
{
$this->contactService = Fabric::getServiceBuilder()->getCRMScope()->contact();
$this->contactUserfieldService = Fabric::getServiceBuilder()->getCRMScope()->contactUserfield();
@@ -94,7 +95,7 @@ public function setUp(): void
)->getId();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->contactUserfieldService->delete($this->contactUserfieldId);
}
diff --git a/tests/Integration/Services/CRM/Deal/Service/BatchTest.php b/tests/Integration/Services/CRM/Deal/Service/BatchTest.php
index 83aba611..6e1a97bb 100644
--- a/tests/Integration/Services/CRM/Deal/Service/BatchTest.php
+++ b/tests/Integration/Services/CRM/Deal/Service/BatchTest.php
@@ -24,16 +24,17 @@
*
* @package Bitrix24\SDK\Tests\Integration\Services\CRM\Deals\Service
*/
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Contact\Service\Batch::class)]
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Deal\Service\Batch::class)]
class BatchTest extends TestCase
{
protected Deal $dealService;
/**
- * @testdox Batch list deals
- * @covers \Bitrix24\SDK\Services\CRM\Contact\Service\Batch::list()
* @throws BaseException
* @throws TransportException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch list deals')]
public function testBatchList(): void
{
$dealId = $this->dealService->add(['TITLE' => 'test deal'])->getId();
@@ -42,69 +43,73 @@ public function testBatchList(): void
foreach ($this->dealService->batch->list([], ['ID' => $dealId], ['ID', 'NAME'], 1) as $item) {
$cnt++;
}
+
self::assertGreaterThanOrEqual(1, $cnt);
$this->dealService->delete($dealId);
}
/**
- * @testdox Batch add deals
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\Batch::add()
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch add deals')]
public function testBatchAdd(): void
{
$deals = [];
for ($i = 1; $i < 60; $i++) {
$deals[] = ['TITLE' => 'TITLE-' . $i];
}
+
$cnt = 0;
$dealId = [];
foreach ($this->dealService->batch->add($deals) as $item) {
$cnt++;
$dealId[] = $item->getId();
}
+
self::assertEquals(count($deals), $cnt);
$cnt = 0;
foreach ($this->dealService->batch->delete($dealId) as $cnt => $deleteResult) {
$cnt++;
}
+
self::assertEquals(count($deals), $cnt);
}
/**
- * @testdox Batch delete deals
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\Batch::add()
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch delete deals')]
public function testBatchDelete(): void
{
$deals = [];
for ($i = 1; $i < 60; $i++) {
$deals[] = ['TITLE' => 'TITLE-' . $i];
}
+
$cnt = 0;
$dealId = [];
foreach ($this->dealService->batch->add($deals) as $item) {
$cnt++;
$dealId[] = $item->getId();
}
+
self::assertEquals(count($deals), $cnt);
$cnt = 0;
foreach ($this->dealService->batch->delete($dealId) as $cnt => $deleteResult) {
$cnt++;
}
+
self::assertEquals(count($deals), $cnt);
}
/**
- * @testdox Batch delete deals
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\Batch::update()
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Exception
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch delete deals')]
public function testBatchUpdate(): void
{
// add deals
@@ -112,12 +117,14 @@ public function testBatchUpdate(): void
for ($i = 1; $i < 60; $i++) {
$deals[] = ['TITLE' => 'TITLE-' . $i];
}
+
$cnt = 0;
$dealId = [];
foreach ($this->dealService->batch->add($deals) as $item) {
$cnt++;
$dealId[] = $item->getId();
}
+
self::assertEquals(count($deals), $cnt);
// read deals and prepare update information
@@ -148,7 +155,7 @@ public function testBatchUpdate(): void
$this->assertEquals($resultDeals, $updateResult);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->dealService = Fabric::getServiceBuilder()->getCRMScope()->deal();
}
diff --git a/tests/Integration/Services/CRM/Deal/Service/DealCategoryStageTest.php b/tests/Integration/Services/CRM/Deal/Service/DealCategoryStageTest.php
index cbe5aa81..96ef44a0 100644
--- a/tests/Integration/Services/CRM/Deal/Service/DealCategoryStageTest.php
+++ b/tests/Integration/Services/CRM/Deal/Service/DealCategoryStageTest.php
@@ -29,24 +29,24 @@
class DealCategoryStageTest extends TestCase
{
protected DealCategoryStage $dealCategoryStage;
+
protected DealCategory $dealCategory;
/**
- * @covers DealCategoryStage::list()
* @throws BaseException
* @throws TransportException
*/
public function testList(): void
{
- $newCategoryId = (int)$this->dealCategory->add(['NAME' => 'php unit test'])->getId();
- $res = $this->dealCategoryStage->list($newCategoryId);
- $this::assertGreaterThan(1, count($res->getDealCategoryStages()));
+ $newCategoryId = $this->dealCategory->add(['NAME' => 'php unit test'])->getId();
+ $dealCategoryStagesResult = $this->dealCategoryStage->list($newCategoryId);
+ $this::assertGreaterThan(1, count($dealCategoryStagesResult->getDealCategoryStages()));
}
/**
* @throws InvalidArgumentException
*/
- public function setUp(): void
+ protected function setUp(): void
{
$this->dealCategoryStage = Fabric::getServiceBuilder()->getCRMScope()->dealCategoryStage();
$this->dealCategory = Fabric::getServiceBuilder()->getCRMScope()->dealCategory();
diff --git a/tests/Integration/Services/CRM/Deal/Service/DealCategoryTest.php b/tests/Integration/Services/CRM/Deal/Service/DealCategoryTest.php
index 1e5aea71..0336ca1a 100644
--- a/tests/Integration/Services/CRM/Deal/Service/DealCategoryTest.php
+++ b/tests/Integration/Services/CRM/Deal/Service/DealCategoryTest.php
@@ -24,12 +24,12 @@
*
* @package Bitrix24\SDK\Tests\Integration\Services\CRM\Deals\Service
*/
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::class)]
class DealCategoryTest extends TestCase
{
protected DealCategory $dealCategory;
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::add
*
* @throws BaseException
* @throws TransportException
@@ -52,7 +52,6 @@ public function testAdd(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::delete
* @throws BaseException
* @throws TransportException
*/
@@ -70,7 +69,6 @@ public function testDelete(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::fields
* @throws BaseException
* @throws TransportException
*/
@@ -80,7 +78,6 @@ public function testFields(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::getDefaultCategorySettings
* @throws BaseException
* @throws TransportException
*/
@@ -90,7 +87,6 @@ public function testDealCategoryDefaultGet(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::setDefaultCategorySettings
* @throws BaseException
* @throws TransportException
*/
@@ -103,7 +99,6 @@ public function testDealCategoryDefaultSet(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::get
* @throws BaseException
* @throws TransportException
*/
@@ -115,26 +110,24 @@ public function testDealCategoryGet(): void
];
$newCategoryId = $this->dealCategory->add($newCategory)->getId();
- $category = $this->dealCategory->get($newCategoryId);
+ $dealCategoryResult = $this->dealCategory->get($newCategoryId);
- $this::assertEquals($newCategory['NAME'], $category->getDealCategoryFields()->NAME);
- $this::assertEquals($newCategory['SORT'], $category->getDealCategoryFields()->SORT);
+ $this::assertEquals($newCategory['NAME'], $dealCategoryResult->getDealCategoryFields()->NAME);
+ $this::assertEquals($newCategory['SORT'], $dealCategoryResult->getDealCategoryFields()->SORT);
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::list
*
* @throws BaseException
* @throws TransportException
*/
public function testList(): void
{
- $res = $this->dealCategory->list([], [], [], 0);
- $this::assertGreaterThanOrEqual(1, count($res->getDealCategories()));
+ $dealCategoriesResult = $this->dealCategory->list([], [], [], 0);
+ $this::assertGreaterThanOrEqual(1, count($dealCategoriesResult->getDealCategories()));
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::getStatus
* @throws BaseException
* @throws TransportException
*/
@@ -145,12 +138,11 @@ public function testDealCategoryStatus(): void
'SORT' => 300,
];
$newCategoryId = $this->dealCategory->add($newCategory)->getId();
- $status = $this->dealCategory->getStatus($newCategoryId);
- $this::assertGreaterThan(1, strlen($status->getDealCategoryTypeId()));
+ $dealCategoryStatusResult = $this->dealCategory->getStatus($newCategoryId);
+ $this::assertGreaterThan(1, strlen($dealCategoryStatusResult->getDealCategoryTypeId()));
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealCategory::update
* @throws BaseException
* @throws TransportException
*/
@@ -165,7 +157,7 @@ public function testUpdate(): void
$this::assertEquals('updated', $this->dealCategory->get($newCategoryId)->getDealCategoryFields()->NAME);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->dealCategory = Fabric::getServiceBuilder()->getCRMScope()->dealCategory();
}
diff --git a/tests/Integration/Services/CRM/Deal/Service/DealContactTest.php b/tests/Integration/Services/CRM/Deal/Service/DealContactTest.php
index 3c6da9a7..99561e54 100644
--- a/tests/Integration/Services/CRM/Deal/Service/DealContactTest.php
+++ b/tests/Integration/Services/CRM/Deal/Service/DealContactTest.php
@@ -26,14 +26,16 @@
*
* @package Bitrix24\SDK\Tests\Integration\Services\CRM\Deals\Service
*/
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Deal\Service\DealContact::class)]
class DealContactTest extends TestCase
{
protected Deal $dealService;
+
protected Contact $contactService;
+
private DealContact $dealContactService;
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealContact::add
* @throws BaseException
* @throws TransportException
*/
@@ -51,7 +53,6 @@ public function testAddWithPrimary(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealContact::add
* @throws BaseException
* @throws TransportException
*/
@@ -70,7 +71,6 @@ public function testAddWithSecondary(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealContact::itemsGet
* @throws BaseException
* @throws TransportException
*/
@@ -99,7 +99,6 @@ public function testItemsGet(): void
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealContact::itemsDelete
* @throws BaseException
* @throws TransportException
*/
@@ -128,7 +127,6 @@ public function testItemsDelete(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealContact::itemsSet
* @throws BaseException
* @throws TransportException
*/
@@ -163,7 +161,6 @@ public function testItemsSet(): void
}
/**
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealContact::delete
* @throws BaseException
* @throws TransportException
*/
@@ -189,7 +186,7 @@ public function testDelete(): void
$this::assertCount(1, $this->dealContactService->itemsGet($dealId)->getDealContacts());
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->dealService = Fabric::getServiceBuilder()->getCRMScope()->deal();
$this->dealContactService = Fabric::getServiceBuilder()->getCRMScope()->dealContact();
diff --git a/tests/Integration/Services/CRM/Deal/Service/DealProductRowsTest.php b/tests/Integration/Services/CRM/Deal/Service/DealProductRowsTest.php
index a5b73daa..f1aa8dbd 100644
--- a/tests/Integration/Services/CRM/Deal/Service/DealProductRowsTest.php
+++ b/tests/Integration/Services/CRM/Deal/Service/DealProductRowsTest.php
@@ -29,11 +29,15 @@
use PHPUnit\Framework\TestCase;
use Typhoon\Reflection\TyphoonReflector;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Deal\Service\DealProductRows::class)]
class DealProductRowsTest extends TestCase
{
private Deal $dealService;
+
private DealProductRows $dealProductRowsService;
+
private DecimalMoneyFormatter $decimalMoneyFormatter;
+
private TyphoonReflector $typhoonReflector;
public function testAllSystemPropertiesAnnotated(): void
@@ -51,9 +55,9 @@ public function testAllSystemPropertiesAnnotated(): void
// get response from server with actual keys
$propListFromApi = array_keys($this->dealProductRowsService->get($dealId)->getCoreResponse()->getResponseData()->getResult()['result']['rows'][0]);
// parse keys from phpdoc annotation
- $props = $this->typhoonReflector->reflectClass(DealProductRowItemResult::class)->properties();
+ $collection = $this->typhoonReflector->reflectClass(DealProductRowItemResult::class)->properties();
$propsFromAnnotations = [];
- foreach ($props as $meta) {
+ foreach ($collection as $meta) {
if ($meta->isAnnotated() && !$meta->isNative()) {
$propsFromAnnotations[] = $meta->id->name;
}
@@ -69,7 +73,6 @@ public function testAllSystemPropertiesAnnotated(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\DealProductRows::set
*/
public function testSet(): void
{
@@ -90,9 +93,9 @@ public function testSet(): void
]
)->isSuccess()
);
- $productRows = $this->dealProductRowsService->get($dealId);
- $this->assertCount(1, $productRows->getProductRows());
- $productRow = $productRows->getProductRows()[0];
+ $dealProductRowItemsResult = $this->dealProductRowsService->get($dealId);
+ $this->assertCount(1, $dealProductRowItemsResult->getProductRows());
+ $productRow = $dealProductRowItemsResult->getProductRows()[0];
$this->assertEquals($price, $productRow->PRICE);
$this->assertEquals(DiscountType::monetary, $productRow->DISCOUNT_TYPE_ID);
$this->assertEquals($discount, $productRow->DISCOUNT_SUM);
@@ -118,16 +121,16 @@ public function testGet(): void
]
)->isSuccess()
);
- $productRows = $this->dealProductRowsService->get($dealId);
- $this->assertCount(1, $productRows->getProductRows());
- $productRow = $productRows->getProductRows()[0];
+ $dealProductRowItemsResult = $this->dealProductRowsService->get($dealId);
+ $this->assertCount(1, $dealProductRowItemsResult->getProductRows());
+ $productRow = $dealProductRowItemsResult->getProductRows()[0];
$this->assertEquals($price, $productRow->PRICE);
$this->assertEquals(DiscountType::percentage, $productRow->DISCOUNT_TYPE_ID);
$this->assertEquals($discount, $productRow->DISCOUNT_SUM);
$this->assertEquals(Percentage::zero(), $productRow->DISCOUNT_RATE);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->dealService = Fabric::getServiceBuilder()->getCRMScope()->deal();
$this->dealProductRowsService = Fabric::getServiceBuilder()->getCRMScope()->dealProductRows();
diff --git a/tests/Integration/Services/CRM/Deal/Service/DealTest.php b/tests/Integration/Services/CRM/Deal/Service/DealTest.php
index 35c1bbcd..364a4d54 100644
--- a/tests/Integration/Services/CRM/Deal/Service/DealTest.php
+++ b/tests/Integration/Services/CRM/Deal/Service/DealTest.php
@@ -27,6 +27,7 @@
*
* @package Bitrix24\SDK\Tests\Integration\Services\CRM\Deals\Service
*/
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Deal\Service\Deal::class)]
class DealTest extends TestCase
{
use CustomBitrix24Assertions;
@@ -41,7 +42,6 @@ public function testAllSystemFieldsAnnotated(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers Deal::add
*/
public function testAdd(): void
{
@@ -51,7 +51,6 @@ public function testAdd(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers Deal::delete
*/
public function testDelete(): void
{
@@ -59,7 +58,6 @@ public function testDelete(): void
}
/**
- * @covers Deal::fields
* @throws BaseException
* @throws TransportException
*/
@@ -71,7 +69,6 @@ public function testFields(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers Deal::get
*/
public function testGet(): void
{
@@ -84,7 +81,6 @@ public function testGet(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers Deal::list
*/
public function testList(): void
{
@@ -94,17 +90,16 @@ public function testList(): void
public function testUpdate(): void
{
- $deal = $this->dealService->add(['TITLE' => 'test']);
+ $addedItemResult = $this->dealService->add(['TITLE' => 'test']);
$newTitle = 'test2';
- self::assertTrue($this->dealService->update($deal->getId(), ['TITLE' => $newTitle], [])->isSuccess());
- self::assertEquals($newTitle, $this->dealService->get($deal->getId())->deal()->TITLE);
+ self::assertTrue($this->dealService->update($addedItemResult->getId(), ['TITLE' => $newTitle], [])->isSuccess());
+ self::assertEquals($newTitle, $this->dealService->get($addedItemResult->getId())->deal()->TITLE);
}
/**
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\Deal::countByFilter
*/
public function testCountByFilter(): void
{
@@ -115,10 +110,12 @@ public function testCountByFilter(): void
for ($i = 1; $i <= $newDealsCount; $i++) {
$deals[] = ['TITLE' => 'TITLE-' . $i];
}
+
$cnt = 0;
foreach ($this->dealService->batch->add($deals) as $item) {
$cnt++;
}
+
self::assertEquals(count($deals), $cnt);
$after = $this->dealService->countByFilter();
@@ -126,7 +123,7 @@ public function testCountByFilter(): void
$this->assertEquals($before + $newDealsCount, $after);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->dealService = Fabric::getServiceBuilder()->getCRMScope()->deal();
}
diff --git a/tests/Integration/Services/CRM/Deal/Service/DealUserfieldTest.php b/tests/Integration/Services/CRM/Deal/Service/DealUserfieldTest.php
index 37224839..5e86e380 100644
--- a/tests/Integration/Services/CRM/Deal/Service/DealUserfieldTest.php
+++ b/tests/Integration/Services/CRM/Deal/Service/DealUserfieldTest.php
@@ -64,22 +64,22 @@ public function testDelete(array $newUserFieldItem): void
public function testGet(array $newUserFieldItem): void
{
$newUserfieldId = $this->userfieldService->add($newUserFieldItem)->getId();
- $ufField = $this->userfieldService->get($newUserfieldId)->userfieldItem();
- $this->assertEquals($newUserfieldId, $ufField->ID);
- $this->assertEquals($newUserFieldItem['USER_TYPE_ID'], $ufField->USER_TYPE_ID);
- $this->assertEquals('UF_CRM_' . $newUserFieldItem['FIELD_NAME'], $ufField->FIELD_NAME);
- $this->assertEquals($newUserFieldItem['XML_ID'], $ufField->XML_ID);
+ $dealUserfieldItemResult = $this->userfieldService->get($newUserfieldId)->userfieldItem();
+ $this->assertEquals($newUserfieldId, $dealUserfieldItemResult->ID);
+ $this->assertEquals($newUserFieldItem['USER_TYPE_ID'], $dealUserfieldItemResult->USER_TYPE_ID);
+ $this->assertEquals('UF_CRM_' . $newUserFieldItem['FIELD_NAME'], $dealUserfieldItemResult->FIELD_NAME);
+ $this->assertEquals($newUserFieldItem['XML_ID'], $dealUserfieldItemResult->XML_ID);
}
#[DataProvider('systemUserfieldsDemoDataDataProvider')]
public function testUpdate(array $newUserFieldItem): void
{
$newUserfieldId = $this->userfieldService->add($newUserFieldItem)->getId();
- $ufFieldBefore = $this->userfieldService->get($newUserfieldId)->userfieldItem();
- $this->assertEquals($newUserfieldId, $ufFieldBefore->ID);
- $this->assertEquals($newUserFieldItem['USER_TYPE_ID'], $ufFieldBefore->USER_TYPE_ID);
- $this->assertEquals('UF_CRM_' . $newUserFieldItem['FIELD_NAME'], $ufFieldBefore->FIELD_NAME);
- $this->assertEquals($newUserFieldItem['XML_ID'], $ufFieldBefore->XML_ID);
+ $dealUserfieldItemResult = $this->userfieldService->get($newUserfieldId)->userfieldItem();
+ $this->assertEquals($newUserfieldId, $dealUserfieldItemResult->ID);
+ $this->assertEquals($newUserFieldItem['USER_TYPE_ID'], $dealUserfieldItemResult->USER_TYPE_ID);
+ $this->assertEquals('UF_CRM_' . $newUserFieldItem['FIELD_NAME'], $dealUserfieldItemResult->FIELD_NAME);
+ $this->assertEquals($newUserFieldItem['XML_ID'], $dealUserfieldItemResult->XML_ID);
$this->assertTrue(
$this->userfieldService->update(
@@ -91,16 +91,16 @@ public function testUpdate(array $newUserFieldItem): void
);
$ufFieldAfter = $this->userfieldService->get($newUserfieldId)->userfieldItem();
- $this->assertEquals($ufFieldBefore->EDIT_FORM_LABEL['en'] . 'QQQ', $ufFieldAfter->EDIT_FORM_LABEL['en']);
+ $this->assertEquals($dealUserfieldItemResult->EDIT_FORM_LABEL['en'] . 'QQQ', $ufFieldAfter->EDIT_FORM_LABEL['en']);
}
public function testList(): void
{
- $ufFields = $this->userfieldService->list([], []);
- $this->assertGreaterThanOrEqual(0, count($ufFields->getUserfields()));
+ $dealUserfieldsResult = $this->userfieldService->list([], []);
+ $this->assertGreaterThanOrEqual(0, count($dealUserfieldsResult->getUserfields()));
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->userfieldService = Fabric::getServiceBuilder()->getCRMScope()->dealUserfield();
}
diff --git a/tests/Integration/Services/CRM/Deal/Service/DealUserfieldUseCaseTest.php b/tests/Integration/Services/CRM/Deal/Service/DealUserfieldUseCaseTest.php
index 4e90aa58..03984bde 100644
--- a/tests/Integration/Services/CRM/Deal/Service/DealUserfieldUseCaseTest.php
+++ b/tests/Integration/Services/CRM/Deal/Service/DealUserfieldUseCaseTest.php
@@ -20,23 +20,25 @@
use Bitrix24\SDK\Tests\Integration\Fabric;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Deal\Service\Deal::class)]
class DealUserfieldUseCaseTest extends TestCase
{
protected Deal $dealService;
+
protected DealUserfield $dealUserfieldService;
+
protected int $dealUserfieldId;
/**
* @throws BaseException
* @throws TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\Deal::add
*/
public function testOperationsWithUserfieldFromDealItem(): void
{
// get userfield metadata
- $ufMetadata = $this->dealUserfieldService->get($this->dealUserfieldId)->userfieldItem();
- $ufOriginalFieldName = $ufMetadata->getOriginalFieldName();
- $ufFieldName = $ufMetadata->FIELD_NAME;
+ $dealUserfieldItemResult = $this->dealUserfieldService->get($this->dealUserfieldId)->userfieldItem();
+ $ufOriginalFieldName = $dealUserfieldItemResult->getOriginalFieldName();
+ $ufFieldName = $dealUserfieldItemResult->FIELD_NAME;
// add deal with uf value
$fieldNameValue = 'test field value';
@@ -59,8 +61,8 @@ public function testOperationsWithUserfieldFromDealItem(): void
]
)->isSuccess()
);
- $updatedDeal = $this->dealService->get($deal->ID)->deal();
- $this->assertEquals($newUfValue, $updatedDeal->getUserfieldByFieldName($ufOriginalFieldName));
+ $dealItemResult = $this->dealService->get($deal->ID)->deal();
+ $this->assertEquals($newUfValue, $dealItemResult->getUserfieldByFieldName($ufOriginalFieldName));
}
/**
@@ -69,7 +71,7 @@ public function testOperationsWithUserfieldFromDealItem(): void
* @throws \Bitrix24\SDK\Core\Exceptions\InvalidArgumentException
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
- public function setUp(): void
+ protected function setUp(): void
{
$this->dealService = Fabric::getServiceBuilder()->getCRMScope()->deal();
$this->dealUserfieldService = Fabric::getServiceBuilder()->getCRMScope()->dealUserfield();
@@ -94,7 +96,7 @@ public function setUp(): void
)->getId();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->dealUserfieldService->delete($this->dealUserfieldId);
}
diff --git a/tests/Integration/Services/CRM/Duplicates/Service/DuplicateTest.php b/tests/Integration/Services/CRM/Duplicates/Service/DuplicateTest.php
index 18282c1f..93a87ca4 100644
--- a/tests/Integration/Services/CRM/Duplicates/Service/DuplicateTest.php
+++ b/tests/Integration/Services/CRM/Duplicates/Service/DuplicateTest.php
@@ -20,35 +20,33 @@
use Bitrix24\SDK\Tests\Integration\Fabric;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Duplicates\Service\Duplicate::class)]
class DuplicateTest extends TestCase
{
protected Contact $contactService;
+
protected Duplicate $duplicate;
/**
- * @return void
* @throws BaseException
* @throws TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Duplicates\Service\Duplicate::findByEmail
*/
public function testDuplicatesByEmailNotFound(): void
{
- $res = $this->duplicate->findByEmail([sprintf('%s@gmail.com', time())]);
- $this->assertFalse($res->hasDuplicateContacts());
- $this->assertFalse($res->hasOneContact());
- $this->assertCount(0, $res->getContactsId());
+ $duplicateResult = $this->duplicate->findByEmail([sprintf('%s@gmail.com', time())]);
+ $this->assertFalse($duplicateResult->hasDuplicateContacts());
+ $this->assertFalse($duplicateResult->hasOneContact());
+ $this->assertCount(0, $duplicateResult->getContactsId());
}
/**
- * @return void
* @throws BaseException
* @throws TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Duplicates\Service\Duplicate::findByEmail
*/
public function testDuplicatesByEmailOneItemFound(): void
{
$email = sprintf('%s@gmail.com', time());
- $b24ContactId = $this->contactService->add([
+ $this->contactService->add([
'NAME' => 'Test',
'LAST_NAME' => 'Test',
'EMAIL' => [
@@ -59,28 +57,26 @@ public function testDuplicatesByEmailOneItemFound(): void
]
])->getId();
- $res = $this->duplicate->findByEmail([$email]);
- $this->assertFalse($res->hasDuplicateContacts());
- $this->assertTrue($res->hasOneContact());
- $this->assertCount(1, $res->getContactsId());
+ $duplicateResult = $this->duplicate->findByEmail([$email]);
+ $this->assertFalse($duplicateResult->hasDuplicateContacts());
+ $this->assertTrue($duplicateResult->hasOneContact());
+ $this->assertCount(1, $duplicateResult->getContactsId());
}
/**
- * @return void
* @throws BaseException
* @throws TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Duplicates\Service\Duplicate::findByPhone
*/
public function testDuplicatesByPhoneNotFound(): void
{
- $res = $this->duplicate->findByPhone([sprintf('+1%s', time())]);
- $this->assertFalse($res->hasDuplicateContacts());
- $this->assertFalse($res->hasOneContact());
- $this->assertCount(0, $res->getContactsId());
+ $duplicateResult = $this->duplicate->findByPhone([sprintf('+1%s', time())]);
+ $this->assertFalse($duplicateResult->hasDuplicateContacts());
+ $this->assertFalse($duplicateResult->hasOneContact());
+ $this->assertCount(0, $duplicateResult->getContactsId());
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->contactService = Fabric::getServiceBuilder()->getCRMScope()->contact();
$this->duplicate = Fabric::getServiceBuilder()->getCRMScope()->duplicate();
diff --git a/tests/Integration/Services/CRM/Enum/Service/EnumTest.php b/tests/Integration/Services/CRM/Enum/Service/EnumTest.php
index 0f21ca76..59acf968 100644
--- a/tests/Integration/Services/CRM/Enum/Service/EnumTest.php
+++ b/tests/Integration/Services/CRM/Enum/Service/EnumTest.php
@@ -42,56 +42,57 @@ public function testOwnerType(): void
public function testActivityStatus(): void
{
- foreach ($this->enumService->activityStatus()->getItems() as $item) {
- $this->assertEquals($item->ID, $item->ENUM->value);
+ foreach ($this->enumService->activityStatus()->getItems() as $activityStatusItemResult) {
+ $this->assertEquals($activityStatusItemResult->ID, $activityStatusItemResult->ENUM->value);
}
}
public function testAddressType(): void
{
- foreach ($this->enumService->addressType()->getItems() as $item) {
- $this->assertEquals($item->ID, $item->ENUM->value);
+ foreach ($this->enumService->addressType()->getItems() as $addressTypeFieldItemResult) {
+ $this->assertEquals($addressTypeFieldItemResult->ID, $addressTypeFieldItemResult->ENUM->value);
}
}
+
public function testActivityNotifyType(): void
{
- foreach ($this->enumService->activityNotifyType()->getItems() as $item) {
- $this->assertEquals($item->ID, $item->ENUM->value);
+ foreach ($this->enumService->activityNotifyType()->getItems() as $activityNotifyTypeItemResult) {
+ $this->assertEquals($activityNotifyTypeItemResult->ID, $activityNotifyTypeItemResult->ENUM->value);
}
}
public function testActivityPriority(): void
{
- foreach ($this->enumService->activityPriority()->getItems() as $item) {
- $this->assertEquals($item->ID, $item->ENUM->value);
+ foreach ($this->enumService->activityPriority()->getItems() as $activityPriorityTypeItemResult) {
+ $this->assertEquals($activityPriorityTypeItemResult->ID, $activityPriorityTypeItemResult->ENUM->value);
}
}
public function testActivityDirection(): void
{
- foreach ($this->enumService->activityDirection()->getItems() as $item) {
- $this->assertEquals($item->ID, $item->ENUM->value);
+ foreach ($this->enumService->activityDirection()->getItems() as $activityDirectionItemResult) {
+ $this->assertEquals($activityDirectionItemResult->ID, $activityDirectionItemResult->ENUM->value);
}
}
public function testActivityType(): void
{
- foreach ($this->enumService->activityType()->getItems() as $item) {
- $this->assertEquals($item->ID, $item->ENUM->value);
+ foreach ($this->enumService->activityType()->getItems() as $activityTypeItemResult) {
+ $this->assertEquals($activityTypeItemResult->ID, $activityTypeItemResult->ENUM->value);
}
}
public function testSettingsMode(): void
{
- foreach ($this->enumService->settingsMode()->getItems() as $item) {
- $this->assertEquals($item->ID, $item->ENUM->value);
+ foreach ($this->enumService->settingsMode()->getItems() as $contentTypeItemResult) {
+ $this->assertEquals($contentTypeItemResult->ID, $contentTypeItemResult->ENUM->value);
}
}
public function testContentType(): void
{
- foreach ($this->enumService->contentType()->getItems() as $item) {
- $this->assertEquals($item->ID, $item->ENUM->value);
+ foreach ($this->enumService->contentType()->getItems() as $contentTypeItemResult) {
+ $this->assertEquals($contentTypeItemResult->ID, $contentTypeItemResult->ENUM->value);
}
}
@@ -105,7 +106,7 @@ public function testFields(): void
$this->assertGreaterThan(1, count($this->enumService->fields()->getFieldsDescription()));
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->enumService = Fabric::getServiceBuilder()->getCRMScope()->enum();
}
diff --git a/tests/Integration/Services/CRM/Lead/Service/BatchTest.php b/tests/Integration/Services/CRM/Lead/Service/BatchTest.php
index 23bfd35c..1ba7c716 100644
--- a/tests/Integration/Services/CRM/Lead/Service/BatchTest.php
+++ b/tests/Integration/Services/CRM/Lead/Service/BatchTest.php
@@ -24,16 +24,17 @@
*
* @package Bitrix24\SDK\Tests\Integration\Services\CRM\Lead\Service
*/
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Lead\Service\Batch::class)]
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Deal\Service\Batch::class)]
class BatchTest extends TestCase
{
protected Lead $leadService;
/**
- * @testdox Batch list leads
- * @covers \Bitrix24\SDK\Services\CRM\Lead\Service\Batch::list()
* @throws BaseException
* @throws TransportException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch list leads')]
public function testBatchList(): void
{
$itemId = $this->leadService->add(['TITLE' => 'test lead'])->getId();
@@ -42,64 +43,69 @@ public function testBatchList(): void
foreach ($this->leadService->batch->list([], ['ID' => $itemId], ['ID', 'NAME'], 1) as $item) {
$cnt++;
}
+
self::assertGreaterThanOrEqual(1, $cnt);
$this->leadService->delete($itemId);
}
/**
- * @testdox Batch add lead
- * @covers \Bitrix24\SDK\Services\CRM\Lead\Service\Batch::add()
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch add lead')]
public function testBatchAdd(): void
{
$items = [];
for ($i = 1; $i < 60; $i++) {
$items[] = ['TITLE' => 'TITLE-' . $i];
}
+
$cnt = 0;
$itemId = [];
foreach ($this->leadService->batch->add($items) as $item) {
$cnt++;
$itemId[] = $item->getId();
}
+
self::assertEquals(count($items), $cnt);
$cnt = 0;
foreach ($this->leadService->batch->delete($itemId) as $cnt => $deleteResult) {
$cnt++;
}
+
self::assertEquals(count($items), $cnt);
}
/**
- * @testdox Batch delete deals
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\Batch::add()
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
+ #[\PHPUnit\Framework\Attributes\TestDox('Batch delete deals')]
public function testBatchDelete(): void
{
$deals = [];
for ($i = 1; $i < 60; $i++) {
$deals[] = ['TITLE' => 'TITLE-' . $i];
}
+
$cnt = 0;
$dealId = [];
foreach ($this->leadService->batch->add($deals) as $item) {
$cnt++;
$dealId[] = $item->getId();
}
+
self::assertEquals(count($deals), $cnt);
$cnt = 0;
foreach ($this->leadService->batch->delete($dealId) as $cnt => $deleteResult) {
$cnt++;
}
+
self::assertEquals(count($deals), $cnt);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->leadService = Fabric::getServiceBuilder()->getCRMScope()->lead();
}
diff --git a/tests/Integration/Services/CRM/Lead/Service/LeadTest.php b/tests/Integration/Services/CRM/Lead/Service/LeadTest.php
index 2c356d7a..684a33c8 100644
--- a/tests/Integration/Services/CRM/Lead/Service/LeadTest.php
+++ b/tests/Integration/Services/CRM/Lead/Service/LeadTest.php
@@ -36,6 +36,7 @@
#[CoversMethod(Lead::class,'list')]
#[CoversMethod(Lead::class,'fields')]
#[CoversMethod(Lead::class,'update')]
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Deal\Service\Deal::class)]
class LeadTest extends TestCase
{
use CustomBitrix24Assertions;
@@ -51,9 +52,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation():void
{
$allFields = $this->leadService->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
$systemFields,
@@ -72,7 +71,6 @@ public function testAdd(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers Lead::delete
*/
public function testDelete(): void
{
@@ -80,7 +78,6 @@ public function testDelete(): void
}
/**
- * @covers Lead::fields
* @throws BaseException
* @throws TransportException
*/
@@ -92,7 +89,6 @@ public function testFields(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers Lead::get
*/
public function testGet(): void
{
@@ -105,7 +101,6 @@ public function testGet(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers Lead::list
*/
public function testList(): void
{
@@ -116,21 +111,19 @@ public function testList(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers Lead::update
*/
public function testUpdate(): void
{
- $deal = $this->leadService->add(['TITLE' => 'test lead']);
+ $addedItemResult = $this->leadService->add(['TITLE' => 'test lead']);
$newTitle = 'test2';
- self::assertTrue($this->leadService->update($deal->getId(), ['TITLE' => $newTitle], [])->isSuccess());
- self::assertEquals($newTitle, $this->leadService->get($deal->getId())->lead()->TITLE);
+ self::assertTrue($this->leadService->update($addedItemResult->getId(), ['TITLE' => $newTitle], [])->isSuccess());
+ self::assertEquals($newTitle, $this->leadService->get($addedItemResult->getId())->lead()->TITLE);
}
/**
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Deal\Service\Deal::countByFilter
*/
public function testCountByFilter(): void
{
@@ -141,10 +134,12 @@ public function testCountByFilter(): void
for ($i = 1; $i <= $newItemsCount; $i++) {
$items[] = ['TITLE' => 'TITLE-' . $i];
}
+
$cnt = 0;
foreach ($this->leadService->batch->add($items) as $item) {
$cnt++;
}
+
self::assertEquals(count($items), $cnt);
$after = $this->leadService->countByFilter();
@@ -152,7 +147,7 @@ public function testCountByFilter(): void
$this->assertEquals($before + $newItemsCount, $after);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->leadService = Fabric::getServiceBuilder()->getCRMScope()->lead();
}
diff --git a/tests/Integration/Services/CRM/Products/Service/ProductsTest.php b/tests/Integration/Services/CRM/Products/Service/ProductsTest.php
index 91c548fe..c75de7b2 100644
--- a/tests/Integration/Services/CRM/Products/Service/ProductsTest.php
+++ b/tests/Integration/Services/CRM/Products/Service/ProductsTest.php
@@ -33,6 +33,7 @@
#[CoversMethod(Product::class,'fields')]
#[CoversMethod(Product::class,'update')]
#[CoversMethod(Product::class,'countByFilter')]
+#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\CRM\Product\Service\Product::class)]
class ProductsTest extends TestCase
{
use CustomBitrix24Assertions;
@@ -51,9 +52,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation(): void
{
$allFields = $this->productService->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
$systemFields,
@@ -113,7 +112,6 @@ public function testFields(): void
/**
* @throws BaseException
* @throws TransportException
- * @covers \Bitrix24\SDK\Services\CRM\Product\Service\Product::list
*/
public function testList(): void
{
@@ -127,11 +125,11 @@ public function testList(): void
*/
public function testUpdate(): void
{
- $product = $this->productService->add(['NAME' => 'test']);
+ $addedItemResult = $this->productService->add(['NAME' => 'test']);
$newName = 'test2';
- self::assertTrue($this->productService->update($product->getId(), ['NAME' => $newName])->isSuccess());
- self::assertEquals($newName, $this->productService->get($product->getId())->product()->NAME);
+ self::assertTrue($this->productService->update($addedItemResult->getId(), ['NAME' => $newName])->isSuccess());
+ self::assertEquals($newName, $this->productService->get($addedItemResult->getId())->product()->NAME);
}
/**
@@ -146,6 +144,7 @@ public function testBatchList(): void
foreach ($this->productService->batch->list([], ['>ID' => '1'], ['ID', 'NAME'], 1) as $item) {
$cnt++;
}
+
self::assertGreaterThanOrEqual(1, $cnt);
}
@@ -155,6 +154,7 @@ public function testBatchAdd(): void
for ($i = 1; $i < 60; $i++) {
$products[] = ['NAME' => 'NAME-' . $i];
}
+
$cnt = 0;
foreach ($this->productService->batch->add($products) as $item) {
$cnt++;
@@ -175,6 +175,7 @@ public function testCountByFilter(): void
for ($i = 1; $i <= $newProductsCount; $i++) {
$products[] = ['NAME' => 'NAME-' . $i];
}
+
$cnt = 0;
foreach ($this->productService->batch->add($products) as $item) {
$cnt++;
@@ -186,7 +187,7 @@ public function testCountByFilter(): void
$this->assertEquals($productsCountBefore + $newProductsCount, $productsCountAfter);
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->productService = Fabric::getServiceBuilder()->getCRMScope()->product();
}
diff --git a/tests/Integration/Services/CRM/Requisites/Service/RequisitePresetTest.php b/tests/Integration/Services/CRM/Requisites/Service/RequisitePresetTest.php
index 28ebe38b..f4fc06c5 100644
--- a/tests/Integration/Services/CRM/Requisites/Service/RequisitePresetTest.php
+++ b/tests/Integration/Services/CRM/Requisites/Service/RequisitePresetTest.php
@@ -46,47 +46,43 @@ class RequisitePresetTest extends TestCase
use CustomBitrix24Assertions;
protected ServiceBuilder $sb;
+
private array $createdCompanies = [];
+
private int $requisitePresetId;
+
private int $entityTypeRequisiteId;
+
private int $countryId;
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
$this->requisitePresetId = current(
array_filter(
$this->sb->getCRMScope()->requisitePreset()->list()->getRequisitePresets(),
- function ($item) {
- return str_contains($item->XML_ID, 'COMPANY#');
- }
+ fn($item): bool => str_contains($item->XML_ID, 'COMPANY#')
)
)->ID;
$this->entityTypeRequisiteId = current(
array_filter(
$this->sb->getCRMScope()->enum()->ownerType()->getItems(),
- function ($item) {
- return $item->SYMBOL_CODE === 'REQUISITE';
- }
+ fn($item): bool => $item->SYMBOL_CODE === 'REQUISITE'
)
)->ID;
$this->countryId = current(
array_column(
array_filter(
$this->sb->getCRMScope()->requisitePreset()->countries()->getCountries(),
- function ($item) {
- return $item->CODE === 'US';
- }
+ fn($item): bool => $item->CODE === 'US'
),
'ID'
)
);
}
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->sb->getCRMScope()->company()->batch->delete($this->createdCompanies) as $result) {
- }
}
public function testFields(): void
@@ -106,9 +102,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation(): void
{
$allFields = $this->sb->getCRMScope()->requisitePreset()->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation($systemFields, RequisitePresetItemResult::class);
}
@@ -136,8 +130,8 @@ public function testAdd(): void
'ACTIVE' => 'Y',
]
)->getId();
- $addedItem = $this->sb->getCRMScope()->requisitePreset()->get($tplId)->requisitePreset();
- $this->assertEquals($name, $addedItem->NAME);
+ $requisitePresetItemResult = $this->sb->getCRMScope()->requisitePreset()->get($tplId)->requisitePreset();
+ $this->assertEquals($name, $requisitePresetItemResult->NAME);
$this->assertTrue($this->sb->getCRMScope()->requisitePreset()->delete($tplId)->isSuccess());
}
@@ -156,7 +150,7 @@ public function testDelete(): void
$this->assertTrue($this->sb->getCRMScope()->requisitePreset()->delete($tplId)->isSuccess());
$this->expectException(ItemNotFoundException::class);
- $addedReq = $this->sb->getCRMScope()->requisitePreset()->get($tplId)->requisite();
+ $this->sb->getCRMScope()->requisitePreset()->get($tplId)->requisite();
}
public function testUpdate(): void
diff --git a/tests/Integration/Services/CRM/Requisites/Service/RequisiteTest.php b/tests/Integration/Services/CRM/Requisites/Service/RequisiteTest.php
index 2596b06c..f7a6e5fc 100644
--- a/tests/Integration/Services/CRM/Requisites/Service/RequisiteTest.php
+++ b/tests/Integration/Services/CRM/Requisites/Service/RequisiteTest.php
@@ -42,38 +42,34 @@ class RequisiteTest extends TestCase
use CustomBitrix24Assertions;
protected ServiceBuilder $sb;
+
private array $createdCompanies = [];
+
private array $createdRequisites = [];
+
private int $requisitePresetId;
+
private int $entityTypeIdCompany;
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
$this->requisitePresetId = current(
array_filter(
$this->sb->getCRMScope()->requisitePreset()->list()->getRequisitePresets(),
- function ($item) {
- return str_contains($item->XML_ID, 'COMPANY#');
- }
+ fn($item): bool => str_contains($item->XML_ID, 'COMPANY#')
)
)->ID;
$this->entityTypeIdCompany = current(
array_filter(
$this->sb->getCRMScope()->enum()->ownerType()->getItems(),
- function ($item) {
- return $item->SYMBOL_CODE === 'COMPANY';
- }
+ fn($item): bool => $item->SYMBOL_CODE === 'COMPANY'
)
)->ID;
}
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->sb->getCRMScope()->requisite()->batch->delete($this->createdRequisites) as $result) {
- }
- foreach ($this->sb->getCRMScope()->company()->batch->delete($this->createdCompanies) as $result) {
- }
}
public function testFields(): void
@@ -93,9 +89,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation(): void
{
$allFields = $this->sb->getCRMScope()->requisite()->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation($systemFields, RequisiteItemResult::class);
}
@@ -116,11 +110,11 @@ public function testAdd(): void
)->getId();
$this->createdRequisites[] = $reqId;
- $addedReq = $this->sb->getCRMScope()->requisite()->get($reqId)->requisite();
+ $requisiteItemResult = $this->sb->getCRMScope()->requisite()->get($reqId)->requisite();
- $this->assertEquals($reqName, $addedReq->NAME);
- $this->assertEquals($this->entityTypeIdCompany, $addedReq->ENTITY_TYPE_ID);
- $this->assertEquals($this->requisitePresetId, $addedReq->PRESET_ID);
+ $this->assertEquals($reqName, $requisiteItemResult->NAME);
+ $this->assertEquals($this->entityTypeIdCompany, $requisiteItemResult->ENTITY_TYPE_ID);
+ $this->assertEquals($this->requisitePresetId, $requisiteItemResult->PRESET_ID);
}
public function testDelete(): void
@@ -141,7 +135,7 @@ public function testDelete(): void
$this->assertTrue($this->sb->getCRMScope()->requisite()->delete($reqId)->isSuccess());
$this->expectException(ItemNotFoundException::class);
- $addedReq = $this->sb->getCRMScope()->requisite()->get($reqId)->requisite();
+ $this->sb->getCRMScope()->requisite()->get($reqId)->requisite();
}
public function testList(): void
@@ -185,11 +179,11 @@ public function testUpdate(): void
)->getId();
$this->createdRequisites[] = $reqId;
- $addedReq = $this->sb->getCRMScope()->requisite()->get($reqId)->requisite();
+ $requisiteItemResult = $this->sb->getCRMScope()->requisite()->get($reqId)->requisite();
- $this->assertEquals($reqName, $addedReq->NAME);
- $this->assertEquals($this->entityTypeIdCompany, $addedReq->ENTITY_TYPE_ID);
- $this->assertEquals($this->requisitePresetId, $addedReq->PRESET_ID);
+ $this->assertEquals($reqName, $requisiteItemResult->NAME);
+ $this->assertEquals($this->entityTypeIdCompany, $requisiteItemResult->ENTITY_TYPE_ID);
+ $this->assertEquals($this->requisitePresetId, $requisiteItemResult->PRESET_ID);
$newName = 'new name';
$this->assertTrue($this->sb->getCRMScope()->requisite()->update($reqId, ['NAME' => $newName])->isSuccess());
diff --git a/tests/Integration/Services/CRM/Userfield/Service/UserfieldTest.php b/tests/Integration/Services/CRM/Userfield/Service/UserfieldTest.php
index 2cd3c0fa..0c08afbb 100644
--- a/tests/Integration/Services/CRM/Userfield/Service/UserfieldTest.php
+++ b/tests/Integration/Services/CRM/Userfield/Service/UserfieldTest.php
@@ -60,9 +60,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation(): void
{
$allFields = $this->sb->getCRMScope()->userfield()->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
$systemFields,
@@ -85,8 +83,8 @@ public function testEnumerationFields(): void
*/
public function testSettingsFields(): void
{
- foreach ($this->sb->getCRMScope()->userfield()->types()->getTypes() as $typeItem) {
- self::assertIsArray($this->sb->getCRMScope()->userfield()->settingsFields($typeItem->ID)->getFieldsDescription());
+ foreach ($this->sb->getCRMScope()->userfield()->types()->getTypes() as $userfieldTypeItemResult) {
+ self::assertIsArray($this->sb->getCRMScope()->userfield()->settingsFields($userfieldTypeItemResult->ID)->getFieldsDescription());
}
}
@@ -96,11 +94,11 @@ public function testSettingsFields(): void
*/
public function testTypes(): void
{
- $ufTypes = $this->sb->getCRMScope()->userfield()->types();
- $this->assertGreaterThan(10, $ufTypes->getTypes());
+ $userfieldTypesResult = $this->sb->getCRMScope()->userfield()->types();
+ $this->assertGreaterThan(10, $userfieldTypesResult->getTypes());
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
}
diff --git a/tests/Integration/Services/CRM/VatRates/Service/VatTest.php b/tests/Integration/Services/CRM/VatRates/Service/VatTest.php
index 1accadc5..3cdfca59 100644
--- a/tests/Integration/Services/CRM/VatRates/Service/VatTest.php
+++ b/tests/Integration/Services/CRM/VatRates/Service/VatTest.php
@@ -39,16 +39,17 @@ class VatTest extends TestCase
use CustomBitrix24Assertions;
private ServiceBuilder $sb;
+
private array $addedVatRates = [];
- public function tearDown(): void
+ protected function tearDown(): void
{
- foreach ($this->addedVatRates as $rateId) {
- $this->sb->getCRMScope()->vat()->delete($rateId);
+ foreach ($this->addedVatRates as $addedVatRate) {
+ $this->sb->getCRMScope()->vat()->delete($addedVatRate);
}
}
- public function setUp(): void
+ protected function setUp(): void
{
$this->sb = Fabric::getServiceBuilder();
}
@@ -75,9 +76,7 @@ public function testAllSystemFieldsHasValidTypeAnnotation(): void
{
$allFields = $this->sb->getCRMScope()->vat()->fields()->getFieldsDescription();
$systemFieldsCodes = (new Core\Fields\FieldsFilter())->filterSystemFields(array_keys($allFields));
- $systemFields = array_filter($allFields, static function ($code) use ($systemFieldsCodes) {
- return in_array($code, $systemFieldsCodes, true);
- }, ARRAY_FILTER_USE_KEY);
+ $systemFields = array_filter($allFields, static fn($code): bool => in_array($code, $systemFieldsCodes, true), ARRAY_FILTER_USE_KEY);
$this->assertBitrix24AllResultItemFieldsHasValidTypeAnnotation(
$systemFields,
@@ -88,19 +87,19 @@ public function testAllSystemFieldsHasValidTypeAnnotation(): void
public function testAddAndGet(): void
{
$name = sprintf('test vat name %s', time());
- $rate = new Percentage((string)random_int(1, 99));
+ $percentage = new Percentage((string)random_int(1, 99));
$sort = random_int(1, 500);
$isActive = (bool)random_int(0, 1);
- $newVatRateId = $this->sb->getCRMScope()->vat()->add($name, $rate, $sort, $isActive)->getId();
+ $newVatRateId = $this->sb->getCRMScope()->vat()->add($name, $percentage, $sort, $isActive)->getId();
$this->addedVatRates[] = $newVatRateId;
- $addedRate = $this->sb->getCRMScope()->vat()->get($newVatRateId)->getRate();
+ $vatRateItemResult = $this->sb->getCRMScope()->vat()->get($newVatRateId)->getRate();
- $this->assertEquals($name, $addedRate->NAME);
- $this->assertTrue($rate->equals($addedRate->RATE));
- $this->assertEquals($sort, $addedRate->C_SORT);
- $this->assertEquals($isActive, $addedRate->ACTIVE);
+ $this->assertEquals($name, $vatRateItemResult->NAME);
+ $this->assertTrue($percentage->equals($vatRateItemResult->RATE));
+ $this->assertEquals($sort, $vatRateItemResult->C_SORT);
+ $this->assertEquals($isActive, $vatRateItemResult->ACTIVE);
}
public function testDelete(): void
@@ -124,8 +123,8 @@ public function testUpdateWithoutParameters(): void
public function testUpdate(): void
{
$title = sprintf('test vat name %s', time());
- $rate = new Percentage((string)random_int(20, 30));
- $newVatRateId = $this->sb->getCRMScope()->vat()->add($title, $rate)->getId();
+ $percentage = new Percentage((string)random_int(20, 30));
+ $newVatRateId = $this->sb->getCRMScope()->vat()->add($title, $percentage)->getId();
$this->addedVatRates[] = $newVatRateId;
$newTitle = 'new' . $title;
@@ -136,8 +135,8 @@ public function testUpdate(): void
)->isSuccess()
);
- $updated = $this->sb->getCRMScope()->vat()->get($newVatRateId)->getRate();
- $this->assertEquals($newTitle, $updated->NAME);
+ $vatRateItemResult = $this->sb->getCRMScope()->vat()->get($newVatRateId)->getRate();
+ $this->assertEquals($newTitle, $vatRateItemResult->NAME);
}
public function testList(): void