refactor: split service into ServiceBase and LiveService

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-10-07 21:49:31 -04:00
parent eea9b5630a
commit 4e12d41ee9
18 changed files with 649 additions and 516 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace KTXT\ProviderImap\Tests\Unit;
use KTXM\ProviderImap\Providers\ServiceBase;
use KTXM\ProviderImap\Providers\LiveService;
use KTXM\ProviderImap\Service\Live\LiveMailService;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
final class LiveServiceTest extends TestCase
{
public function testEntityExtantReportsExistenceOfEachIdentifier(): void
{
$service = new LiveService();
$live = new LiveServiceTestLiveStub($this->createStub(ServiceBase::class));
$live->existing = [5];
(new ReflectionProperty(LiveService::class, 'mailService'))->setValue($service, $live);
$result = $service->entityExtant('INBOX', 5, '6', 'abc', 0);
$this->assertSame([5 => true, 6 => false, 'abc' => false, 0 => false], $result);
$this->assertSame([['INBOX', [5, 6]]], $live->extantCalls);
}
}
final class LiveServiceTestLiveStub extends LiveMailService
{
/** @var int[] */
public array $existing = [];
public array $extantCalls = [];
public function entityExtant(string $collection, int ...$uids): array
{
$this->extantCalls[] = [$collection, $uids];
return array_values(array_intersect($uids, $this->existing));
}
}