Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased 1.3.0 – 2025.02.28

### Added

- 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
api-call `app.info` on vendor OAUTH server.
Expand Down Expand Up @@ -74,7 +75,8 @@
for task «[split cli commands](https://github.com/bitrix24/b24phpsdk/issues/92)»
- Changed method signature `Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity::updateApplicationVersion`, for
task «[add bitrixUserId and AuthToken](https://github.com/bitrix24/b24phpsdk/issues/115)»
- Developer experience: webhook example moved to repository [bitrix24/b24sdk-examples](https://github.com/bitrix24/b24sdk-examples/tree/main/php/quick-start/simple/02-work-with-webhook)
- Developer experience: webhook example moved to
repository [bitrix24/b24sdk-examples](https://github.com/bitrix24/b24sdk-examples/tree/main/php/quick-start/simple/02-work-with-webhook)

### Fixed

Expand All @@ -84,15 +86,18 @@
`entity.item.update`, [see details](https://github.com/bitrix24/b24phpsdk/issues/53)
- Fixed errors in `Bitrix24\SDK\Core\ApiClient` for methods with strict arguments
order, [see details](https://github.com/bitrix24/b24phpsdk/issues/101)
- Fixed errors in `ApplicationInstallationRepositoryInterfaceTest` for work with storage [see details](https://github.com/bitrix24/b24phpsdk/issues/123)

### Security

- Added method `Bitrix24\SDK\Services\Main\Service::guardValidateCurrentAuthToken` for validate current auth token with
api-call `app.info` on vendor OAUTH server. You can validate incoming tokens from placements and events

### Removed
- Developer experience: removed example webhook-error-handling, see example [02-work-with-webhook](https://github.com/bitrix24/b24sdk-examples/tree/main/php/quick-start/simple/02-work-with-webhook)


- Developer experience: removed example webhook-error-handling, see
example [02-work-with-webhook](https://github.com/bitrix24/b24sdk-examples/tree/main/php/quick-start/simple/02-work-with-webhook)

### Statistics

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Bitrix24\SDK\Application\Contracts\ApplicationInstallations\Repository\ApplicationInstallationRepositoryInterface;
use Bitrix24\SDK\Application\PortalLicenseFamily;
use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException;
use Bitrix24\SDK\Tests\Application\Contracts\TestRepositoryFlusherInterface;
use Carbon\CarbonImmutable;
use DateInterval;
use DateTime;
Expand Down Expand Up @@ -50,7 +51,7 @@ abstract protected function createApplicationInstallationImplementation(
): ApplicationInstallationInterface;

abstract protected function createApplicationInstallationRepositoryImplementation(): ApplicationInstallationRepositoryInterface;

abstract protected function createRepositoryFlusherImplementation(): TestRepositoryFlusherInterface;
/**
* @throws ApplicationInstallationNotFoundException
*/
Expand All @@ -73,9 +74,11 @@ final public function testSave(
): void
{
$appInstallationRepo = $this->createApplicationInstallationRepositoryImplementation();
$flusher = $this->createRepositoryFlusherImplementation();

$installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId);
$appInstallationRepo->save($installation);
$flusher->flush();

$this->assertEquals($installation, $appInstallationRepo->getById($installation->getId()));
}
Expand All @@ -99,9 +102,11 @@ final public function testGetByIdHappyPath(
): void
{
$appInstallationRepo = $this->createApplicationInstallationRepositoryImplementation();
$flusher = $this->createRepositoryFlusherImplementation();

$installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId);
$appInstallationRepo->save($installation);
$flusher->flush();

$this->assertEquals($installation, $appInstallationRepo->getById($installation->getId()));
}
Expand Down Expand Up @@ -153,6 +158,7 @@ final public function testDeleteWithHappyPath(
): void
{
$appInstallationRepo = $this->createApplicationInstallationRepositoryImplementation();
$flusher = $this->createRepositoryFlusherImplementation();

$installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId);
// successfully finish installation flow
Expand All @@ -162,9 +168,11 @@ final public function testDeleteWithHappyPath(
// we receive ON_APPLICATION_UNINSTALL event and mark application installation as uninstalled: status = deleted
$installation->applicationUninstalled();
$appInstallationRepo->save($installation);
$flusher->flush();

// if we want we can delete application installation from repository
$appInstallationRepo->delete($installation->getId());
$flusher->flush();

$this->expectException(ApplicationInstallationNotFoundException::class);
$appInstallationRepo->getById($installation->getId());
Expand Down Expand Up @@ -217,9 +225,11 @@ final public function testDeleteWithWrongState(
): void
{
$appInstallationRepo = $this->createApplicationInstallationRepositoryImplementation();
$flusher = $this->createRepositoryFlusherImplementation();

$installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId);
$appInstallationRepo->save($installation);
$flusher->flush();

$this->expectException(InvalidArgumentException::class);
$appInstallationRepo->delete($installation->getId());
Expand All @@ -244,9 +254,11 @@ final public function testFindByBitrix24AccountId(
): void
{
$appInstallationRepo = $this->createApplicationInstallationRepositoryImplementation();
$flusher = $this->createRepositoryFlusherImplementation();

$installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId);
$appInstallationRepo->save($installation);
$flusher->flush();

$this->assertEquals([$installation], $appInstallationRepo->findByBitrix24AccountId($bitrix24AccountUuid));
}
Expand Down Expand Up @@ -296,11 +308,13 @@ final public function testFindByExternalId(
): void
{
$appInstallationRepo = $this->createApplicationInstallationRepositoryImplementation();
$flusher = $this->createRepositoryFlusherImplementation();

$installation = $this->createApplicationInstallationImplementation($uuid, $applicationInstallationStatus, $createdAt, $updatedAt, $bitrix24AccountUuid, $applicationStatus, $portalLicenseFamily, $portalUsersCount, $clientContactPersonUuid, $partnerContactPersonUuid, $partnerUuid, $externalId);
$externalId = Uuid::v7()->toRfc4122();
$installation->setExternalId($externalId);
$appInstallationRepo->save($installation);
$flusher->flush();

$this->assertEquals([$installation], $appInstallationRepo->findByExternalId($externalId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Bitrix24\SDK\Application\Contracts\ApplicationInstallations\Repository\ApplicationInstallationRepositoryInterface;
use Bitrix24\SDK\Application\PortalLicenseFamily;
use Bitrix24\SDK\Tests\Application\Contracts\ApplicationInstallations\Repository\ApplicationInstallationRepositoryInterfaceTest;
use Bitrix24\SDK\Tests\Application\Contracts\NullableFlusher;
use Bitrix24\SDK\Tests\Application\Contracts\TestRepositoryFlusherInterface;
use Bitrix24\SDK\Tests\Integration\Fabric;
use Bitrix24\SDK\Tests\Unit\Application\Contracts\ApplicationInstallations\Entity\ApplicationInstallationReferenceEntityImplementation;
use Carbon\CarbonImmutable;
Expand Down Expand Up @@ -47,6 +49,11 @@ protected function createApplicationInstallationImplementation(Uuid $uuid, Appli
);
}

protected function createRepositoryFlusherImplementation(): TestRepositoryFlusherInterface
{
return new NullableFlusher();
}

protected function createApplicationInstallationRepositoryImplementation(): ApplicationInstallationRepositoryInterface
{
return new InMemoryApplicationInstallationRepositoryImplementation(new NullLogger());
Expand Down