From 01b11a8548e69c600e1b3f8ff4eb2f5bf649688e Mon Sep 17 00:00:00 2001 From: mesilov Date: Sun, 22 Jun 2025 19:59:38 +0600 Subject: [PATCH 1/3] Refactor `changeContactPerson` method into `linkContactPerson` and `unlinkContactPerson`. Add corresponding unit tests and events for state changes. Update CHANGELOG to reflect these changes. Signed-off-by: mesilov --- CHANGELOG.md | 3 + .../Docs/ApplicationInstallations.md | 3 +- .../ApplicationInstallationInterface.php | 13 +- ...onInstallationContactPersonLinkedEvent.php | 28 + ...InstallationContactPersonUnlinkedEvent.php | 28 + .../ApplicationInstallationInterfaceTest.php | 1110 +++++++++++------ ...tallationReferenceEntityImplementation.php | 91 +- 7 files changed, 856 insertions(+), 420 deletions(-) create mode 100644 src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonLinkedEvent.php create mode 100644 src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonUnlinkedEvent.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 438bd3cf..b48571a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,9 @@ - added method `isApplicationTokenValid` - changed method `public function applicationInstalled(?string $applicationToken): void` application token now is nullable - changed method `public function applicationUninstalled(?string $applicationToken): void` application token now is nullable + - added method `linkContactPerson(Uuid $uuid)` + - added method `unlinkContactPerson()` + - remove method `changeContactPerson(?Uuid $uuid)` ### Statistics diff --git a/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md b/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md index 9180ca7c..38032518 100644 --- a/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md +++ b/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md @@ -14,7 +14,8 @@ Optional can store links to: | `getUpdatedAt()` | `CarbonImmutable` | Returns date and time of last application installation change | | | `getBitrix24AccountId()` | `Uuid` | Returns Bitrix24 Account id related to this installation | | | `getContactPersonId()` | `?Uuid` | Returns contact person id who installed the application on portal (optional) | | -| `changeContactPerson()` | `void` | Changes client contact person | | +| `linkContactPerson()` | `void` | Link client contact person | | +| `unlinkContactPerson()` | `void` | Unlink client contact person | | | `getBitrix24PartnerContactPersonId()` | `?Uuid` | Returns Bitrix24 partner contact person id (optional) | | | `changeBitrix24PartnerContactPerson()` | `void` | Changes Bitrix24 partner contact person | | | `getBitrix24PartnerId()` | `?Uuid` | Returns Bitrix24 Partner id related to this installation (optional) | | diff --git a/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php b/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php index e1826161..2a6208d3 100644 --- a/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php +++ b/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php @@ -57,11 +57,18 @@ public function getBitrix24AccountId(): Uuid; public function getContactPersonId(): ?Uuid; /** - * Change contact person + * Link contact person * - * Change client contact person if client say he has new responsible for the application + * Link client contact person if a client says they have new responsible for the application */ - public function changeContactPerson(?Uuid $uuid): void; + public function linkContactPerson(Uuid $uuid): void; + + /** + * Unlink contact person + * + * Unlink a client contact person if the client says the contact person has changed + */ + public function unlinkContactPerson(): void; /** * Get Bitrix24 Partner contact person id, optional diff --git a/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonLinkedEvent.php b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonLinkedEvent.php new file mode 100644 index 00000000..3c2c35f3 --- /dev/null +++ b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonLinkedEvent.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\Application\Contracts\ApplicationInstallations\Events; + +use Carbon\CarbonImmutable; +use Symfony\Component\Uid\Uuid; +use Symfony\Contracts\EventDispatcher\Event; + +class ApplicationInstallationContactPersonLinkedEvent extends Event +{ + public function __construct( + public readonly Uuid $applicationInstallationId, + public readonly CarbonImmutable $timestamp, + public readonly Uuid $contactPersonId + ) { + } +} \ No newline at end of file diff --git a/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonUnlinkedEvent.php b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonUnlinkedEvent.php new file mode 100644 index 00000000..e0aab0a6 --- /dev/null +++ b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonUnlinkedEvent.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\Application\Contracts\ApplicationInstallations\Events; + +use Carbon\CarbonImmutable; +use Symfony\Component\Uid\Uuid; +use Symfony\Contracts\EventDispatcher\Event; + +class ApplicationInstallationContactPersonUnlinkedEvent extends Event +{ + public function __construct( + public readonly Uuid $applicationInstallationId, + public readonly CarbonImmutable $timestamp, + public readonly Uuid $unlinkedContactPersonId + ) { + } +} \ No newline at end of file diff --git a/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php b/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php index e1212219..1b80f900 100644 --- a/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php +++ b/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php @@ -34,39 +34,51 @@ abstract class ApplicationInstallationInterfaceTest extends TestCase { abstract protected function createApplicationInstallationImplementation( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId, + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId, ): ApplicationInstallationInterface; #[Test] #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getId method')] final public function testGetId( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($uuid, $installation->getId()); } @@ -74,21 +86,33 @@ final public function testGetId( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getCreatedAt method')] final public function testGetCreatedAt( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($createdAt, $installation->getCreatedAt()); } @@ -96,21 +120,33 @@ final public function testGetCreatedAt( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getCreatedAt method')] final public function testGetUpdatedAt( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($updatedAt, $installation->getUpdatedAt()); } @@ -118,21 +154,33 @@ final public function testGetUpdatedAt( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test testGetBitrix24AccountId method')] final public function testGetBitrix24AccountId( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($bitrix24AccountUuid, $installation->getBitrix24AccountId()); } @@ -140,47 +188,111 @@ final public function testGetBitrix24AccountId( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getContactPersonId method')] final public function testGetContactPersonId( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($clientContactPersonUuid, $installation->getContactPersonId()); } #[Test] #[DataProvider('applicationInstallationDataProvider')] - #[TestDox('test changeContactPerson method')] - final public function testChangeContactPerson( - Uuid $uuid, + #[TestDox('test bindContactPerson method')] + final public function testBindContactPerson( + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); + + $newContactPersonId = Uuid::v7(); + $installation->linkContactPerson($newContactPersonId); + $this->assertEquals($newContactPersonId, $installation->getContactPersonId()); + $this->assertFalse($installation->getCreatedAt()->equalTo($installation->getUpdatedAt())); + } + + #[Test] + #[DataProvider('applicationInstallationDataProvider')] + #[TestDox('test unbindContactPerson method')] + final public function testUnbindContactPerson( + Uuid $uuid, + ApplicationInstallationStatus $applicationInstallationStatus, + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $newContactPersonId = Uuid::v7(); - $installation->changeContactPerson($newContactPersonId); + $installation->linkContactPerson($newContactPersonId); $this->assertEquals($newContactPersonId, $installation->getContactPersonId()); + $installation->unlinkContactPerson(); + $this->assertNull($installation->getContactPersonId()); $this->assertFalse($installation->getCreatedAt()->equalTo($installation->getUpdatedAt())); } @@ -188,21 +300,33 @@ final public function testChangeContactPerson( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getBitrix24PartnerContactPersonId method')] final public function testGetBitrix24PartnerContactPersonId( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($partnerContactPersonUuid, $installation->getBitrix24PartnerContactPersonId()); } @@ -210,21 +334,33 @@ final public function testGetBitrix24PartnerContactPersonId( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test changeBitrix24PartnerContactPerson method')] final public function testChangeBitrix24PartnerContactPerson( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $newBitrix24PartnerContactPersonId = Uuid::v7(); $installation->changeBitrix24PartnerContactPerson($newBitrix24PartnerContactPersonId); @@ -236,21 +372,33 @@ final public function testChangeBitrix24PartnerContactPerson( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test changeBitrix24Partner method')] final public function testChangeBitrix24Partner( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $newBitrix24PartnerUuid = Uuid::v7(); $installation->changeBitrix24Partner($newBitrix24PartnerUuid); @@ -262,21 +410,33 @@ final public function testChangeBitrix24Partner( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getExternalId method')] final public function testGetExternalId( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($externalId, $installation->getExternalId()); } @@ -287,21 +447,33 @@ final public function testGetExternalId( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test setExternalId method')] final public function testSetExternalId( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $newExternalId = Uuid::v7()->toRfc4122(); $installation->setExternalId($newExternalId); @@ -318,21 +490,33 @@ final public function testSetExternalId( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getStatus method')] final public function testGetStatus( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($applicationInstallationStatus, $installation->getStatus()); } @@ -340,21 +524,33 @@ final public function testGetStatus( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test applicationInstalled method')] final public function testApplicationInstalled( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $installation->applicationInstalled(); $this->assertEquals(ApplicationInstallationStatus::active, $installation->getStatus()); $this->assertFalse($installation->getCreatedAt()->equalTo($installation->getUpdatedAt())); @@ -368,21 +564,33 @@ final public function testApplicationInstalled( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test applicationUninstalled method')] final public function testApplicationUninstalled( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $installation->applicationInstalled(); // a few moments later $installation->applicationUninstalled(); @@ -398,21 +606,33 @@ final public function testApplicationUninstalled( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test markAsActive method')] final public function testMarkAsActive( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $installation->applicationInstalled(); // a few moments later @@ -433,21 +653,33 @@ final public function testMarkAsActive( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test markAsBlocked method')] final public function testMarkAsBlocked( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $installation->applicationInstalled(); // a few moments later @@ -463,21 +695,33 @@ final public function testMarkAsBlocked( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getApplicationStatus method')] final public function testGetApplicationStatus( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($applicationStatus, $installation->getApplicationStatus()); } @@ -485,21 +729,33 @@ final public function testGetApplicationStatus( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test changeApplicationStatus method')] final public function testChangeApplicationStatus( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($applicationStatus, $installation->getApplicationStatus()); $newApplicationStatus = ApplicationStatus::trial(); @@ -511,21 +767,33 @@ final public function testChangeApplicationStatus( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getPortalLicenseFamily method')] final public function testGetPortalLicenseFamily( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($portalLicenseFamily, $installation->getPortalLicenseFamily()); } @@ -533,21 +801,33 @@ final public function testGetPortalLicenseFamily( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test changePortalLicenseFamily method')] final public function testChangePortalLicenseFamily( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($portalLicenseFamily, $installation->getPortalLicenseFamily()); $newLicenseFamily = PortalLicenseFamily::en; @@ -559,21 +839,33 @@ final public function testChangePortalLicenseFamily( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getPortalUsersCount method')] final public function testGetPortalUsersCount( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($portalUsersCount, $installation->getPortalUsersCount()); } @@ -581,24 +873,36 @@ final public function testGetPortalUsersCount( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test changePortalUsersCount method')] final public function testChangePortalUsersCount( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($portalUsersCount, $installation->getPortalUsersCount()); - $newUsersCount= 249; + $newUsersCount = 249; $installation->changePortalUsersCount($newUsersCount); $this->assertEquals($newUsersCount, $installation->getPortalUsersCount()); } @@ -607,21 +911,33 @@ final public function testChangePortalUsersCount( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getComment method')] final public function testGetComment( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $comment = 'test block'; $installation->applicationInstalled(); $installation->markAsBlocked($comment); @@ -632,21 +948,33 @@ final public function testGetComment( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getBitrix24PartnerId method')] final public function testGetBitrix24PartnerId( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $this->assertEquals($partnerUuid, $installation->getBitrix24PartnerId()); } @@ -654,21 +982,33 @@ final public function testGetBitrix24PartnerId( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test isApplicationTokenValid method')] final public function testIsApplicationTokenValid( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); // First set a valid token $validToken = 'valid_application_token_' . uniqid('', true); @@ -685,21 +1025,33 @@ final public function testIsApplicationTokenValid( #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test setApplicationToken method')] final public function testSetApplicationToken( - Uuid $uuid, + Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, - CarbonImmutable $createdAt, - CarbonImmutable $updatedAt, - Uuid $bitrix24AccountUuid, - ApplicationStatus $applicationStatus, - PortalLicenseFamily $portalLicenseFamily, - ?int $portalUsersCount, - ?Uuid $clientContactPersonUuid, - ?Uuid $partnerContactPersonUuid, - ?Uuid $partnerUuid, - ?string $externalId - ): void - { - $installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId); + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); $applicationToken = 'application_token_' . uniqid('', true); $installation->setApplicationToken($applicationToken); diff --git a/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php b/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php index 42b42152..795d1618 100644 --- a/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php +++ b/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php @@ -35,20 +35,19 @@ final class ApplicationInstallationReferenceEntityImplementation implements Appl private ?string $applicationToken = null; public function __construct( - private readonly Uuid $id, + private readonly Uuid $id, private ApplicationInstallationStatus $applicationInstallationStatus, - private readonly CarbonImmutable $createdAt, - private CarbonImmutable $updatedAt, - private readonly Uuid $bitrix24AccountUuid, - private ApplicationStatus $applicationStatus, - private PortalLicenseFamily $portalLicenseFamily, - private ?int $portalUsersCount, - private ?Uuid $clientContactPersonUuid, - private ?Uuid $partnerContactPersonUuid, - private ?Uuid $bitrix24PartnerUuid, - private ?string $externalId, - ) - { + private readonly CarbonImmutable $createdAt, + private CarbonImmutable $updatedAt, + private readonly Uuid $bitrix24AccountUuid, + private ApplicationStatus $applicationStatus, + private PortalLicenseFamily $portalLicenseFamily, + private ?int $portalUsersCount, + private ?Uuid $clientContactPersonUuid, + private ?Uuid $partnerContactPersonUuid, + private ?Uuid $bitrix24PartnerUuid, + private ?string $externalId, + ) { } public function getId(): Uuid @@ -108,12 +107,6 @@ public function getContactPersonId(): ?Uuid return $this->clientContactPersonUuid; } - public function changeContactPerson(?Uuid $uuid): void - { - $this->clientContactPersonUuid = $uuid; - $this->updatedAt = new CarbonImmutable(); - } - public function getBitrix24PartnerContactPersonId(): ?Uuid { return $this->partnerContactPersonUuid; @@ -157,10 +150,13 @@ public function setExternalId(?string $externalId): void public function applicationInstalled(?string $applicationToken = null): void { if ($this->applicationInstallationStatus !== ApplicationInstallationStatus::new) { - throw new LogicException(sprintf('application installation must be in status «%s», current state «%s»', - ApplicationInstallationStatus::new->name, - $this->applicationInstallationStatus->name - )); + throw new LogicException( + sprintf( + 'application installation must be in status «%s», current state «%s»', + ApplicationInstallationStatus::new->name, + $this->applicationInstallationStatus->name + ) + ); } if ($applicationToken !== null) { @@ -177,11 +173,14 @@ public function applicationInstalled(?string $applicationToken = null): void public function applicationUninstalled(?string $applicationToken = null): void { if ($this->applicationInstallationStatus === ApplicationInstallationStatus::new || $this->applicationInstallationStatus === ApplicationInstallationStatus::deleted) { - throw new LogicException(sprintf('application installation must be in status «%s» or «%s», current state «%s»', - ApplicationInstallationStatus::active->name, - ApplicationInstallationStatus::blocked->name, - $this->applicationInstallationStatus->name - )); + throw new LogicException( + sprintf( + 'application installation must be in status «%s» or «%s», current state «%s»', + ApplicationInstallationStatus::active->name, + ApplicationInstallationStatus::blocked->name, + $this->applicationInstallationStatus->name + ) + ); } if ($applicationToken !== null) { @@ -195,10 +194,13 @@ public function applicationUninstalled(?string $applicationToken = null): void public function markAsActive(?string $comment): void { if ($this->applicationInstallationStatus !== ApplicationInstallationStatus::blocked) { - throw new LogicException(sprintf('you can activate application install only in state «%s», current state «%s»', - ApplicationInstallationStatus::blocked->name, - $this->applicationInstallationStatus->name - )); + throw new LogicException( + sprintf( + 'you can activate application install only in state «%s», current state «%s»', + ApplicationInstallationStatus::blocked->name, + $this->applicationInstallationStatus->name + ) + ); } $this->applicationInstallationStatus = ApplicationInstallationStatus::active; @@ -209,11 +211,14 @@ public function markAsActive(?string $comment): void public function markAsBlocked(?string $comment): void { if ($this->applicationInstallationStatus === ApplicationInstallationStatus::blocked || $this->applicationInstallationStatus === ApplicationInstallationStatus::deleted) { - throw new LogicException(sprintf('you can block application install only in state «%s» or «%s», current state «%s»', - ApplicationInstallationStatus::new->name, - ApplicationInstallationStatus::active->name, - $this->applicationInstallationStatus->name - )); + throw new LogicException( + sprintf( + 'you can block application install only in state «%s» or «%s», current state «%s»', + ApplicationInstallationStatus::new->name, + ApplicationInstallationStatus::active->name, + $this->applicationInstallationStatus->name + ) + ); } $this->applicationInstallationStatus = ApplicationInstallationStatus::blocked; @@ -257,4 +262,16 @@ public function isApplicationTokenValid(string $applicationToken): bool return $this->applicationToken === $applicationToken; } + + public function linkContactPerson(Uuid $uuid): void + { + $this->clientContactPersonUuid = $uuid; + $this->updatedAt = new CarbonImmutable(); + } + + public function unlinkContactPerson(): void + { + $this->clientContactPersonUuid = null; + $this->updatedAt = new CarbonImmutable(); + } } From cc3fee89730deba8e5981fa39d7c962f2ca1af4d Mon Sep 17 00:00:00 2001 From: mesilov Date: Sun, 22 Jun 2025 20:08:46 +0600 Subject: [PATCH 2/3] Refactor `changeBitrix24PartnerContactPerson` method into `linkBitrix24PartnerContactPerson` and `unlinkBitrix24PartnerContactPerson`. Add corresponding unit tests and update CHANGELOG. Signed-off-by: mesilov --- CHANGELOG.md | 3 ++ .../Docs/ApplicationInstallations.md | 3 +- .../ApplicationInstallationInterface.php | 13 ++++-- .../ApplicationInstallationInterfaceTest.php | 46 +++++++++++++++++-- ...tallationReferenceEntityImplementation.php | 8 +++- 5 files changed, 65 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b48571a7..aa69e5a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,7 +111,10 @@ - changed method `public function applicationUninstalled(?string $applicationToken): void` application token now is nullable - added method `linkContactPerson(Uuid $uuid)` - added method `unlinkContactPerson()` + - added method `linkBitrix24PartnerContactPerson()` + - added method `unlinkBitrix24PartnerContactPerson()` - remove method `changeContactPerson(?Uuid $uuid)` + - remove method `changeBitrix24PartnerContactPerson(?Uuid $uuid)` ### Statistics diff --git a/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md b/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md index 38032518..cb1f55a6 100644 --- a/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md +++ b/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md @@ -17,7 +17,8 @@ Optional can store links to: | `linkContactPerson()` | `void` | Link client contact person | | | `unlinkContactPerson()` | `void` | Unlink client contact person | | | `getBitrix24PartnerContactPersonId()` | `?Uuid` | Returns Bitrix24 partner contact person id (optional) | | -| `changeBitrix24PartnerContactPerson()` | `void` | Changes Bitrix24 partner contact person | | +| `linkBitrix24PartnerContactPerson()` | `void` | Link Bitrix24 partner contact person | | +| `unlinkBitrix24PartnerContactPerson()` | `void` | Unlink Bitrix24 partner contact person | | | `getBitrix24PartnerId()` | `?Uuid` | Returns Bitrix24 Partner id related to this installation (optional) | | | `changeBitrix24Partner()` | `void` | Changes Bitrix24 partner | | | `getExternalId()` | `?string` | Returns external id for application installation | | diff --git a/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php b/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php index 2a6208d3..b236f0c3 100644 --- a/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php +++ b/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php @@ -78,11 +78,18 @@ public function unlinkContactPerson(): void; public function getBitrix24PartnerContactPersonId(): ?Uuid; /** - * Change bitrix24 partner contact person + * Link Bitrix24 partner contact person * - * Change bitrix24 partner contact person if partner say he has new responsible for the application + * Link Bitrix24 partner contact person if partner say he has new responsible for the application */ - public function changeBitrix24PartnerContactPerson(?Uuid $uuid): void; + public function linkBitrix24PartnerContactPerson(Uuid $uuid): void; + + /** + * Unlink Bitrix24 partner contact person + * + * Unlink Bitrix24 partner contacts the person if the partner says they remove this employee + */ + public function unlinkBitrix24PartnerContactPerson(): void; /** * @return Uuid|null get Bitrix24 Partner id related with this installation, optional diff --git a/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php b/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php index 1b80f900..d93a5056 100644 --- a/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php +++ b/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php @@ -332,8 +332,8 @@ final public function testGetBitrix24PartnerContactPersonId( #[Test] #[DataProvider('applicationInstallationDataProvider')] - #[TestDox('test changeBitrix24PartnerContactPerson method')] - final public function testChangeBitrix24PartnerContactPerson( + #[TestDox('test linkBitrix24PartnerContactPerson method')] + final public function testLinkBitrix24PartnerContactPerson( Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, CarbonImmutable $createdAt, @@ -363,11 +363,51 @@ final public function testChangeBitrix24PartnerContactPerson( ); $newBitrix24PartnerContactPersonId = Uuid::v7(); - $installation->changeBitrix24PartnerContactPerson($newBitrix24PartnerContactPersonId); + $installation->linkBitrix24PartnerContactPerson($newBitrix24PartnerContactPersonId); $this->assertEquals($newBitrix24PartnerContactPersonId, $installation->getBitrix24PartnerContactPersonId()); $this->assertFalse($installation->getCreatedAt()->equalTo($installation->getUpdatedAt())); } + #[Test] + #[DataProvider('applicationInstallationDataProvider')] + #[TestDox('test unlinkBitrix24PartnerContactPerson method')] + final public function testUnlinkBitrix24PartnerContactPerson( + Uuid $uuid, + ApplicationInstallationStatus $applicationInstallationStatus, + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); + + $newBitrix24PartnerContactPersonId = Uuid::v7(); + $installation->linkBitrix24PartnerContactPerson($newBitrix24PartnerContactPersonId); + $this->assertEquals($newBitrix24PartnerContactPersonId, $installation->getBitrix24PartnerContactPersonId()); + $installation->unlinkBitrix24PartnerContactPerson(); + $this->assertNull($installation->getBitrix24PartnerContactPersonId()); + $this->assertFalse($installation->getCreatedAt()->equalTo($installation->getUpdatedAt())); + } + #[Test] #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test changeBitrix24Partner method')] diff --git a/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php b/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php index 795d1618..dc0fa226 100644 --- a/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php +++ b/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php @@ -112,12 +112,18 @@ public function getBitrix24PartnerContactPersonId(): ?Uuid return $this->partnerContactPersonUuid; } - public function changeBitrix24PartnerContactPerson(?Uuid $uuid): void + public function linkBitrix24PartnerContactPerson(?Uuid $uuid): void { $this->partnerContactPersonUuid = $uuid; $this->updatedAt = new CarbonImmutable(); } + public function unlinkBitrix24PartnerContactPerson(): void + { + $this->partnerContactPersonUuid = null; + $this->updatedAt = new CarbonImmutable(); + } + public function getBitrix24PartnerId(): ?Uuid { return $this->bitrix24PartnerUuid; From 4c9b381908d6a2e2f14b5e15a109af76bde79948 Mon Sep 17 00:00:00 2001 From: mesilov Date: Sun, 22 Jun 2025 20:20:49 +0600 Subject: [PATCH 3/3] Refactor `changeBitrix24Partner` method into `linkBitrix24Partner` and `unlinkBitrix24Partner`. Add corresponding events, update related documentation, unit tests, and CHANGELOG. Signed-off-by: mesilov --- CHANGELOG.md | 3 ++ .../Docs/ApplicationInstallations.md | 3 +- .../ApplicationInstallationInterface.php | 13 ++++-- ...trix24PartnerContactPersonLinkedEvent.php} | 9 ++-- ...ix24PartnerContactPersonUnlinkedEvent.php} | 9 ++-- ...InstallationBitrix24PartnerLinkedEvent.php | 28 +++++++++++ ...stallationBitrix24PartnerUnlinkedEvent.php | 28 +++++++++++ .../ApplicationInstallationInterfaceTest.php | 46 +++++++++++++++++-- ...tallationReferenceEntityImplementation.php | 8 +++- 9 files changed, 129 insertions(+), 18 deletions(-) rename src/Application/Contracts/ApplicationInstallations/Events/{ApplicationInstallationContactPersonChangedEvent.php => ApplicationInstallationBitrix24PartnerContactPersonLinkedEvent.php} (67%) rename src/Application/Contracts/ApplicationInstallations/Events/{ApplicationInstallationBitrix24PartnerContactPersonChangedEvent.php => ApplicationInstallationBitrix24PartnerContactPersonUnlinkedEvent.php} (63%) create mode 100644 src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerLinkedEvent.php create mode 100644 src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerUnlinkedEvent.php diff --git a/CHANGELOG.md b/CHANGELOG.md index aa69e5a5..3a5eff63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -110,10 +110,13 @@ - changed method `public function applicationInstalled(?string $applicationToken): void` application token now is nullable - changed method `public function applicationUninstalled(?string $applicationToken): void` application token now is nullable - added method `linkContactPerson(Uuid $uuid)` + - added method `linkBitrix24Partner()` + - added method `unlinkBitrix24Partner()` - added method `unlinkContactPerson()` - added method `linkBitrix24PartnerContactPerson()` - added method `unlinkBitrix24PartnerContactPerson()` - remove method `changeContactPerson(?Uuid $uuid)` + - remove method `changeBitrix24Partner(?Uuid $uuid)` - remove method `changeBitrix24PartnerContactPerson(?Uuid $uuid)` ### Statistics diff --git a/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md b/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md index cb1f55a6..54cc136c 100644 --- a/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md +++ b/src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md @@ -20,7 +20,8 @@ Optional can store links to: | `linkBitrix24PartnerContactPerson()` | `void` | Link Bitrix24 partner contact person | | | `unlinkBitrix24PartnerContactPerson()` | `void` | Unlink Bitrix24 partner contact person | | | `getBitrix24PartnerId()` | `?Uuid` | Returns Bitrix24 Partner id related to this installation (optional) | | -| `changeBitrix24Partner()` | `void` | Changes Bitrix24 partner | | +| `linkBitrix24Partner()` | `void` | Link Bitrix24 partner | | +| `unlinkBitrix24Partner()` | `void` | Unlink Bitrix24 partner | | | `getExternalId()` | `?string` | Returns external id for application installation | | | `setExternalId()` | `void` | Sets external id for application installation | `InvalidArgumentException` | | `getStatus()` | `ApplicationInstallationStatus` | Returns application installation status | | diff --git a/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php b/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php index b236f0c3..631b3181 100644 --- a/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php +++ b/src/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterface.php @@ -97,11 +97,18 @@ public function unlinkBitrix24PartnerContactPerson(): void; public function getBitrix24PartnerId(): ?Uuid; /** - * Change bitrix24 partner + * Link Bitrix24 partner * - * Change bitrix24 partner if other partner starts support client portal + * Link Bitrix24 partner who supports this portal */ - public function changeBitrix24Partner(?Uuid $uuid): void; + public function linkBitrix24Partner(Uuid $uuid): void; + + /** + * Unlink Bitrix24 partner + * + * Unlink Bitrix24 partner who stops supporting this portal + */ + public function unlinkBitrix24Partner(): void; /** * Get external id for application installation diff --git a/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonChangedEvent.php b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonLinkedEvent.php similarity index 67% rename from src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonChangedEvent.php rename to src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonLinkedEvent.php index 1b3b7861..80b23f6f 100644 --- a/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationContactPersonChangedEvent.php +++ b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonLinkedEvent.php @@ -17,13 +17,12 @@ use Symfony\Component\Uid\Uuid; use Symfony\Contracts\EventDispatcher\Event; -class ApplicationInstallationContactPersonChangedEvent extends Event +class ApplicationInstallationBitrix24PartnerContactPersonLinkedEvent extends Event { public function __construct( - public readonly Uuid $applicationInstallationId, + public readonly Uuid $applicationInstallationId, public readonly CarbonImmutable $timestamp, - public readonly ?Uuid $previousContactPersonId, - public readonly ?Uuid $currentContactPersonId) - { + public readonly Uuid $bitrix24PartnerContactPersonId + ) { } } \ No newline at end of file diff --git a/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonChangedEvent.php b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonUnlinkedEvent.php similarity index 63% rename from src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonChangedEvent.php rename to src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonUnlinkedEvent.php index 1569a932..2b0f014b 100644 --- a/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonChangedEvent.php +++ b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerContactPersonUnlinkedEvent.php @@ -17,13 +17,12 @@ use Symfony\Component\Uid\Uuid; use Symfony\Contracts\EventDispatcher\Event; -class ApplicationInstallationBitrix24PartnerContactPersonChangedEvent extends Event +class ApplicationInstallationBitrix24PartnerContactPersonUnlinkedEvent extends Event { public function __construct( - public readonly Uuid $applicationInstallationId, + public readonly Uuid $applicationInstallationId, public readonly CarbonImmutable $timestamp, - public readonly ?Uuid $previousBitrix24PartnerContactPersonId, - public readonly ?Uuid $currentBitrix24PartnerContactPersonId) - { + public readonly Uuid $unlinkedBitrix24PartnerContactPersonId + ) { } } \ No newline at end of file diff --git a/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerLinkedEvent.php b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerLinkedEvent.php new file mode 100644 index 00000000..feef2104 --- /dev/null +++ b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerLinkedEvent.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\Application\Contracts\ApplicationInstallations\Events; + +use Carbon\CarbonImmutable; +use Symfony\Component\Uid\Uuid; +use Symfony\Contracts\EventDispatcher\Event; + +class ApplicationInstallationBitrix24PartnerLinkedEvent extends Event +{ + public function __construct( + public readonly Uuid $applicationInstallationId, + public readonly CarbonImmutable $timestamp, + public readonly Uuid $bitrix24PartnerId + ) { + } +} \ No newline at end of file diff --git a/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerUnlinkedEvent.php b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerUnlinkedEvent.php new file mode 100644 index 00000000..5325fb90 --- /dev/null +++ b/src/Application/Contracts/ApplicationInstallations/Events/ApplicationInstallationBitrix24PartnerUnlinkedEvent.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\Application\Contracts\ApplicationInstallations\Events; + +use Carbon\CarbonImmutable; +use Symfony\Component\Uid\Uuid; +use Symfony\Contracts\EventDispatcher\Event; + +class ApplicationInstallationBitrix24PartnerUnlinkedEvent extends Event +{ + public function __construct( + public readonly Uuid $applicationInstallationId, + public readonly CarbonImmutable $timestamp, + public readonly Uuid $unlinkedBitrix24PartnerId + ) { + } +} \ No newline at end of file diff --git a/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php b/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php index d93a5056..48d96ef7 100644 --- a/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php +++ b/tests/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationInterfaceTest.php @@ -410,8 +410,8 @@ final public function testUnlinkBitrix24PartnerContactPerson( #[Test] #[DataProvider('applicationInstallationDataProvider')] - #[TestDox('test changeBitrix24Partner method')] - final public function testChangeBitrix24Partner( + #[TestDox('test linkBitrix24Partner method')] + final public function linkBitrix24Partner( Uuid $uuid, ApplicationInstallationStatus $applicationInstallationStatus, CarbonImmutable $createdAt, @@ -441,11 +441,51 @@ final public function testChangeBitrix24Partner( ); $newBitrix24PartnerUuid = Uuid::v7(); - $installation->changeBitrix24Partner($newBitrix24PartnerUuid); + $installation->linkBitrix24Partner($newBitrix24PartnerUuid); $this->assertEquals($newBitrix24PartnerUuid, $installation->getBitrix24PartnerId()); $this->assertFalse($installation->getCreatedAt()->equalTo($installation->getUpdatedAt())); } + #[Test] + #[DataProvider('applicationInstallationDataProvider')] + #[TestDox('test unlinkBitrix24Partner method')] + final public function unlinkBitrix24Partner( + Uuid $uuid, + ApplicationInstallationStatus $applicationInstallationStatus, + CarbonImmutable $createdAt, + CarbonImmutable $updatedAt, + Uuid $bitrix24AccountUuid, + ApplicationStatus $applicationStatus, + PortalLicenseFamily $portalLicenseFamily, + ?int $portalUsersCount, + ?Uuid $clientContactPersonUuid, + ?Uuid $partnerContactPersonUuid, + ?Uuid $partnerUuid, + ?string $externalId + ): void { + $installation = $this->createApplicationInstallationImplementation( + $uuid, + $applicationInstallationStatus, + $createdAt, + $updatedAt, + $bitrix24AccountUuid, + $applicationStatus, + $portalLicenseFamily, + $portalUsersCount, + $clientContactPersonUuid, + $partnerContactPersonUuid, + $partnerUuid, + $externalId + ); + + $newBitrix24PartnerUuid = Uuid::v7(); + $installation->linkBitrix24Partner($newBitrix24PartnerUuid); + $this->assertEquals($newBitrix24PartnerUuid, $installation->getBitrix24PartnerId()); + $installation->unlinkBitrix24Partner(); + $this->assertNull($installation->getBitrix24PartnerId()); + $this->assertFalse($installation->getCreatedAt()->equalTo($installation->getUpdatedAt())); + } + #[Test] #[DataProvider('applicationInstallationDataProvider')] #[TestDox('test getExternalId method')] diff --git a/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php b/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php index dc0fa226..eaf8a86f 100644 --- a/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php +++ b/tests/Unit/Application/Contracts/ApplicationInstallations/Entity/ApplicationInstallationReferenceEntityImplementation.php @@ -129,12 +129,18 @@ public function getBitrix24PartnerId(): ?Uuid return $this->bitrix24PartnerUuid; } - public function changeBitrix24Partner(?Uuid $uuid): void + public function linkBitrix24Partner(Uuid $uuid): void { $this->bitrix24PartnerUuid = $uuid; $this->updatedAt = new CarbonImmutable(); } + public function unlinkBitrix24Partner(): void + { + $this->bitrix24PartnerUuid = null; + $this->updatedAt = new CarbonImmutable(); + } + public function getExternalId(): ?string { return $this->externalId;