diff --git a/.github/workflows/tests-functional.yml b/.github/workflows/tests-functional.yml index 2227491..9db731a 100644 --- a/.github/workflows/tests-functional.yml +++ b/.github/workflows/tests-functional.yml @@ -39,9 +39,6 @@ jobs: POSTGRES_PASSWORD: b24phpLibTest POSTGRES_DB: b24phpLibTest DATABASE_HOST: localhost - DATABASE_USER: b24phpLibTest - DATABASE_PASSWORD: b24phpLibTest - DATABASE_NAME: b24phpLibTest steps: - name: "Checkout code" diff --git a/Makefile b/Makefile index 28e6bab..cddd366 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,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 'testChangeDomainUrlWithHappyPath' tests/Functional/Bitrix24Accounts/UseCase/ChangeDomainUrl/HandlerTest.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/src/Bitrix24Accounts/ReadModel/Fetcher.php b/src/Bitrix24Accounts/ReadModel/Bitrix24AccountFetcher.php similarity index 97% rename from src/Bitrix24Accounts/ReadModel/Fetcher.php rename to src/Bitrix24Accounts/ReadModel/Bitrix24AccountFetcher.php index ac7676c..b2a51c5 100644 --- a/src/Bitrix24Accounts/ReadModel/Fetcher.php +++ b/src/Bitrix24Accounts/ReadModel/Bitrix24AccountFetcher.php @@ -7,7 +7,7 @@ use Doctrine\ORM\EntityManagerInterface; use Knp\Component\Pager\Pagination\PaginationInterface; use Knp\Component\Pager\PaginatorInterface; -class Fetcher +class Bitrix24AccountFetcher { public function __construct( diff --git a/src/Bitrix24Accounts/UseCase/ChangeDomainUrl/Handler.php b/src/Bitrix24Accounts/UseCase/ChangeDomainUrl/Handler.php index a02af34..53246d3 100644 --- a/src/Bitrix24Accounts/UseCase/ChangeDomainUrl/Handler.php +++ b/src/Bitrix24Accounts/UseCase/ChangeDomainUrl/Handler.php @@ -19,7 +19,7 @@ public function __construct( public function handle(Command $command): void { - $this->logger->debug('Bitrix24Accounts.ChangeDomainUrl.start', [ + $this->logger->info('Bitrix24Accounts.ChangeDomainUrl.start', [ 'b24_domain_url_old' => $command->oldDomainUrlHost, 'b24_domain_url_new' => $command->newDomainUrlHost, ]); @@ -28,16 +28,15 @@ public function handle(Command $command): void foreach ($accounts as $account) { $account->changeDomainUrl($command->newDomainUrlHost); $this->bitrix24AccountRepository->save($account); - // $this->flusher->flush(); - // todo выяснить почему он не видит объединение типов - // @phpstan-ignore-next-line - /* foreach ($account->emitEvents() as $event) { - $this->eventDispatcher->dispatch($event); - }*/ - } + + //используется как оператор распаковки (splat operator) для передачи массива как отдельных аргументов: $this->flusher->flush(...$accounts); - $this->logger->debug('Bitrix24Accounts.ChangeDomainUrl.Finish'); + $this->logger->info('Bitrix24Accounts.ChangeDomainUrl.Finish', + [ + 'b24_domain_url_old' => $command->oldDomainUrlHost, + 'b24_domain_url_new' => $command->newDomainUrlHost, + ]); } } diff --git a/src/Bitrix24Accounts/UseCase/InstallFinish/Command.php b/src/Bitrix24Accounts/UseCase/InstallFinish/Command.php index b866b25..74ce9c4 100644 --- a/src/Bitrix24Accounts/UseCase/InstallFinish/Command.php +++ b/src/Bitrix24Accounts/UseCase/InstallFinish/Command.php @@ -4,6 +4,7 @@ namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\InstallFinish; +use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException; readonly class Command { public function __construct( @@ -11,5 +12,22 @@ public function __construct( public string $memberId, public string $domainUrl, public ?int $bitrix24UserId, - ) {} + ) { + $this->validate(); + } + + private function validate(): void + { + if (empty($this->applicationToken)) { + throw new InvalidArgumentException('Application token cannot be empty.'); + } + + if (empty($this->memberId)) { + throw new InvalidArgumentException('Member ID cannot be empty.'); + } + + if (empty($this->domainUrl)) { + throw new InvalidArgumentException('Domain URL cannot be empty.'); + } + } } diff --git a/src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php b/src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php index 35e9916..bd8d043 100644 --- a/src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php +++ b/src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php @@ -18,7 +18,6 @@ readonly class Handler { public function __construct( - private EventDispatcherInterface $eventDispatcher, private Bitrix24AccountRepositoryInterface $bitrix24AccountRepository, private Flusher $flusher, private LoggerInterface $logger @@ -31,27 +30,28 @@ public function __construct( */ public function handle(Command $command): void { - $this->logger->debug('Bitrix24Accounts.InstallFinish.start', [ + $this->logger->info('Bitrix24Accounts.InstallFinish.start', [ 'b24_domain_url' => $command->domainUrl, 'b24_member_id' => $command->memberId, 'b24_application_id' => $command->applicationToken, 'b24_user_id' => $command->bitrix24UserId, ]); - /** - * @var AggregateRootEventsEmitterInterface|Bitrix24AccountInterface $bitrix24Account - */ $bitrix24Account = $this->getSingleAccountByMemberId($command->domainUrl, $command->memberId, Bitrix24AccountStatus::new, $command->bitrix24UserId); $bitrix24Account->applicationInstalled($command->applicationToken); $this->bitrix24AccountRepository->save($bitrix24Account); - $this->flusher->flush(); - foreach ($bitrix24Account->emitEvents() as $event) { - $this->eventDispatcher->dispatch($event); - } + $this->flusher->flush($bitrix24Account); + - $this->logger->debug('Bitrix24Accounts.InstallFinish.Finish'); + $this->logger->info('Bitrix24Accounts.InstallFinish.Finish', + [ + 'b24_domain_url' => $command->domainUrl, + 'b24_member_id' => $command->memberId, + 'b24_application_id' => $command->applicationToken, + 'b24_user_id' => $command->bitrix24UserId, + ]); } public function getSingleAccountByMemberId(string $domainUrl, string $memberId, Bitrix24AccountStatus $bitrix24AccountStatus, ?int $bitrix24UserId): Bitrix24AccountInterface diff --git a/src/Bitrix24Accounts/UseCase/InstallStart/Handler.php b/src/Bitrix24Accounts/UseCase/InstallStart/Handler.php index a401b03..b9d1f17 100644 --- a/src/Bitrix24Accounts/UseCase/InstallStart/Handler.php +++ b/src/Bitrix24Accounts/UseCase/InstallStart/Handler.php @@ -22,7 +22,7 @@ public function __construct( public function handle(Command $command): void { - $this->logger->debug('Bitrix24Accounts.InstallStart.start', [ + $this->logger->info('Bitrix24Accounts.InstallStart.start', [ 'id' => $command->uuid->toRfc4122(), 'domain_url' => $command->domainUrl, 'member_id' => $command->memberId, @@ -44,12 +44,12 @@ public function handle(Command $command): void ); $this->bitrix24AccountRepository->save($bitrix24Account); $this->flusher->flush($bitrix24Account); - // $this->flusher->flush(); - /*foreach ($bitrix24Account->emitEvents() as $event) { - $this->eventDispatcher->dispatch($event); - }*/ - - $this->logger->debug('Bitrix24Accounts.InstallStart.Finish'); + $this->logger->info('Bitrix24Accounts.InstallStart.Finish', + [ + 'id' => $command->uuid->toRfc4122(), + 'domain_url' => $command->domainUrl, + 'member_id' => $command->memberId, + ]); } } diff --git a/src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php b/src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php index 13d408c..fdfb12d 100644 --- a/src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php +++ b/src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php @@ -11,7 +11,6 @@ use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Repository\Bitrix24AccountRepositoryInterface; use Bitrix24\SDK\Application\Contracts\Events\AggregateRootEventsEmitterInterface; use Psr\Log\LoggerInterface; -use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; readonly class Handler { @@ -26,7 +25,7 @@ public function __construct( */ public function handle(Command $command): void { - $this->logger->debug('Bitrix24Accounts.RenewAuthToken.start', [ + $this->logger->info('Bitrix24Accounts.RenewAuthToken.start', [ 'domain_url' => $command->renewedAuthToken->domain, 'member_id' => $command->renewedAuthToken->memberId, 'bitrix24_user_id' => $command->bitrix24UserId, @@ -39,17 +38,19 @@ public function handle(Command $command): void $command->bitrix24UserId ); - // Bitrix24Account extends AggregateRoot and implement AggregateRootEventsEmitterInterface - /** @var AggregateRootEventsEmitterInterface|Bitrix24AccountInterface $bitrix24Account */ + $bitrix24Account->renewAuthToken($command->renewedAuthToken); $this->bitrix24AccountRepository->save($bitrix24Account); + $this->flusher->flush($bitrix24Account); - /* foreach ($bitrix24Account->emitEvents() as $event) { - $this->eventDispatcher->dispatch($event); - }*/ - $this->logger->debug('Bitrix24Accounts.RenewAuthToken.finish'); + $this->logger->info('Bitrix24Accounts.RenewAuthToken.finish', + [ + 'domain_url' => $command->renewedAuthToken->domain, + 'member_id' => $command->renewedAuthToken->memberId, + 'bitrix24_user_id' => $command->bitrix24UserId, + ]); } /** diff --git a/src/Bitrix24Accounts/UseCase/Uninstall/Handler.php b/src/Bitrix24Accounts/UseCase/Uninstall/Handler.php index f30e983..8c5ea1f 100644 --- a/src/Bitrix24Accounts/UseCase/Uninstall/Handler.php +++ b/src/Bitrix24Accounts/UseCase/Uninstall/Handler.php @@ -22,27 +22,26 @@ public function __construct( ) {} /** - * @throws Bitrix24AccountNotFoundException * @throws InvalidArgumentException */ public function handle(Command $command): void { - $this->logger->debug('Bitrix24Accounts.Uninstall.start', [ + $this->logger->info('Bitrix24Accounts.Uninstall.start', [ 'b24_application_token' => $command->applicationToken, ]); - /** - * @var AggregateRootEventsEmitterInterface[]|Bitrix24AccountInterface[] $accounts - */ $accounts = $this->bitrix24AccountRepository->findByApplicationToken($command->applicationToken); - + $accountsCount = count($accounts); foreach ($accounts as $account) { $account->applicationUninstalled($command->applicationToken); $this->bitrix24AccountRepository->save($account); } $this->flusher->flush(...$accounts); - - $this->logger->debug('Bitrix24Accounts.Uninstall.Finish'); + $this->logger->info('Bitrix24Accounts.Uninstall.Finish', + [ + 'accountsCount' => $accountsCount, + 'b24_application_token' => $command->applicationToken, + ]); } } diff --git a/src/Services/Flusher.php b/src/Services/Flusher.php index ec9af9e..9b8b8ab 100644 --- a/src/Services/Flusher.php +++ b/src/Services/Flusher.php @@ -6,25 +6,24 @@ use Bitrix24\Lib\AggregateRoot; +use Bitrix24\SDK\Application\Contracts\Events\AggregateRootEventsEmitterInterface; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class Flusher { private $em; private $eventDispatcher; - public function __construct(EntityManagerInterface $em,EventDispatcher $eventDispatcher) { + public function __construct(EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher) { $this->em = $em; $this->eventDispatcher = $eventDispatcher; } - public function flush(AggregateRoot ...$roots): void + public function flush(AggregateRootEventsEmitterInterface ...$roots): void { $this->em->flush(); - foreach ($roots as $root) { $events = $root->emitEvents(); foreach ($events as $event) { - var_dump($event); $this->eventDispatcher->dispatch($event); } } diff --git a/tests/Functional/Bitrix24Accounts/FetcherTest.php b/tests/Functional/Bitrix24Accounts/Bitrix24AccountsFetcherTest.php similarity index 64% rename from tests/Functional/Bitrix24Accounts/FetcherTest.php rename to tests/Functional/Bitrix24Accounts/Bitrix24AccountsFetcherTest.php index 46698c9..2b4ad05 100644 --- a/tests/Functional/Bitrix24Accounts/FetcherTest.php +++ b/tests/Functional/Bitrix24Accounts/Bitrix24AccountsFetcherTest.php @@ -5,7 +5,7 @@ namespace Bitrix24\Lib\Tests\Functional\Bitrix24Accounts; use Bitrix24\Lib\Bitrix24Accounts\Infrastructure\Doctrine\Bitrix24AccountRepository; -use Bitrix24\Lib\Bitrix24Accounts\ReadModel\Fetcher; +use Bitrix24\Lib\Bitrix24Accounts\ReadModel\Bitrix24AccountFetcher; use Bitrix24\Lib\Services\Flusher; use Bitrix24\Lib\Tests\EntityManagerFactory; use Knp\Component\Pager\Event\Subscriber\Paginate\PaginationSubscriber; @@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\RequestStack; use Knp\Component\Pager\ArgumentAccess\RequestArgumentAccess; -class FetcherTest extends TestCase +class Bitrix24AccountsFetcherTest extends TestCase { private EntityManagerInterface $entityManager; @@ -29,7 +29,7 @@ class FetcherTest extends TestCase private Bitrix24AccountRepositoryInterface $repository; - private Fetcher $fetcher; + private Bitrix24AccountFetcher $fetcher; private Flusher $flusher; @@ -42,7 +42,7 @@ protected function setUp(): void $eventDispatcher->addSubscriber(new SortableSubscriber()); $requestArgumentAccess = new RequestArgumentAccess(new RequestStack()); $this->paginator = new Paginator($eventDispatcher, $requestArgumentAccess); - $this->fetcher = new Fetcher($this->entityManager, $this->paginator); + $this->fetcher = new Bitrix24AccountFetcher($this->entityManager, $this->paginator); $this->flusher = new Flusher($this->entityManager,$eventDispatcher); $this->repository = new Bitrix24AccountRepository($this->entityManager); } @@ -67,4 +67,36 @@ public function testListReturnsPaginatedResults(): void $this->assertGreaterThan(0, $pagination->count()); // Проверяем, что есть хотя бы одна запись } + public function testColumnNamesInBitrix24Accounts(): void + { + // Ожидаемые названия столбцов + $expectedColumns = [ + 'id', + 'status', + 'b24_user_id', + 'is_b24_user_admin', + 'member_id', + 'domain_url', + 'application_token', + 'created_at_utc', + 'updated_at_utc', + 'application_version', + 'authtoken_access_token', + 'authtoken_refresh_token', + 'authtoken_expires', + 'authtoken_expires_in', + 'applicationscope_current_scope' + ]; + + // Получение фактических названий столбцов из базы данных + $connection = $this->entityManager->getConnection(); + $schemaManager = $connection->createSchemaManager(); + $columns = $schemaManager->listTableColumns('bitrix24account'); + $actualColumns = array_keys($columns); + + foreach ($expectedColumns as $column) { + $this->assertContains($column, $actualColumns, "Column '$column' is missing in table 'bitrix24account'."); + } + } + } \ No newline at end of file diff --git a/tests/Functional/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepositoryTest.php b/tests/Functional/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepositoryTest.php index cf6e12b..177ce15 100644 --- a/tests/Functional/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepositoryTest.php +++ b/tests/Functional/Bitrix24Accounts/Infrastructure/Doctrine/Bitrix24AccountRepositoryTest.php @@ -28,6 +28,7 @@ use Carbon\CarbonImmutable; use Override; use PHPUnit\Framework\Attributes\CoversClass; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Uid\Uuid; #[CoversClass(Bitrix24AccountRepository::class)] @@ -73,6 +74,8 @@ protected function createBitrix24AccountRepositoryImplementation(): Bitrix24Acco #[Override] protected function createRepositoryFlusherImplementation(): TestRepositoryFlusherInterface { - return new FlusherDecorator(new Flusher(EntityManagerFactory::get())); + $entityManager = EntityManagerFactory::get(); + $eventDispatcher = new EventDispatcher(); + return new FlusherDecorator(new Flusher($entityManager, $eventDispatcher)); } } \ 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 b724574..784aad2 100644 --- a/tests/Functional/Bitrix24Accounts/UseCase/ChangeDomainUrl/HandlerTest.php +++ b/tests/Functional/Bitrix24Accounts/UseCase/ChangeDomainUrl/HandlerTest.php @@ -26,10 +26,9 @@ use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; -use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Uid\Uuid; - +use Symfony\Component\EventDispatcher\EventDispatcher; /** * @internal */ @@ -50,8 +49,8 @@ protected function setUp(): void $entityManager = EntityManagerFactory::get(); $eventDispatcher = new EventDispatcher(); $this->repository = new Bitrix24AccountRepository($entityManager); - $this->flusher = new Flusher($entityManager,$eventDispatcher); $this->eventDispatcher = new TraceableEventDispatcher($eventDispatcher, new Stopwatch()); + $this->flusher = new Flusher($entityManager,$this->eventDispatcher); $this->handler = new Bitrix24Accounts\UseCase\ChangeDomainUrl\Handler( $this->repository, $this->flusher, diff --git a/tests/Functional/Bitrix24Accounts/UseCase/InstallFinish/CommandTest.php b/tests/Functional/Bitrix24Accounts/UseCase/InstallFinish/CommandTest.php new file mode 100644 index 0000000..9eb2f62 --- /dev/null +++ b/tests/Functional/Bitrix24Accounts/UseCase/InstallFinish/CommandTest.php @@ -0,0 +1,123 @@ +withStatus(Bitrix24AccountStatus::new) + ->build(); + + $this->repository->save($bitrix24Account); + $this->flusher->flush(); + + $applicationToken = Uuid::v7()->toRfc4122(); + $command = new Command( + $applicationToken, + $bitrix24Account->getMemberId(), + $bitrix24Account->getDomainUrl(), + $bitrix24Account->getBitrix24UserId() + ); + $this->assertInstanceOf(Command::class, $command); + } + + public function testEmptyApplicationToken(): void + { + $bitrix24Account = (new Bitrix24AccountBuilder()) + ->withStatus(Bitrix24AccountStatus::new) + ->build(); + + $this->repository->save($bitrix24Account); + $this->flusher->flush(); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Application token cannot be empty.'); + + new Command('', + $bitrix24Account->getMemberId(), + $bitrix24Account->getDomainUrl(), + $bitrix24Account->getBitrix24UserId() + ); + } + + + public function testEmptyMemberId(): void + { + $bitrix24Account = (new Bitrix24AccountBuilder()) + ->withStatus(Bitrix24AccountStatus::new) + ->build(); + + $this->repository->save($bitrix24Account); + $this->flusher->flush(); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Member ID cannot be empty.'); + + $applicationToken = Uuid::v7()->toRfc4122(); + new Command($applicationToken, + '', + $bitrix24Account->getDomainUrl(), + $bitrix24Account->getBitrix24UserId() + ); + } + + public function testEmptyDomainUrl(): void + { + $bitrix24Account = (new Bitrix24AccountBuilder()) + ->withStatus(Bitrix24AccountStatus::new) + ->build(); + + $this->repository->save($bitrix24Account); + $this->flusher->flush(); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Domain URL cannot be empty.'); + + $applicationToken = Uuid::v7()->toRfc4122(); + new Command($applicationToken, + $bitrix24Account->getMemberId(), + '', + $bitrix24Account->getBitrix24UserId() + ); + } + + protected function setUp(): void + { + $entityManager = EntityManagerFactory::get(); + $eventDispatcher = new EventDispatcher(); + $this->eventDispatcher = new TraceableEventDispatcher($eventDispatcher, new Stopwatch()); + $this->repository = new Bitrix24AccountRepository($entityManager); + $this->flusher = new Flusher($entityManager,$this->eventDispatcher); + } +} \ No newline at end of file diff --git a/tests/Functional/Bitrix24Accounts/UseCase/InstallFinish/HandlerTest.php b/tests/Functional/Bitrix24Accounts/UseCase/InstallFinish/HandlerTest.php index 2ea70ec..287db48 100644 --- a/tests/Functional/Bitrix24Accounts/UseCase/InstallFinish/HandlerTest.php +++ b/tests/Functional/Bitrix24Accounts/UseCase/InstallFinish/HandlerTest.php @@ -85,11 +85,11 @@ protected function setUp(): void { $entityManager = EntityManagerFactory::get(); $eventDispatcher = new EventDispatcher(); - $this->repository = new Bitrix24AccountRepository($entityManager); - $this->flusher = new Flusher($entityManager,$eventDispatcher); $this->eventDispatcher = new TraceableEventDispatcher($eventDispatcher, new Stopwatch()); + $this->repository = new Bitrix24AccountRepository($entityManager); + $this->flusher = new Flusher($entityManager,$this->eventDispatcher); + $this->handler = new Bitrix24Accounts\UseCase\InstallFinish\Handler( - $this->eventDispatcher, $this->repository, $this->flusher, new NullLogger() diff --git a/tests/Functional/Bitrix24Accounts/UseCase/InstallStart/HandlerTest.php b/tests/Functional/Bitrix24Accounts/UseCase/InstallStart/HandlerTest.php index 057ce05..add9878 100644 --- a/tests/Functional/Bitrix24Accounts/UseCase/InstallStart/HandlerTest.php +++ b/tests/Functional/Bitrix24Accounts/UseCase/InstallStart/HandlerTest.php @@ -53,9 +53,9 @@ protected function setUp(): void { $entityManager = EntityManagerFactory::get(); $eventDispatcher = new EventDispatcher(); - $this->repository = new Bitrix24AccountRepository($entityManager); - $this->flusher = new Flusher($entityManager,$eventDispatcher); $this->eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $this->repository = new Bitrix24AccountRepository($entityManager); + $this->flusher = new Flusher($entityManager,$this->eventDispatcher); $this->handler = new Bitrix24Accounts\UseCase\InstallStart\Handler( $this->repository, $this->flusher, diff --git a/tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php b/tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php index fb775d0..0f63150 100644 --- a/tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php +++ b/tests/Functional/Bitrix24Accounts/UseCase/RenewAuthToken/HandlerTest.php @@ -28,8 +28,8 @@ use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; -use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Component\EventDispatcher\EventDispatcher; /** * @internal @@ -50,9 +50,9 @@ protected function setUp(): void { $entityManager = EntityManagerFactory::get(); $eventDispatcher = new EventDispatcher(); + $this->eventDispatcher = new TraceableEventDispatcher($eventDispatcher, new Stopwatch()); $this->repository = new Bitrix24AccountRepository($entityManager); - $this->flusher = new Flusher($entityManager,$eventDispatcher); - $this->eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $this->flusher = new Flusher($entityManager,$this->eventDispatcher); $this->handler = new Handler( $this->repository, $this->flusher, diff --git a/tests/Functional/Bitrix24Accounts/UseCase/Uninstall/HandlerTest.php b/tests/Functional/Bitrix24Accounts/UseCase/Uninstall/HandlerTest.php index c83dc18..da6e1f0 100644 --- a/tests/Functional/Bitrix24Accounts/UseCase/Uninstall/HandlerTest.php +++ b/tests/Functional/Bitrix24Accounts/UseCase/Uninstall/HandlerTest.php @@ -103,9 +103,9 @@ protected function setUp(): void $entityManager = EntityManagerFactory::get(); $eventDispatcher = new EventDispatcher(); + $this->eventDispatcher = new TraceableEventDispatcher($eventDispatcher, new Stopwatch()); $this->repository = new Bitrix24AccountRepository($entityManager); - $this->flusher = new Flusher($entityManager, $eventDispatcher); - $this->eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $this->flusher = new Flusher($entityManager, $this->eventDispatcher); $this->handler = new Bitrix24Accounts\UseCase\Uninstall\Handler( $this->repository,