generated from Nodarx/template
54a24c9892
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXT\ProviderImap\Tests\Unit;
|
|
|
|
use KTXM\ProviderImap\Providers\Service;
|
|
use KTXM\ProviderImap\Service\Remote\RemoteMailService;
|
|
use PHPUnit\Framework\TestCase;
|
|
use ReflectionProperty;
|
|
|
|
final class ServiceTest extends TestCase
|
|
{
|
|
public function testEntityExtantReportsExistenceOfEachIdentifier(): void
|
|
{
|
|
$service = new Service();
|
|
$remote = new ServiceTestRemoteStub($this->createStub(Service::class));
|
|
$remote->existing = [5];
|
|
(new ReflectionProperty(Service::class, 'remoteService'))->setValue($service, $remote);
|
|
|
|
$result = $service->entityExtant('INBOX', 5, '6', 'abc', 0);
|
|
|
|
$this->assertSame([5 => true, 6 => false, 'abc' => false, 0 => false], $result);
|
|
$this->assertSame([['INBOX', [5, 6]]], $remote->extantCalls);
|
|
}
|
|
}
|
|
|
|
final class ServiceTestRemoteStub extends RemoteMailService
|
|
{
|
|
/** @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));
|
|
}
|
|
}
|