Prueba Service Worker

This commit is contained in:
Juan Pablo Vial
2025-06-24 11:20:21 -04:00
parent ecc67a43c8
commit 200510d60a

View File

@ -0,0 +1,46 @@
<?php
namespace Tests\Unit\Service\Worker;
use DateTimeImmutable;
use Psr\Container\ContainerInterface;
use PHPUnit\Framework\TestCase;
use Incoviba\Service;
use Incoviba\Model;
use Psr\Log\LoggerInterface;
class ServiceTest extends TestCase
{
protected Model\Job $job;
protected ContainerInterface $container;
protected LoggerInterface $logger;
protected function setUp(): void
{
$pagoService = $this->getMockBuilder(Service\Venta\Pago::class)->disableOriginalConstructor()->getMock();
$pagoService->method('updateUF')->willReturn(true);
$this->logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock();
$this->container = $this->getMockBuilder(ContainerInterface::class)->disableOriginalConstructor()->getMock();
$this->container->method('get')->willReturnMap([
[LoggerInterface::class, $this->logger],
[Service\Queue::class, $this->getMockBuilder(Service\Queue::class)->disableOriginalConstructor()->getMock()],
[Service\UF::class, $this->getMockBuilder(Service\UF::class)->disableOriginalConstructor()->getMock()],
[Service\Venta\Pago::class, $pagoService],
]);
}
public function testExecute(): void
{
$configuration = [
'type' => 'service',
'service' => Service\Venta\Pago::class,
'method' => 'updateUF',
'params' => ['pago_id' => 1]
];
$job = $this->getMockBuilder(Model\Job::class)->disableOriginalConstructor()->getMock();
$job->configuration = $configuration;
$service = new Service\Worker\Service($this->container, $this->logger);
$result = $service->execute($job);
$this->assertTrue($result);
}
}