Reorden Toku

This commit is contained in:
Juan Pablo Vial
2025-05-10 12:38:14 -04:00
parent 1486d6cf38
commit fb7177fd65
24 changed files with 213 additions and 215 deletions

View File

@ -1,22 +1,22 @@
<?php
namespace Tests\Unit\Service\MediosPago\Toku;
namespace Tests\Unit\Service\Venta\MediosPago\Toku;
use PDO;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use PHPUnit\Framework\TestCase;
use Faker;
use GuzzleHttp\Client;
use Incoviba\Common\Define;
use Incoviba\Repository;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use PDO;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
class CustomerTest extends TestCase
{
protected Client $client;
protected Model\MediosPago\Toku\Customer $customer;
protected Repository\MediosPago\Toku\Customer $customerRepository;
protected Model\Venta\MediosPago\Toku\Customer $customer;
protected Repository\Venta\MediosPago\Toku\Customer $customerRepository;
protected array $getData;
protected array $postData;
@ -50,7 +50,7 @@ class CustomerTest extends TestCase
$persona->apellidoMaterno
]));
$this->customer = $this->getMockBuilder(Model\MediosPago\Toku\Customer::class)
$this->customer = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Customer::class)
->disableOriginalConstructor()->getMock();
$this->customer->id = $faker->randomNumber();
$this->customer->persona = $persona;
@ -65,7 +65,7 @@ class CustomerTest extends TestCase
'toku_id' => $this->customer->toku_id
]);
$this->customerRepository = $this->getMockBuilder(Repository\MediosPago\Toku\Customer::class)
$this->customerRepository = $this->getMockBuilder(Repository\Venta\MediosPago\Toku\Customer::class)
->disableOriginalConstructor()->getMock();
$this->customerRepository->method('fetchById')->willReturn($this->customer);
$this->customerRepository->method('fetchByRut')->willReturn($this->customer);
@ -148,25 +148,25 @@ class CustomerTest extends TestCase
public function testGetById(): void
{
$service = new Service\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$service = new Service\Venta\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$this->assertEquals(json_decode(json_encode($this->customer), true), $service->getById($this->customer->id));
}
public function testGetByExternalId(): void
{
$service = new Service\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$service = new Service\Venta\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$this->assertEquals(json_decode(json_encode($this->customer), true), $service->getByExternalId($this->customer->rut()));
}
public function testGet(): void
{
$service = new Service\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$service = new Service\Venta\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$this->assertArrayIsEqualToArrayIgnoringListOfKeys($this->getData, $service->get($this->customer->toku_id), []);
}
public function testAdd(): void
{
$service = new Service\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$service = new Service\Venta\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$sendData = [
'rut' => $this->postData['government_id'],
@ -178,7 +178,7 @@ class CustomerTest extends TestCase
}
public function testEdit(): void
{
$service = new Service\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$service = new Service\Venta\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$sendData = [
'rut' => $this->postData['government_id'],
@ -190,7 +190,7 @@ class CustomerTest extends TestCase
}
public function testDelete(): void
{
$service = new Service\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$service = new Service\Venta\MediosPago\Toku\Customer($this->client, $this->customerRepository);
$this->expectNotToPerformAssertions();
$service->delete($this->customer->toku_id);

View File

@ -1,22 +1,22 @@
<?php
namespace Tests\Unit\Service\MediosPago\Toku;
namespace Tests\Unit\Service\Venta\MediosPago\Toku;
use PDO;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use PHPUnit\Framework\TestCase;
use Faker;
use GuzzleHttp\Client;
use Incoviba\Common\Define;
use Incoviba\Repository;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use PDO;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
class InvoiceTest extends TestCase
{
protected Client $client;
protected Model\MediosPago\Toku\Invoice $invoice;
protected Repository\MediosPago\Toku\Invoice $invoiceRepository;
protected Model\Venta\MediosPago\Toku\Invoice $invoice;
protected Repository\Venta\MediosPago\Toku\Invoice $invoiceRepository;
protected Model\Venta\Cuota $cuota;
protected Service\Venta\Pago $pagoService;
protected Service\UF $ufService;
@ -35,14 +35,14 @@ class InvoiceTest extends TestCase
$faker = Faker\Factory::create();
$customer = $this->getMockBuilder(Model\MediosPago\Toku\Customer::class)
$customer = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Customer::class)
->disableOriginalConstructor()->getMock();
$customer->id = $faker->randomNumber();
$customer->toku_id = $faker->ean13();
$venta = $this->getMockBuilder(Model\Venta::class)
->disableOriginalConstructor()->getMock();
$venta->id = $faker->randomNumber();
$subscription = $this->getMockBuilder(Model\MediosPago\Toku\Subscription::class)
$subscription = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Subscription::class)
->disableOriginalConstructor()->getMock();
$subscription->id = $faker->randomNumber();
$subscription->venta = $venta;
@ -75,7 +75,7 @@ class InvoiceTest extends TestCase
$this->cuota->numero = $faker->randomNumber(2);
$this->cuota->pago = $pago;
$this->invoice = $this->getMockBuilder(Model\MediosPago\Toku\Invoice::class)
$this->invoice = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Invoice::class)
->disableOriginalConstructor()->getMock();
$this->invoice->id = $faker->randomNumber();
$this->invoice->cuota = $this->cuota;
@ -86,7 +86,7 @@ class InvoiceTest extends TestCase
'toku_id' => $this->invoice->toku_id
]);
$this->invoiceRepository = $this->getMockBuilder(Repository\MediosPago\Toku\Invoice::class)
$this->invoiceRepository = $this->getMockBuilder(Repository\Venta\MediosPago\Toku\Invoice::class)
->disableOriginalConstructor()->getMock();
$this->invoiceRepository->method('fetchById')->willReturn($this->invoice);
$this->invoiceRepository->method('fetchByCuota')->willReturn($this->invoice);
@ -179,25 +179,25 @@ class InvoiceTest extends TestCase
public function testGetById(): void
{
$service = new Service\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$service = new Service\Venta\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$this->assertEquals(json_decode(json_encode($this->invoice), true), $service->getById($this->cuota->id));
}
public function testGetByExternalId(): void
{
$service = new Service\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$service = new Service\Venta\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$this->assertEquals(json_decode(json_encode($this->invoice), true), $service->getByExternalId($this->invoice->toku_id));
}
public function testGet(): void
{
$service = new Service\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$service = new Service\Venta\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$this->assertEquals($this->getData, $service->get($this->invoice->toku_id));
}
public function testAdd(): void
{
$service = new Service\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$service = new Service\Venta\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$sendData = [
'customer' => $this->postData['customer'],
@ -210,7 +210,7 @@ class InvoiceTest extends TestCase
}
public function testEdit(): void
{
$service = new Service\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$service = new Service\Venta\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$sendData = [
'customer' => $this->postData['customer'],
@ -223,7 +223,7 @@ class InvoiceTest extends TestCase
}
public function testDelete(): void
{
$service = new Service\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$service = new Service\Venta\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$this->expectNotToPerformAssertions();
$service->delete($this->invoice->toku_id);
@ -258,7 +258,7 @@ class InvoiceTest extends TestCase
]
];
$service = new Service\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$service = new Service\Venta\MediosPago\Toku\Invoice($this->client, $this->invoiceRepository, $this->pagoService, $this->ufService);
$this->assertTrue($service->update($request['payment_intent']['invoice'], $request['payment_intent']));
}

View File

@ -1,22 +1,22 @@
<?php
namespace Tests\Unit\Service\MediosPago\Toku;
namespace Tests\Unit\Service\Venta\MediosPago\Toku;
use PDO;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use PHPUnit\Framework\TestCase;
use Faker;
use GuzzleHttp\Client;
use Incoviba\Common\Define;
use Incoviba\Repository;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use PDO;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
class SubscriptionTest extends TestCase
{
protected Client $client;
protected Model\MediosPago\Toku\Subscription $subscription;
protected Repository\MediosPago\Toku\Subscription $subscriptionRepository;
protected Model\Venta\MediosPago\Toku\Subscription $subscription;
protected Repository\Venta\MediosPago\Toku\Subscription $subscriptionRepository;
protected Model\Venta $venta;
protected array $getData;
protected array $postData;
@ -32,7 +32,7 @@ class SubscriptionTest extends TestCase
$faker = Faker\Factory::create();
$customer = $this->getMockBuilder(Model\MediosPago\Toku\Customer::class)
$customer = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Customer::class)
->disableOriginalConstructor()->getMock();
$customer->id = $faker->randomNumber();
@ -60,7 +60,7 @@ class SubscriptionTest extends TestCase
$this->venta->method('proyecto')->willReturn($proyecto);
$this->venta->method('propiedad')->willReturn($propiedad);
$this->subscription = $this->getMockBuilder(Model\MediosPago\Toku\Subscription::class)
$this->subscription = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Subscription::class)
->disableOriginalConstructor()->getMock();
$this->subscription->id = $faker->randomNumber();
$this->subscription->venta = $this->venta;
@ -71,7 +71,7 @@ class SubscriptionTest extends TestCase
'toku_id' => $this->subscription->toku_id,
]);
$this->subscriptionRepository = $this->getMockBuilder(Repository\MediosPago\Toku\Subscription::class)
$this->subscriptionRepository = $this->getMockBuilder(Repository\Venta\MediosPago\Toku\Subscription::class)
->disableOriginalConstructor()->getMock();
$this->subscriptionRepository->method('fetchById')->willReturn($this->subscription);
$this->subscriptionRepository->method('fetchByVenta')->willReturn($this->subscription);
@ -142,25 +142,25 @@ class SubscriptionTest extends TestCase
public function testGetById(): void
{
$service = new Service\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$service = new Service\Venta\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$this->assertEquals(json_decode(json_encode($this->subscription), true), $service->getById($this->subscription->toku_id));
}
public function testGetByExternalId(): void
{
$service = new Service\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$service = new Service\Venta\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$this->assertEquals(json_decode(json_encode($this->subscription), true), $service->getByExternalId($this->subscription->toku_id));
}
public function testGet(): void
{
$service = new Service\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$service = new Service\Venta\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$this->assertArrayIsEqualToArrayIgnoringListOfKeys($this->getData, $service->get($this->subscription->toku_id), []);
}
public function testAdd(): void
{
$service = new Service\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$service = new Service\Venta\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$sendData = [
'customer' => $this->postData['customer'],
@ -171,7 +171,7 @@ class SubscriptionTest extends TestCase
}
public function testEdit(): void
{
$service = new Service\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$service = new Service\Venta\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$sendData = [
'customer' => $this->postData['customer'],
@ -182,7 +182,7 @@ class SubscriptionTest extends TestCase
}
public function testDelete(): void
{
$service = new Service\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$service = new Service\Venta\MediosPago\Toku\Subscription($this->client, $this->subscriptionRepository);
$this->expectNotToPerformAssertions();
$service->delete($this->subscription->toku_id);

View File

@ -1,23 +1,22 @@
<?php
namespace Tests\Unit\Service\MediosPago;
namespace Tests\Unit\Service\Venta\MediosPago;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Exception\InvalidResult;
use Psr\Log\LoggerInterface;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Exception\InvalidResult;
use Incoviba\Model;
use Incoviba\Service;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
class TokuTest extends TestCase
{
protected LoggerInterface $logger;
protected Service\MediosPago\Toku\Customer $customerService;
protected Service\MediosPago\Toku\Subscription $subscriptionService;
protected Service\MediosPago\Toku\Invoice $invoiceService;
protected Model\MediosPago\Toku\Customer $customer;
protected Model\MediosPago\Toku\Subscription $subscription;
protected Model\MediosPago\Toku\Invoice $invoice;
protected Service\Venta\MediosPago\Toku\Customer $customerService;
protected Service\Venta\MediosPago\Toku\Subscription $subscriptionService;
protected Service\Venta\MediosPago\Toku\Invoice $invoiceService;
protected Model\Venta\MediosPago\Toku\Customer $customer;
protected Model\Venta\MediosPago\Toku\Subscription $subscription;
protected Model\Venta\MediosPago\Toku\Invoice $invoice;
protected Model\Persona $persona;
protected Model\Venta $venta;
protected Model\Venta\Cuota $cuota;
@ -43,7 +42,7 @@ class TokuTest extends TestCase
$this->persona->apellidoMaterno = $faker->lastName();
$this->persona->method('datos')->willReturn($datos);
$this->persona->method('__get')->with('dv')->willReturn($this->persona->digito);
$this->customer = $this->getMockBuilder(Model\MediosPago\Toku\Customer::class)
$this->customer = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Customer::class)
->disableOriginalConstructor()->getMock();
$this->customer->id = $faker->randomNumber();
$this->customer->persona = $this->persona;
@ -88,7 +87,7 @@ class TokuTest extends TestCase
$this->venta->method('proyecto')->willReturn($proyecto);
$this->venta->method('propiedad')->willReturn($propiedad);
$this->venta->method('propietario')->willReturn($propietario);
$this->subscription = $this->getMockBuilder(Model\MediosPago\Toku\Subscription::class)
$this->subscription = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Subscription::class)
->disableOriginalConstructor()->getMock();
$this->subscription->id = $faker->randomNumber();
$this->subscription->venta = $this->venta;
@ -105,7 +104,7 @@ class TokuTest extends TestCase
$this->cuota->numero = $faker->randomNumber(2);
$this->cuota->pago = $this->pago;
$pie->method('cuotas')->willReturn([$this->cuota]);
$this->invoice = $this->getMockBuilder(Model\MediosPago\Toku\Invoice::class)
$this->invoice = $this->getMockBuilder(Model\Venta\MediosPago\Toku\Invoice::class)
->disableOriginalConstructor()->getMock();
$this->invoice->id = $faker->randomNumber();
$this->invoice->cuota = $this->cuota;
@ -116,7 +115,7 @@ class TokuTest extends TestCase
'rut' => $this->customer->rut(),
'toku_id' => $this->customer->toku_id
];
$this->customerService = $this->getMockBuilder(Service\MediosPago\Toku\Customer::class)
$this->customerService = $this->getMockBuilder(Service\Venta\MediosPago\Toku\Customer::class)
->disableOriginalConstructor()->getMock();
$this->customerService->method('getById')->willReturn($customerArray);
$this->customerService->method('getByExternalId')->willReturn($customerArray);
@ -143,7 +142,7 @@ class TokuTest extends TestCase
$this->customerService->method('edit')->willReturn(true);
$this->customerService->method('delete');
$this->subscriptionService = $this->getMockBuilder(Service\MediosPago\Toku\Subscription::class)
$this->subscriptionService = $this->getMockBuilder(Service\Venta\MediosPago\Toku\Subscription::class)
->disableOriginalConstructor()->getMock();
$this->subscriptionService->method('getById')->willReturn([
'id' => $this->subscription->id,
@ -173,7 +172,7 @@ class TokuTest extends TestCase
'cuota_id' => $this->cuota->id,
'toku_id' => $this->invoice->toku_id,
];
$this->invoiceService = $this->getMockBuilder(Service\MediosPago\Toku\Invoice::class)
$this->invoiceService = $this->getMockBuilder(Service\Venta\MediosPago\Toku\Invoice::class)
->disableOriginalConstructor()->getMock();
$this->invoiceService->method('getById')->willReturn($invoiceArray);
$this->invoiceService->method('getByExternalId')->willReturn($invoiceArray);
@ -207,8 +206,8 @@ class TokuTest extends TestCase
public function testSendCustomer(): void
{
$service = new Service\MediosPago\Toku($this->logger);
$service->register(Service\MediosPago\Toku::CUSTOMER, $this->customerService);
$service = new Service\Venta\MediosPago\Toku($this->logger);
$service->register(Service\Venta\MediosPago\Toku::CUSTOMER, $this->customerService);
$expected = [
'id' => $this->customer->id,
@ -220,9 +219,9 @@ class TokuTest extends TestCase
}
public function testSendSubscription(): void
{
$service = new Service\MediosPago\Toku($this->logger);
$service->register(Service\MediosPago\Toku::CUSTOMER, $this->customerService);
$service->register(Service\MediosPago\Toku::SUBSCRIPTION, $this->subscriptionService);
$service = new Service\Venta\MediosPago\Toku($this->logger);
$service->register(Service\Venta\MediosPago\Toku::CUSTOMER, $this->customerService);
$service->register(Service\Venta\MediosPago\Toku::SUBSCRIPTION, $this->subscriptionService);
$expected = [
'id' => $this->subscription->id,
@ -234,10 +233,10 @@ class TokuTest extends TestCase
}
public function testSendInvoice(): void
{
$service = new Service\MediosPago\Toku($this->logger);
$service->register(Service\MediosPago\Toku::CUSTOMER, $this->customerService);
$service->register(Service\MediosPago\Toku::SUBSCRIPTION, $this->subscriptionService);
$service->register(Service\MediosPago\Toku::INVOICE, $this->invoiceService);
$service = new Service\Venta\MediosPago\Toku($this->logger);
$service->register(Service\Venta\MediosPago\Toku::CUSTOMER, $this->customerService);
$service->register(Service\Venta\MediosPago\Toku::SUBSCRIPTION, $this->subscriptionService);
$service->register(Service\Venta\MediosPago\Toku::INVOICE, $this->invoiceService);
$expected = [
[
@ -251,9 +250,9 @@ class TokuTest extends TestCase
}
public function testUpdatePago(): void
{
$service = new Service\MediosPago\Toku($this->logger);
$service->register(Service\MediosPago\Toku::CUSTOMER, $this->customerService);
$service->register(Service\MediosPago\Toku::INVOICE, $this->invoiceService);
$service = new Service\Venta\MediosPago\Toku($this->logger);
$service->register(Service\Venta\MediosPago\Toku::CUSTOMER, $this->customerService);
$service->register(Service\Venta\MediosPago\Toku::INVOICE, $this->invoiceService);
$faker = Faker\Factory::create();
$request = [
@ -292,9 +291,9 @@ class TokuTest extends TestCase
$customerService = clone($this->customerService);
$customerService->method('getByExternalId')->willThrowException($emptyResponse);
$service = new Service\MediosPago\Toku($this->logger);
$service->register(Service\MediosPago\Toku::CUSTOMER, $customerService);
$service->register(Service\MediosPago\Toku::INVOICE, $this->invoiceService);
$service = new Service\Venta\MediosPago\Toku($this->logger);
$service->register(Service\Venta\MediosPago\Toku::CUSTOMER, $customerService);
$service->register(Service\Venta\MediosPago\Toku::INVOICE, $this->invoiceService);
$faker = Faker\Factory::create();
$request = [
@ -330,9 +329,9 @@ class TokuTest extends TestCase
$invoiceService = clone($this->invoiceService);
$invoiceService->method('getByExternalId')->willThrowException($emptyResponse);
$service = new Service\MediosPago\Toku($this->logger);
$service->register(Service\MediosPago\Toku::CUSTOMER, $this->customerService);
$service->register(Service\MediosPago\Toku::INVOICE, $invoiceService);
$service = new Service\Venta\MediosPago\Toku($this->logger);
$service->register(Service\Venta\MediosPago\Toku::CUSTOMER, $this->customerService);
$service->register(Service\Venta\MediosPago\Toku::INVOICE, $invoiceService);
$this->expectException(InvalidResult::class);
$service->updatePago($request['payment_intent']);