Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit 64e7577

Browse files
committed
Switch to NullLogger for InMemory repository implementations
Replaced Fabric::getLogger with Psr\Log\NullLogger in multiple InMemory repository implementations for consistent logging behavior in unit tests. Adjusted test suite configuration to display warnings. Signed-off-by: mesilov <mesilov.maxim@gmail.com>
1 parent 509f3de commit 64e7577

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ lint-rector-fix:
1010
vendor/bin/rector process
1111

1212
test-unit:
13-
vendor/bin/phpunit --testsuite unit_tests
13+
vendor/bin/phpunit --testsuite unit_tests --display-warnings
1414

1515
# integration tests with granularity by api-scope
1616
test-integration-scope-telephony:

tests/Unit/Application/Contracts/ApplicationInstallations/Repository/InMemoryApplicationInstallationRepositoryImplementationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Bitrix24\SDK\Tests\Unit\Application\Contracts\ApplicationInstallations\Entity\ApplicationInstallationReferenceEntityImplementation;
1515
use Carbon\CarbonImmutable;
1616
use PHPUnit\Framework\Attributes\CoversClass;
17+
use Psr\Log\NullLogger;
1718
use Symfony\Component\Uid\Uuid;
1819

1920
#[CoversClass(ApplicationInstallationRepositoryInterface::class)]
@@ -39,6 +40,6 @@ protected function createApplicationInstallationImplementation(Uuid $uuid, Appli
3940

4041
protected function createApplicationInstallationRepositoryImplementation(): ApplicationInstallationRepositoryInterface
4142
{
42-
return new InMemoryApplicationInstallationRepositoryImplementation(Fabric::getLogger());
43+
return new InMemoryApplicationInstallationRepositoryImplementation(new NullLogger());
4344
}
4445
}

tests/Unit/Application/Contracts/Bitrix24Accounts/Repository/InMemoryBitrix24AccountRepositoryImplementationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Bitrix24\SDK\Tests\Unit\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountReferenceEntityImplementation;
1515
use Carbon\CarbonImmutable;
1616
use PHPUnit\Framework\Attributes\CoversClass;
17+
use Psr\Log\NullLogger;
1718
use Symfony\Component\Uid\Uuid;
1819

1920
#[CoversClass(Bitrix24AccountRepositoryInterface::class)]
@@ -50,6 +51,6 @@ protected function createBitrix24AccountImplementation(
5051

5152
protected function createBitrix24AccountRepositoryImplementation(): Bitrix24AccountRepositoryInterface
5253
{
53-
return new InMemoryBitrix24AccountRepositoryImplementation(Fabric::getLogger());
54+
return new InMemoryBitrix24AccountRepositoryImplementation(new NullLogger());
5455
}
5556
}

tests/Unit/Application/Contracts/Bitrix24Partners/Entity/Bitrix24PartnerReferenceEntityImplementation.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
final class Bitrix24PartnerReferenceEntityImplementation implements Bitrix24PartnerInterface, AggregateRootEventsEmitterInterface
3131
{
3232
private ?string $comment = null;
33+
3334
private array $events = [];
3435

3536
public function __construct(
@@ -76,10 +77,10 @@ public function setExternalId(?string $externalId): void
7677
$this->updatedAt = new CarbonImmutable();
7778

7879
$this->events[] = new Bitrix24PartnerExternalIdChangedEvent(
79-
$this->getId(),
80-
$this->getUpdatedAt(),
80+
$this->id,
81+
$this->updatedAt,
8182
$prevExternalId,
82-
$this->getExternalId()
83+
$this->externalId
8384
);
8485
}
8586

tests/Unit/Application/Contracts/Bitrix24Partners/Repository/InMemoryBitrix24PartnerRepositoryImplementation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function findByExternalId(string $externalId, ?Bitrix24PartnerStatus $bit
7575
{
7676
$this->logger->debug('b24PartnerRepository.findByExternalId', [
7777
'externalId' => $externalId,
78-
'bitrix24PartnerStatus' => $bitrix24PartnerStatus->name
78+
'bitrix24PartnerStatus' => $bitrix24PartnerStatus?->name
7979
]);
8080

8181
if (trim($externalId) === '') {

tests/Unit/Application/Contracts/Bitrix24Partners/Repository/InMemoryBitrix24PartnerRepositoryImplementationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Darsyn\IP\Version\Multi as IP;
2727
use libphonenumber\PhoneNumber;
2828
use PHPUnit\Framework\Attributes\CoversClass;
29+
use Psr\Log\NullLogger;
2930
use Symfony\Component\Uid\Uuid;
3031

3132
#[CoversClass(Bitrix24PartnerRepositoryInterface::class)]
@@ -60,6 +61,6 @@ protected function createBitrix24PartnerImplementation(
6061

6162
protected function createBitrix24PartnerRepositoryImplementation(): Bitrix24PartnerRepositoryInterface
6263
{
63-
return new InMemoryBitrix24PartnerRepositoryImplementation(Fabric::getLogger());
64+
return new InMemoryBitrix24PartnerRepositoryImplementation(new NullLogger());
6465
}
6566
}

tests/Unit/Application/Contracts/ContactPersons/Repository/InMemoryContactPersonRepositoryImplementationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Darsyn\IP\Version\Multi as IP;
2020
use libphonenumber\PhoneNumber;
2121
use PHPUnit\Framework\Attributes\CoversClass;
22+
use Psr\Log\NullLogger;
2223
use Symfony\Component\Uid\Uuid;
2324

2425
#[CoversClass(ContactPersonRepositoryInterface::class)]
@@ -98,6 +99,6 @@ protected function createContactPersonImplementation(
9899

99100
protected function createContactPersonRepositoryImplementation(): ContactPersonRepositoryInterface
100101
{
101-
return new InMemoryContactPersonRepositoryImplementation(Fabric::getLogger());
102+
return new InMemoryContactPersonRepositoryImplementation(new NullLogger());
102103
}
103104
}

0 commit comments

Comments
 (0)