Varios cambios Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl> Reviewed-on: #25
46 lines
1.7 KiB
PHP
46 lines
1.7 KiB
PHP
<?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);
|
|
}
|
|
} |