diff --git a/.github/workflows/tests-functional.yml b/.github/workflows/tests-functional.yml
index 47e1a0d..244ba73 100644
--- a/.github/workflows/tests-functional.yml
+++ b/.github/workflows/tests-functional.yml
@@ -68,8 +68,9 @@ jobs:
- name: "Run functional tests"
run: |
php bin/doctrine orm:schema-tool:drop --force
- php bin/doctrine orm:schema-tool:create
+ php bin/doctrine orm:schema-tool:create --dump-sql
php bin/doctrine orm:schema-tool:update --dump-sql
+ php bin/doctrine orm:info
php vendor/bin/phpunit --testsuite=functional_tests --display-warnings --testdox
- name: "is functional tests succeeded"
diff --git a/Makefile b/Makefile
index 0e4c481..c71ff1d 100644
--- a/Makefile
+++ b/Makefile
@@ -101,7 +101,7 @@ test-run-functional: debug-print-env
# Запустить один функциональный тест с дебагером
run-one-functional-test: debug-print-env
- docker-compose run --rm php-cli php -dxdebug.start_with_request=yes vendor/bin/phpunit --filter 'testFindByApplicationToken' tests/Functional/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepositoryTest.php
+ docker-compose run --rm php-cli php -dxdebug.start_with_request=yes vendor/bin/phpunit --filter 'testRenewAuthTokenWithoutBitrix24UserId' tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php
schema-drop:
docker-compose run --rm php-cli php bin/doctrine orm:schema-tool:drop --force
diff --git a/config/cli-config.php b/config/cli-config.php
index 18e2c02..28ff2dc 100644
--- a/config/cli-config.php
+++ b/config/cli-config.php
@@ -13,7 +13,7 @@
[
'driver' => 'pdo_pgsql',
'memory' => true,
- 'dbname' => 'b24phpLibTest',
+ 'dbname' => $_ENV['DATABASE_NAME'],
]);
return DependencyFactory::fromConnection($config, new ExistingConnection($conn));
\ No newline at end of file
diff --git a/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml b/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml
index 0d19a83..c2e57d9 100644
--- a/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml
+++ b/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml
@@ -20,7 +20,7 @@
-
+
diff --git a/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.TestUser.dcm.xml b/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.TestUser.dcm.xml
deleted file mode 100644
index 2d30540..0000000
--- a/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.TestUser.dcm.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Bitrix24Accounts/Entity/Bitrix24Account.php b/src/Bitrix24Accounts/Entity/Bitrix24Account.php
index fc9e417..580d719 100644
--- a/src/Bitrix24Accounts/Entity/Bitrix24Account.php
+++ b/src/Bitrix24Accounts/Entity/Bitrix24Account.php
@@ -32,12 +32,6 @@
class Bitrix24Account implements Bitrix24AccountInterface, AggregateRootEventsEmitterInterface
{
- private string $accessToken;
-
- private string $refreshToken;
-
- private int $expires;
-
private array $applicationScope;
private ?string $applicationToken = null;
@@ -67,17 +61,8 @@ public function __construct(
bool $isEmitBitrix24AccountCreatedEvent = false
) {
$this->authToken = $authToken;
- $this->accessToken = $authToken->accessToken;
- $this->refreshToken = $authToken->refreshToken;
- $this->expires = $authToken->expires;
$this->applicationScope = $applicationScope->getScopeCodes();
-
- if ($isEmitBitrix24AccountCreatedEvent) {
- $this->events[] = new Bitrix24AccountCreatedEvent(
- $this->id,
- $this->createdAt
- );
- }
+ $this->addAccountCreatedEventIfNeeded($isEmitBitrix24AccountCreatedEvent);
}
#[\Override]
@@ -122,7 +107,6 @@ public function getStatus(): Bitrix24AccountStatus
#[\Override]
public function getAuthToken(): AuthToken
{
- $this->authToken = new AuthToken($this->accessToken, $this->refreshToken, $this->expires);
return $this->authToken;
}
@@ -144,9 +128,12 @@ public function renewAuthToken(RenewedAuthToken $renewedAuthToken): void
);
}
- $this->accessToken = $renewedAuthToken->authToken->accessToken;
- $this->refreshToken = $renewedAuthToken->authToken->refreshToken;
- $this->expires = $renewedAuthToken->authToken->expires;
+ $this->authToken = new AuthToken(
+ $renewedAuthToken->authToken->accessToken,
+ $renewedAuthToken->authToken->refreshToken,
+ $renewedAuthToken->authToken->expires
+ );
+
$this->updatedAt = new CarbonImmutable();
}
@@ -370,4 +357,15 @@ public function emitEvents(): array
return $events;
}
+
+ public function addAccountCreatedEventIfNeeded(bool $isEmitCreatedEvent): void
+ {
+ if ($isEmitCreatedEvent) {
+ // Создание события и добавление его в массив событий
+ $this->events[] = new Bitrix24AccountCreatedEvent(
+ $this->id,
+ $this->createdAt
+ );
+ }
+ }
}
diff --git a/src/Bitrix24Accounts/Entity/TestUser.php b/src/Bitrix24Accounts/Entity/TestUser.php
deleted file mode 100644
index 216d1f2..0000000
--- a/src/Bitrix24Accounts/Entity/TestUser.php
+++ /dev/null
@@ -1,44 +0,0 @@
-login;
- }
-
- public function setLogin(string $login): void
- {
- $this->login = $login;
- }
-
- public function getPassword(): string
- {
- return $this->password;
- }
-
- public function setPassword(string $password): void
- {
- $this->password = $password;
- }
-
- public function getId(): int
- {
- return $this->id;
- }
-
- public function setId(int $id): void
- {
- $this->id = $id;
- }
-
-}
\ No newline at end of file
diff --git a/src/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepository.php b/src/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepository.php
index f695276..9cb26d9 100644
--- a/src/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepository.php
+++ b/src/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepository.php
@@ -32,8 +32,6 @@ public function __construct(
#[Override]
public function getById(Uuid $uuid): Bitrix24AccountInterface
{
- // print_r($uuid);
- // exit();
$res = $this->getEntityManager()->getRepository(Bitrix24Account::class)->find($uuid);
if (null === $res) {
throw new Bitrix24AccountNotFoundException(
@@ -106,12 +104,15 @@ public function delete(Uuid $uuid): void
$this->getEntityManager()->remove($bitrix24Account);
}
- public function findAllActive(): array
+ public function findAllActive(int|null $limit = null, int|null $offset = null): array
{
return $this->getEntityManager()->getRepository(Bitrix24Account::class)->findBy(
[
'status' => Bitrix24AccountStatus::active,
- ]
+ ],
+ null,
+ $limit,
+ $offset
);
}
diff --git a/src/Bitrix24Accounts/ReadModel/Fetcher.php b/src/Bitrix24Accounts/ReadModel/Fetcher.php
index 03ed4dc..91b1982 100644
--- a/src/Bitrix24Accounts/ReadModel/Fetcher.php
+++ b/src/Bitrix24Accounts/ReadModel/Fetcher.php
@@ -4,6 +4,7 @@
namespace Bitrix24\Lib\Bitrix24Accounts\ReadModel;
+use Bitrix24\Lib\Bitrix24Accounts\Infrastructure\Doctrine\Bitrix24AccountRepository;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\Pagination\PaginationInterface;
use Knp\Component\Pager\PaginatorInterface;
@@ -21,13 +22,14 @@ public function list(
int $size
): PaginationInterface
{
+
$queryBuilder = $this->em->getConnection()->createQueryBuilder()
->select(
'b24account.id as id',
'b24account.status as status',
'b24account.member_id as member_id',
'b24account.domain_url as domain_url',
- 'b24account.app_version as application_version',
+ 'b24account.application_version as application_version',
'b24account.created_at_utc as created_at',
'b24account.updated_at_utc as updated_at',
)
diff --git a/src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php b/src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php
index fe22b80..7b31f3f 100644
--- a/src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php
+++ b/src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php
@@ -4,6 +4,7 @@
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\InstallFinish;
+use Bitrix24\Lib\Bitrix24Accounts\Entity\Bitrix24Account;
use Bitrix24\Lib\Services\Flusher;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountInterface;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountStatus;
@@ -38,17 +39,37 @@ public function handle(Command $command): void
'b24_user_id' => $command->bitrix24UserId,
]);
+
+ /**
+ * @var AggregateRootEventsEmitterInterface|Bitrix24AccountInterface $targetAccount
+ */
+ $targetAccount = $this->getSingleAccountByMemberId($command->domainUrl, $command->memberId,Bitrix24AccountStatus::new, $command->bitrix24UserId);
+
+ $targetAccount->applicationInstalled($command->applicationToken);
+
+ $this->bitrix24AccountRepository->save($targetAccount);
+ $this->flusher->flush();
+ foreach ($targetAccount->emitEvents() as $event) {
+ $this->eventDispatcher->dispatch($event);
+ }
+
+ $this->logger->debug('Bitrix24Accounts.InstallFinish.Finish');
+ }
+
+ public function getSingleAccountByMemberId(string $domainUrl, string $memberId, Bitrix24AccountStatus $status, int|null $bitrix24UserId): Bitrix24AccountInterface
+ {
$accounts = $this->bitrix24AccountRepository->findByMemberId(
- $command->memberId,
- Bitrix24AccountStatus::new,
- $command->bitrix24UserId
+ $memberId,
+ $status,
+ $bitrix24UserId
);
+
if ([] === $accounts) {
throw new Bitrix24AccountNotFoundException(
sprintf(
'bitrix24 account for domain %s with member id %s in status «new» not found',
- $command->domainUrl,
- $command->memberId
+ $domainUrl,
+ $memberId
)
);
}
@@ -57,24 +78,12 @@ public function handle(Command $command): void
throw new MultipleBitrix24AccountsFoundException(
sprintf(
'multiple bitrix24 accounts for domain %s with member id %s in status «new» found',
- $command->domainUrl,
- $command->memberId
+ $domainUrl,
+ $memberId
)
);
}
- /**
- * @var AggregateRootEventsEmitterInterface|Bitrix24AccountInterface $targetAccount
- */
- $targetAccount = $accounts[0];
- $targetAccount->applicationInstalled($command->applicationToken);
-
- $this->bitrix24AccountRepository->save($targetAccount);
- $this->flusher->flush();
- foreach ($targetAccount->emitEvents() as $event) {
- $this->eventDispatcher->dispatch($event);
- }
-
- $this->logger->debug('Bitrix24Accounts.InstallFinish.Finish');
+ return $accounts[0];
}
}
diff --git a/src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php b/src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php
index 3fe5632..cf00ff6 100644
--- a/src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php
+++ b/src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php
@@ -36,43 +36,48 @@ public function handle(Command $command): void
]);
// get all active bitrix24 accounts
+ $targetAccount = $this->getSingleAccountByMemberId($command->renewedAuthToken->domain, $command->renewedAuthToken->memberId,Bitrix24AccountStatus::active,$command->bitrix24UserId);
+
+ /**
+ * @var Bitrix24AccountInterface|AggregateRootEventsEmitterInterface $targetAccount
+ */
+ $targetAccount->renewAuthToken($command->renewedAuthToken);
+ $this->bitrix24AccountRepository->save($targetAccount);
+ $this->flusher->flush();
+ foreach ($targetAccount->emitEvents() as $event) {
+ $this->eventDispatcher->dispatch($event);
+ }
+
+ $this->logger->debug('Bitrix24Accounts.RenewAuthToken.finish');
+ }
+
+ public function getSingleAccountByMemberId(string $domainUrl, string $memberId, Bitrix24AccountStatus $status, int|null $bitrix24UserId): Bitrix24AccountInterface
+ {
$accounts = $this->bitrix24AccountRepository->findByMemberId(
- $command->renewedAuthToken->memberId,
- Bitrix24AccountStatus::active,
- $command->bitrix24UserId
+ $memberId,
+ $status,
+ $bitrix24UserId
);
- if ($command->bitrix24UserId === null && count($accounts) > 1) {
+ if ($bitrix24UserId === null && count($accounts) > 1) {
throw new MultipleBitrix24AccountsFoundException(
sprintf('updating auth token failure - for domain %s with member id %s found multiple active accounts, try pass bitrix24_user_id in command',
- $command->renewedAuthToken->domain,
- $command->renewedAuthToken->memberId
+ $domainUrl,
+ $memberId
)
);
}
- if ($command->bitrix24UserId !== null && count($accounts) > 1) {
+ if ($bitrix24UserId !== null && count($accounts) > 1) {
throw new MultipleBitrix24AccountsFoundException(
sprintf('updating auth token failure - for domain %s with member id %s and bitrix24 user id %s found multiple active accounts',
- $command->renewedAuthToken->domain,
- $command->renewedAuthToken->memberId,
- $command->bitrix24UserId
+ $domainUrl,
+ $memberId,
+ $bitrix24UserId
)
);
}
- $targetAccount = $accounts[0];
-
- /**
- * @var Bitrix24AccountInterface|AggregateRootEventsEmitterInterface $targetAccount
- */
- $targetAccount->renewAuthToken($command->renewedAuthToken);
- $this->bitrix24AccountRepository->save($targetAccount);
- $this->flusher->flush();
- foreach ($targetAccount->emitEvents() as $event) {
- $this->eventDispatcher->dispatch($event);
- }
-
- $this->logger->debug('Bitrix24Accounts.RenewAuthToken.finish');
+ return $accounts[0];
}
}
\ No newline at end of file
diff --git a/tests/EntityManagerFactory.php b/tests/EntityManagerFactory.php
index 783cae0..2127162 100644
--- a/tests/EntityManagerFactory.php
+++ b/tests/EntityManagerFactory.php
@@ -32,10 +32,6 @@ class EntityManagerFactory
public static function get(): EntityManagerInterface
{
- /* $paths = [
- dirname(__DIR__) . '/src/Bitrix24Accounts/Entity'
- ];*/
-
if (self::$entityManager === null) {
$paths = [
dirname(__DIR__) . '/config/xml'
@@ -74,12 +70,8 @@ public static function get(): EntityManagerInterface
Type::addType('carbon_immutable', CarbonImmutableType::class);
}
- // $configuration = ORMSetup::createAttributeMetadataConfiguration($paths, $isDevMode);
$configuration = ORMSetup::createXMLMetadataConfiguration($paths, $isDevMode);
- // $log = new Logger('name');
- // $log->pushHandler(new StreamHandler('log.txt', Level::Debug));
- // $configuration->setMiddlewares([new \Doctrine\DBAL\Logging\Middleware($log)]);
$connection = DriverManager::getConnection($connectionParams, $configuration);
self::$entityManager = new EntityManager($connection, $configuration);
}
diff --git a/tests/Functional/Bitrix24Accounts/FetcherTest.php b/tests/Functional/Bitrix24Accounts/FetcherTest.php
new file mode 100644
index 0000000..c4e5dc4
--- /dev/null
+++ b/tests/Functional/Bitrix24Accounts/FetcherTest.php
@@ -0,0 +1,68 @@
+entityManager = EntityManagerFactory::get();
+ $eventDispatcher = new EventDispatcher();
+ $requestStack = new RequestStack();
+ $argumentAccess = new ArgumentAccess\RequestArgumentAccess($requestStack);
+ $this->paginator = new Paginator($eventDispatcher, $argumentAccess);
+ $this->fetcher = new Fetcher($this->entityManager, $this->paginator);
+ $this->flusher = new Flusher($this->entityManager);
+ $this->repository = new Bitrix24AccountRepository($this->entityManager);
+ }
+
+ public function testListReturnsPaginatedResults(): void
+ {
+
+ $bitrix24Account = (new Bitrix24AccountBuilder())
+ ->build()
+ ;
+ $this->repository->save($bitrix24Account);
+ $this->flusher->flush();
+
+ // Параметры для теста
+ $page = 1;
+ $size = 10;
+ // Вызов метода list
+ /** @var PaginationInterface $result */
+ $result = $this->fetcher->list($page, $size);
+
+ // Проверка, что результат является экземпляром PaginationInterface
+ $this->assertInstanceOf(PaginationInterface::class, $result);
+
+ // Проверка, что данные возвращаются корректно
+ $this->assertGreaterThan(0, count($result)); // Проверяем, что есть хотя бы одна запись
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Functional/Bitrix24Accounts/UseCase/ChangeDomainUrl/HandlerTest.php b/tests/Functional/Bitrix24Accounts/UseCase/ChangeDomainUrl/HandlerTest.php
index 16e5dd2..9448734 100644
--- a/tests/Functional/Bitrix24Accounts/UseCase/ChangeDomainUrl/HandlerTest.php
+++ b/tests/Functional/Bitrix24Accounts/UseCase/ChangeDomainUrl/HandlerTest.php
@@ -61,13 +61,12 @@ protected function setUp(): void
#[TestDox('Test change domain url with happy path - one account')]
public function testChangeDomainUrlWithHappyPath(): void
{
- $oldDomainUrl = Uuid::v7()->toRfc4122().'-test.bitrix24.com';
- $newDomainUrl = 'new-'.$oldDomainUrl;
+ $oldDomainUrl = Uuid::v7()->toRfc4122() . '-test.bitrix24.com';
+ $newDomainUrl = 'new-' . $oldDomainUrl;
$bitrix24Account = (new Bitrix24AccountBuilder())
->withDomainUrl($oldDomainUrl)
- ->build()
- ;
+ ->build();
$this->repository->save($bitrix24Account);
$this->flusher->flush();
@@ -79,20 +78,33 @@ public function testChangeDomainUrlWithHappyPath(): void
);
$updated = $this->repository->getById($bitrix24Account->getId());
- $this->assertEquals($newDomainUrl, $updated->getDomainUrl());
+ $this->assertEquals(
+ $newDomainUrl,
+ $updated->getDomainUrl(),
+ sprintf(
+ 'New domain url %s must be equals domain url %s after update',
+ $newDomainUrl,
+ $updated->getDomainUrl()
+ )
+ );
$this->assertTrue(in_array(
Bitrix24AccountDomainUrlChangedEvent::class,
- $this->eventDispatcher->getOrphanedEvents()
- ));
+ $this->eventDispatcher->getOrphanedEvents(),
+ ),
+ sprintf(
+ 'Event %s was expected to be in the list of orphan events, but it is missing',
+ Bitrix24AccountDomainUrlChangedEvent::class
+ )
+ );
}
#[Test]
#[TestDox('Test change domain url with happy path - many accounts')]
public function testChangeDomainUrlWithHappyPathForManyAccounts(): void
{
- $oldDomainUrl = Uuid::v7()->toRfc4122().'-test.bitrix24.com';
- $newDomainUrl = 'new-'.$oldDomainUrl;
+ $oldDomainUrl = Uuid::v7()->toRfc4122() . '-test.bitrix24.com';
+ $newDomainUrl = 'new-' . $oldDomainUrl;
$b24MemberId = Uuid::v7()->toRfc4122();
$bitrix24AccountA = (new Bitrix24AccountBuilder())
@@ -133,6 +145,11 @@ public function testChangeDomainUrlWithHappyPathForManyAccounts(): void
$this->assertTrue(in_array(
Bitrix24AccountDomainUrlChangedEvent::class,
$this->eventDispatcher->getOrphanedEvents()
- ));
+ ),
+ sprintf(
+ 'Event %s was expected to be in the list of orphan events, but it is missing',
+ Bitrix24AccountDomainUrlChangedEvent::class
+ )
+ );
}
}
diff --git a/tests/Functional/Bitrix24Accounts/UseCase/InstallStart/HandlerTest.php b/tests/Functional/Bitrix24Accounts/UseCase/InstallStart/HandlerTest.php
index 1ca6599..5461746 100644
--- a/tests/Functional/Bitrix24Accounts/UseCase/InstallStart/HandlerTest.php
+++ b/tests/Functional/Bitrix24Accounts/UseCase/InstallStart/HandlerTest.php
@@ -91,13 +91,67 @@ public function testInstallStartHappyPath(): void
);
$account = $this->repository->getById($accountId);
- $this->assertEquals($b24UserId, $account->getBitrix24UserId());
- $this->assertEquals($isB24UserAdmin, $account->isBitrix24UserAdmin());
- $this->assertEquals($b24MemberId, $account->getMemberId());
- $this->assertEquals($b24DomainUrl, $account->getDomainUrl());
- $this->assertEquals($authToken, $account->getAuthToken());
- $this->assertEquals($appVersion, $account->getApplicationVersion());
- $this->assertEquals($scope, $account->getApplicationScope());
+
+ $this->assertEquals(
+ $b24UserId,
+ $account->getBitrix24UserId(),
+ sprintf(
+ 'Expected the property value to be "%s", but got "%s"',
+ $b24UserId,
+ $account->getBitrix24UserId()
+ )
+ );
+
+ $this->assertEquals(
+ $isB24UserAdmin,
+ $account->isBitrix24UserAdmin(),
+ sprintf(
+ 'Expected the property value to be "%s", but got "%s"',
+ $isB24UserAdmin,
+ $account->isBitrix24UserAdmin()
+ )
+ );
+
+ $this->assertEquals(
+ $b24MemberId,
+ $account->getMemberId(),
+ sprintf(
+ 'Expected the property value to be "%s", but got "%s"',
+ $b24MemberId,
+ $account->getMemberId()
+ )
+ );
+
+ $this->assertEquals(
+ $b24DomainUrl,
+ $account->getDomainUrl(),
+ sprintf(
+ 'Expected the property value to be "%s", but got "%s"',
+ $b24DomainUrl,
+ $account->getDomainUrl()
+ )
+ );
+
+ $this->assertEquals(
+ $authToken,
+ $account->getAuthToken(),
+ sprintf('Object not equals')
+ );
+
+ $this->assertEquals(
+ $appVersion,
+ $account->getApplicationVersion(),
+ sprintf(
+ 'Expected the property value to be "%s", but got "%s"',
+ $appVersion,
+ $account->getApplicationVersion()
+ )
+ );
+ $this->assertEquals(
+ $scope,
+ $account->getApplicationScope(),
+ sprintf('Object not equals')
+ );
$this->assertContains(
Bitrix24AccountCreatedEvent::class,
diff --git a/tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php b/tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php
index 9d9854c..0de29b0 100644
--- a/tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php
+++ b/tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php
@@ -80,16 +80,23 @@ public function testRenewAuthTokenWithoutBitrix24UserId(): void
)
);
$updated = $this->repository->getById($bitrix24Account->getId());
- $this->assertEquals($newAuthToken->accessToken, $updated->getAuthToken()->accessToken);
- $this->assertEquals($newAuthToken->refreshToken, $updated->getAuthToken()->refreshToken);
+ $this->assertEquals(
+ $newAuthToken->accessToken,
+ $updated->getAuthToken()->accessToken,
+ sprintf(
+ 'Expected accessToken %s but got %s',
+ $newAuthToken->accessToken,
+ $updated->getAuthToken()->accessToken
+ )
+ );
- // на продлении токенов событий не бросаем
- $this->assertCount(
- 0,
- $this->eventDispatcher->getOrphanedEvents(),
+ $this->assertEquals(
+ $newAuthToken->refreshToken,
+ $updated->getAuthToken()->refreshToken,
sprintf(
- 'get unexpected domain events count %s',
- count($this->eventDispatcher->getOrphanedEvents()),
+ 'Expected refreshToken %s but got %s',
+ $newAuthToken->refreshToken,
+ $updated->getAuthToken()->refreshToken
)
);
}
diff --git a/tests/Functional/Bitrix24Accounts/UseCase/Uninstall/HandlerTest.php b/tests/Functional/Bitrix24Accounts/UseCase/Uninstall/HandlerTest.php
index 31cddc5..8b6a752 100644
--- a/tests/Functional/Bitrix24Accounts/UseCase/Uninstall/HandlerTest.php
+++ b/tests/Functional/Bitrix24Accounts/UseCase/Uninstall/HandlerTest.php
@@ -69,11 +69,21 @@ public function testUninstallWithHappyPath(): void
$this->handler->handle(new Bitrix24Accounts\UseCase\Uninstall\Command($applicationToken));
$updated = $this->repository->getById($bitrix24Account->getId());
- $this->assertEquals(Bitrix24AccountStatus::deleted, $updated->getStatus());
+ $this->assertEquals(
+ Bitrix24AccountStatus::deleted,
+ $updated->getStatus(),
+ sprintf('Expected status deleted')
+ );
$this->assertTrue(in_array(
Bitrix24AccountApplicationUninstalledEvent::class,
- $this->eventDispatcher->getOrphanedEvents()));
+ $this->eventDispatcher->getOrphanedEvents()
+ ),
+ sprintf(
+ 'Event %s was expected to be in the list of orphan events, but it is missing',
+ Bitrix24AccountApplicationUninstalledEvent::class
+ )
+ );
}
#[Override]