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

@ -123,31 +123,31 @@ return [
]
]);
},
Incoviba\Service\MediosPago\Toku\Customer::class => function(ContainerInterface $container) {
return new Incoviba\Service\MediosPago\Toku\Customer(
Incoviba\Service\Venta\MediosPago\Toku\Customer::class => function(ContainerInterface $container) {
return new Incoviba\Service\Venta\MediosPago\Toku\Customer(
$container->get('tokuClient'),
$container->get(Incoviba\Repository\MediosPago\Toku\Customer::class)
$container->get(Incoviba\Repository\Venta\MediosPago\Toku\Customer::class)
);
},
Incoviba\Service\MediosPago\Toku\Subscription::class => function(ContainerInterface $container) {
return new Incoviba\Service\MediosPago\Toku\Subscription(
Incoviba\Service\Venta\MediosPago\Toku\Subscription::class => function(ContainerInterface $container) {
return new Incoviba\Service\Venta\MediosPago\Toku\Subscription(
$container->get('tokuClient'),
$container->get(Incoviba\Repository\MediosPago\Toku\Subscription::class)
$container->get(Incoviba\Repository\Venta\MediosPago\Toku\Subscription::class)
);
},
Incoviba\Service\MediosPago\Toku\Invoice::class => function(ContainerInterface $container) {
return new Incoviba\Service\MediosPago\Toku\Invoice(
Incoviba\Service\Venta\MediosPago\Toku\Invoice::class => function(ContainerInterface $container) {
return new Incoviba\Service\Venta\MediosPago\Toku\Invoice(
$container->get('tokuClient'),
$container->get(Incoviba\Repository\MediosPago\Toku\Invoice::class),
$container->get(Incoviba\Repository\Venta\MediosPago\Toku\Invoice::class),
$container->get(Incoviba\Service\Venta\Pago::class),
$container->get(Incoviba\Service\UF::class)
);
},
Incoviba\Service\MediosPago\Toku::class => function(ContainerInterface $container) {
return (new Incoviba\Service\MediosPago\Toku(
Incoviba\Service\Venta\MediosPago\Toku::class => function(ContainerInterface $container) {
return (new Incoviba\Service\Venta\MediosPago\Toku(
$container->get(Psr\Log\LoggerInterface::class)
))->register('customer', $container->get(Incoviba\Service\MediosPago\Toku\Customer::class))
->register('subscription', $container->get(Incoviba\Service\MediosPago\Toku\Subscription::class))
->register('invoice', $container->get(Incoviba\Service\MediosPago\Toku\Invoice::class));
))->register('customer', $container->get(Incoviba\Service\Venta\MediosPago\Toku\Customer::class))
->register('subscription', $container->get(Incoviba\Service\Venta\MediosPago\Toku\Subscription::class))
->register('invoice', $container->get(Incoviba\Service\Venta\MediosPago\Toku\Invoice::class));
}
];

View File

@ -4,7 +4,6 @@ namespace Incoviba\Controller\API\Ventas\MediosPago;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Common\Ideal\Controller;
use Incoviba\Controller\API\withJson;
use Incoviba\Exception\InvalidResult;
@ -15,8 +14,8 @@ class Toku extends Controller
{
use withJson;
public function cuotas(ServerRequestInterface $request, ResponseInterface $response,
Service\MediosPago\Toku $tokuService, Service\Venta $ventaService, int $venta_id): ResponseInterface
public function cuotas(ServerRequestInterface $request, ResponseInterface $response,
Service\Venta\MediosPago\Toku $tokuService, Service\Venta $ventaService, int $venta_id): ResponseInterface
{
$input = $request->getParsedBody();
$output = [
@ -38,9 +37,9 @@ class Toku extends Controller
} catch (Read | InvalidResult) {}
return $this->withJson($response, $output);
}
public function success(ServerRequestInterface $request, ResponseInterface $response,
ResponseFactoryInterface $responseFactory,
Service\MediosPago\Toku $tokuService): ResponseInterface
public function success(ServerRequestInterface $request, ResponseInterface $response,
ResponseFactoryInterface $responseFactory,
Service\Venta\MediosPago\Toku $tokuService): ResponseInterface
{
$body = $request->getBody();
$input = json_decode($body->getContents(), true);

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Model\MediosPago\Toku;
namespace Incoviba\Model\Venta\MediosPago\Toku;
use Incoviba\Common\Ideal;
use Incoviba\Model\Persona;

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Model\MediosPago\Toku;
namespace Incoviba\Model\Venta\MediosPago\Toku;
use Incoviba\Common\Ideal;
use Incoviba\Model\Venta\Cuota;

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Model\MediosPago\Toku;
namespace Incoviba\Model\Venta\MediosPago\Toku;
use Incoviba\Common\Ideal;
use Incoviba\Model\Venta;

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Repository\MediosPago\Toku;
namespace Incoviba\Repository\Venta\MediosPago\Toku;
use DateTimeImmutable;
use Incoviba\Common\Define;
@ -20,7 +20,7 @@ class Customer extends Ideal\Repository
return 'teku_customers';
}
public function create(?array $data = null): Model\MediosPago\Toku\Customer
public function create(?array $data = null): Model\Venta\MediosPago\Toku\Customer
{
$map = (new Implement\Repository\MapperParser(['toku_id']))
->register('rut', (new Implement\Repository\Mapper())
@ -30,9 +30,9 @@ class Customer extends Ideal\Repository
return $this->personaService->getById($rut);
})
);
return $this->parseData(new Model\MediosPago\Toku\Customer(), $data, $map);
return $this->parseData(new Model\Venta\MediosPago\Toku\Customer(), $data, $map);
}
public function save(Define\Model $model): Model\MediosPago\Toku\Customer
public function save(Define\Model $model): Model\Venta\MediosPago\Toku\Customer
{
$model->id = $this->saveNew(
['rut', 'toku_id', 'created_at'],
@ -40,17 +40,17 @@ class Customer extends Ideal\Repository
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Model\MediosPago\Toku\Customer
public function edit(Define\Model $model, array $new_data): Model\Venta\MediosPago\Toku\Customer
{
return $this->update($model, ['rut', 'toku_id', 'updated_at'], array_merge($new_data, ['updated_at' => (new DateTimeImmutable())->format('Y-m-d H:i:s.u')]));
}
/**
* @param string $rut
* @return Model\MediosPago\Toku\Customer
* @return \Incoviba\Model\Venta\MediosPago\Toku\Customer
* @throws Implement\Exception\EmptyResult
*/
public function fetchByRut(string $rut): Model\MediosPago\Toku\Customer
public function fetchByRut(string $rut): Model\Venta\MediosPago\Toku\Customer
{
if (str_contains($rut, '-')) {
$rut = str_replace('-', '', $rut);
@ -68,10 +68,10 @@ class Customer extends Ideal\Repository
/**
* @param string $toku_id
* @return Model\MediosPago\Toku\Customer
* @return \Incoviba\Model\Venta\MediosPago\Toku\Customer
* @throws Implement\Exception\EmptyResult
*/
public function fetchByTokuId(string $toku_id): Model\MediosPago\Toku\Customer
public function fetchByTokuId(string $toku_id): Model\Venta\MediosPago\Toku\Customer
{
$query = $this->connection->getQueryBuilder()
->select()

View File

@ -1,12 +1,12 @@
<?php
namespace Incoviba\Repository\MediosPago\Toku;
namespace Incoviba\Repository\Venta\MediosPago\Toku;
use DateTimeImmutable;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Repository;
use Incoviba\Model;
use Incoviba\Repository;
class Invoice extends Ideal\Repository
{
@ -19,7 +19,7 @@ class Invoice extends Ideal\Repository
{
return 'toku_invoices';
}
public function create(?array $data = null): Model\MediosPago\Toku\Invoice
public function create(?array $data = null): Model\Venta\MediosPago\Toku\Invoice
{
$map = (new Implement\Repository\MapperParser(['toku_id']))
->register('cuota_id', (new Implement\Repository\Mapper())
@ -27,9 +27,9 @@ class Invoice extends Ideal\Repository
->setFunction(function($data) {
return $this->cuotaRepository->fetchById($data['cuota_id']);
}));
return $this->parseData(new Model\MediosPago\Toku\Invoice(), $data, $map);
return $this->parseData(new Model\Venta\MediosPago\Toku\Invoice(), $data, $map);
}
public function save(Define\Model $model): Model\MediosPago\Toku\Invoice
public function save(Define\Model $model): Model\Venta\MediosPago\Toku\Invoice
{
$model->id = $this->saveNew(
['cuota_id', 'toku_id', 'created_at'],
@ -37,17 +37,17 @@ class Invoice extends Ideal\Repository
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Model\MediosPago\Toku\Invoice
public function edit(Define\Model $model, array $new_data): Model\Venta\MediosPago\Toku\Invoice
{
return $this->update($model, ['cuota_id', 'toku_id', 'updated_at'], array_merge($new_data, ['updated_at' => (new DateTimeImmutable())->format('Y-m-d H:i:s.u')]));
}
/**
* @param int $cuota_id
* @return Model\MediosPago\Toku\Invoice
* @return \Incoviba\Model\Venta\MediosPago\Toku\Invoice
* @throws Implement\Exception\EmptyResult
*/
public function fetchByCuota(int $cuota_id): Model\MediosPago\Toku\Invoice
public function fetchByCuota(int $cuota_id): Model\Venta\MediosPago\Toku\Invoice
{
$query = $this->connection->getQueryBuilder()
->select()
@ -58,10 +58,10 @@ class Invoice extends Ideal\Repository
/**
* @param string $toku_id
* @return Model\MediosPago\Toku\Invoice
* @return \Incoviba\Model\Venta\MediosPago\Toku\Invoice
* @throws Implement\Exception\EmptyResult
*/
public function fetchByTokuId(string $toku_id): Model\MediosPago\Toku\Invoice
public function fetchByTokuId(string $toku_id): Model\Venta\MediosPago\Toku\Invoice
{
$query = $this->connection->getQueryBuilder()
->select()

View File

@ -1,9 +1,9 @@
<?php
namespace Incoviba\Repository\MediosPago\Toku;
namespace Incoviba\Repository\Venta\MediosPago\Toku;
use DateTimeImmutable;
use Incoviba\Common\Ideal;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Model;
use Incoviba\Repository;
@ -20,7 +20,7 @@ class Subscription extends Ideal\Repository
return 'toku_subscriptions';
}
public function create(?array $data = null): Model\MediosPago\Toku\Subscription
public function create(?array $data = null): Model\Venta\MediosPago\Toku\Subscription
{
$map = (new Implement\Repository\MapperParser(['toku_id']))
->register('venta_id', (new Implement\Repository\Mapper())
@ -28,9 +28,9 @@ class Subscription extends Ideal\Repository
->setFunction(function($data) {
return $this->ventaRepository->fetchById($data['venta_id']);
}));
return $this->parseData(new Model\MediosPago\Toku\Subscription(), $data, $map);
return $this->parseData(new Model\Venta\MediosPago\Toku\Subscription(), $data, $map);
}
public function save(Define\Model $model): Model\MediosPago\Toku\Subscription
public function save(Define\Model $model): Model\Venta\MediosPago\Toku\Subscription
{
$model->id = $this->saveNew(
['venta_id', 'toku_id', 'created_at'],
@ -38,12 +38,12 @@ class Subscription extends Ideal\Repository
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Model\MediosPago\Toku\Subscription
public function edit(Define\Model $model, array $new_data): Model\Venta\MediosPago\Toku\Subscription
{
return $this->update($model, ['venta_id', 'toku_id', 'updated_at'], array_merge($new_data, ['updated_at' => (new DateTimeImmutable())->format('Y-m-d H:i:s.u')]));
}
public function fetchByVenta(int $venta_id): Model\MediosPago\Toku\Subscription
public function fetchByVenta(int $venta_id): Model\Venta\MediosPago\Toku\Subscription
{
$query = $this->connection->getQueryBuilder()
->select()
@ -51,7 +51,7 @@ class Subscription extends Ideal\Repository
->where('venta_id = :venta_id');
return $this->fetchOne($query, compact('venta_id'));
}
public function fetchByTokuId(string $toku_id): Model\MediosPago\Toku\Subscription
public function fetchByTokuId(string $toku_id): Model\Venta\MediosPago\Toku\Subscription
{
$query = $this->connection->getQueryBuilder()
->select()

View File

@ -1,15 +1,15 @@
<?php
namespace Incoviba\Service\MediosPago;
namespace Incoviba\Service\Venta\MediosPago;
use HttpException;
use Incoviba\Common\Define\Repository;
use Incoviba\Common\Ideal\LoggerEnabled;
use Incoviba\Common\Implement\Exception\{EmptyResponse, EmptyResult};
use Incoviba\Exception\InvalidResult;
use PDOException;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ResponseInterface;
use Incoviba\Common\Define\Repository;
use Incoviba\Common\Implement\Exception\{EmptyResponse, EmptyResult};
use Incoviba\Common\Ideal\LoggerEnabled;
use Incoviba\Exception\InvalidResult;
abstract class AbstractEndPoint extends LoggerEnabled implements EndPoint
{

View File

@ -1,5 +1,5 @@
<?php
namespace Incoviba\Service\MediosPago;
namespace Incoviba\Service\Venta\MediosPago;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Exception\InvalidResult;

View File

@ -1,14 +1,14 @@
<?php
namespace Incoviba\Service\MediosPago;
namespace Incoviba\Service\Venta\MediosPago;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Exception\InvalidResult;
use Incoviba\Model;
use Incoviba\Model\Persona;
use Incoviba\Model\Venta\Propietario;
use Incoviba\Model;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
class Toku extends Ideal\Service
{

View File

@ -1,14 +1,14 @@
<?php
namespace Incoviba\Service\MediosPago\Toku;
namespace Incoviba\Service\Venta\MediosPago\Toku;
use Psr\Http\Client\ClientInterface;
use Incoviba\Repository;
use Incoviba\Service\MediosPago\AbstractEndPoint;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
use Psr\Http\Client\ClientInterface;
class Customer extends AbstractEndPoint
{
public function __construct(ClientInterface $client,
protected Repository\MediosPago\Toku\Customer $customerRepository)
public function __construct(ClientInterface $client,
protected Repository\Venta\MediosPago\Toku\Customer $customerRepository)
{
parent::__construct($client);
}

View File

@ -1,22 +1,22 @@
<?php
namespace Incoviba\Service\MediosPago\Toku;
namespace Incoviba\Service\Venta\MediosPago\Toku;
use DateTimeImmutable;
use DateMalformedStringException;
use Psr\Http\Client\ClientInterface;
use Incoviba\Exception\InvalidResult;
use DateTimeImmutable;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Exception\InvalidResult;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service\MediosPago\AbstractEndPoint;
use Incoviba\Service\UF;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
use Incoviba\Service\Venta\Pago;
use Psr\Http\Client\ClientInterface;
class Invoice extends AbstractEndPoint
{
public function __construct(ClientInterface $client,
protected Repository\MediosPago\Toku\Invoice $invoiceRepository,
protected Pago $pagoService, protected UF $ufService)
public function __construct(ClientInterface $client,
protected Repository\Venta\MediosPago\Toku\Invoice $invoiceRepository,
protected Pago $pagoService, protected UF $ufService)
{
parent::__construct($client);
}

View File

@ -1,14 +1,14 @@
<?php
namespace Incoviba\Service\MediosPago\Toku;
namespace Incoviba\Service\Venta\MediosPago\Toku;
use Psr\Http\Client\ClientInterface;
use Incoviba\Model\Venta;
use Incoviba\Repository;
use Incoviba\Service\MediosPago\AbstractEndPoint;
use Incoviba\Service\Venta\MediosPago\AbstractEndPoint;
use Psr\Http\Client\ClientInterface;
class Subscription extends AbstractEndPoint
{
public function __construct(ClientInterface $client, protected Repository\MediosPago\Toku\Subscription $subscriptionRepsitory)
public function __construct(ClientInterface $client, protected Repository\Venta\MediosPago\Toku\Subscription $subscriptionRepsitory)
{
parent::__construct($client);
}

View File

@ -1,12 +1,12 @@
<?php
namespace Test\Unit\Model\MediosPago\Toku;
namespace Test\Unit\Model\Venta\MediosPago\Toku;
use Faker;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Incoviba\Model\MediosPago\Toku\Customer;
use Incoviba\Model\Persona;
use Tests\Extension\ObjectHasMethodTrait;
use Incoviba\Model\Persona;
use Incoviba\Model\Venta\MediosPago\Toku\Customer;
class CustomerTest extends TestCase
{

View File

@ -1,5 +1,5 @@
<?php
namespace Tests\Unit\Model\MediosPago\Toku;
namespace Tests\Unit\Model\Venta\MediosPago\Toku;
use Faker;
use PHPUnit\Framework\Attributes\DataProvider;
@ -19,7 +19,7 @@ class InvoiceTest extends TestCase
#[DataProvider('dataProperties')]
public function testProperties(string $propertyName): void
{
$invoice = new Model\MediosPago\Toku\Invoice();
$invoice = new Model\Venta\MediosPago\Toku\Invoice();
$this->assertObjectHasProperty($propertyName, $invoice);
}
@ -35,7 +35,7 @@ class InvoiceTest extends TestCase
$id = $faker->randomNumber();
$invoice = new Model\MediosPago\Toku\Invoice();
$invoice = new Model\Venta\MediosPago\Toku\Invoice();
$invoice->id = $id;
$invoice->cuota = $cuota;
$invoice->toku_id = $toku_id;

View File

@ -1,5 +1,5 @@
<?php
namespace Tests\Unit\Model\MediosPago\Toku;
namespace Tests\Unit\Model\Venta\MediosPago\Toku;
use Faker;
use PHPUnit\Framework\Attributes\DataProvider;
@ -19,7 +19,7 @@ class SubscriptionTest extends TestCase
#[DataProvider('dataProperties')]
public function testProperties(string $propertyName): void
{
$subscription = new Model\MediosPago\Toku\Subscription();
$subscription = new Model\Venta\MediosPago\Toku\Subscription();
$this->assertObjectHasProperty($propertyName, $subscription);
}
@ -34,7 +34,7 @@ class SubscriptionTest extends TestCase
$id = $faker->randomNumber();
$subscription = new Model\MediosPago\Toku\Subscription();
$subscription = new Model\Venta\MediosPago\Toku\Subscription();
$subscription->id = $id;
$subscription->venta = $venta;
$subscription->toku_id = $toku_id;

View File

@ -1,14 +1,14 @@
<?php
namespace Tests\Unit\Repository\MediosPago\Toku;
namespace Tests\Unit\Repository\Venta\MediosPago\Toku;
use PDO;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Define;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use PDO;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
class CustomerTest extends TestCase
{
@ -47,7 +47,7 @@ class CustomerTest extends TestCase
public function testCreate(): void
{
$repository = new Repository\MediosPago\Toku\Customer($this->connection, $this->personaService);
$repository = new Repository\Venta\MediosPago\Toku\Customer($this->connection, $this->personaService);
$faker = Faker\Factory::create();
$data = [
@ -59,9 +59,9 @@ class CustomerTest extends TestCase
$this->assertEquals($this->persona, $customer->persona);
$this->assertEquals($data['toku_id'], $customer->toku_id);
}
public function testSave(): Model\MediosPago\Toku\Customer
public function testSave(): Model\Venta\MediosPago\Toku\Customer
{
$repository = new Repository\MediosPago\Toku\Customer($this->connection, $this->personaService);
$repository = new Repository\Venta\MediosPago\Toku\Customer($this->connection, $this->personaService);
$faker = Faker\Factory::create();
$data = [
@ -77,7 +77,7 @@ class CustomerTest extends TestCase
return $customer;
}
#[Depends('testSave')]
public function testFetch(Model\MediosPago\Toku\Customer $reference): void
public function testFetch(Model\Venta\MediosPago\Toku\Customer $reference): void
{
$result = [
'id' => $reference->id,
@ -89,16 +89,16 @@ class CustomerTest extends TestCase
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Customer($this->connection, $this->personaService);
$repository = new Repository\Venta\MediosPago\Toku\Customer($this->connection, $this->personaService);
$customer = $repository->fetchById($reference->id);
$this->assertInstanceOf(Model\MediosPago\Toku\Customer::class, $customer);
$this->assertInstanceOf(Model\Venta\MediosPago\Toku\Customer::class, $customer);
$this->assertEquals($reference->id, $customer->id);
$this->assertEquals($this->persona, $customer->persona);
$this->assertEquals($reference->toku_id, $customer->toku_id);
}
#[Depends('testSave')]
public function testFetchByRut(Model\MediosPago\Toku\Customer $reference): void
public function testFetchByRut(Model\Venta\MediosPago\Toku\Customer $reference): void
{
$result = [
'id' => $reference->id,
@ -110,7 +110,7 @@ class CustomerTest extends TestCase
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Customer($this->connection, $this->personaService);
$repository = new Repository\Venta\MediosPago\Toku\Customer($this->connection, $this->personaService);
$customer = $repository->fetchByRut($this->persona->rut);
$this->assertEquals($reference->id, $customer->id);
@ -118,7 +118,7 @@ class CustomerTest extends TestCase
$this->assertEquals($reference->toku_id, $customer->toku_id);
}
#[Depends('testSave')]
public function testFetchByTokuId(Model\MediosPago\Toku\Customer $reference): void
public function testFetchByTokuId(Model\Venta\MediosPago\Toku\Customer $reference): void
{
$result = [
'id' => $reference->id,
@ -129,7 +129,7 @@ class CustomerTest extends TestCase
->disableOriginalConstructor()->getMock();
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Customer($this->connection, $this->personaService);
$repository = new Repository\Venta\MediosPago\Toku\Customer($this->connection, $this->personaService);
$customer = $repository->fetchByTokuId($reference->toku_id);
$this->assertEquals($reference->id, $customer->id);

View File

@ -1,13 +1,13 @@
<?php
namespace Tests\Unit\Repository\MediosPago\Toku;
namespace Tests\Unit\Repository\Venta\MediosPago\Toku;
use PDO;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Define;
use Incoviba\Model;
use Incoviba\Repository;
use PDO;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
class InvoiceTest extends TestCase
{
@ -38,7 +38,7 @@ class InvoiceTest extends TestCase
public function testCreate(): void
{
$repository = new Repository\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$faker = Faker\Factory::create();
$data = [
@ -51,9 +51,9 @@ class InvoiceTest extends TestCase
$this->assertEquals($this->cuota->id, $invoice->cuota->id);
$this->assertEquals($data['toku_id'], $invoice->toku_id);
}
public function testSave(): Model\MediosPago\Toku\Invoice
public function testSave(): Model\Venta\MediosPago\Toku\Invoice
{
$repository = new Repository\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$faker = Faker\Factory::create();
$data = [
@ -70,7 +70,7 @@ class InvoiceTest extends TestCase
return $invoice;
}
#[Depends('testSave')]
public function testFetch(Model\MediosPago\Toku\Invoice $reference): void
public function testFetch(Model\Venta\MediosPago\Toku\Invoice $reference): void
{
$result = [
'id' => $reference->id,
@ -82,16 +82,16 @@ class InvoiceTest extends TestCase
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$invoice = $repository->fetchById($reference->id);
$this->assertInstanceOf(Model\MediosPago\Toku\Invoice::class, $invoice);
$this->assertInstanceOf(Model\Venta\MediosPago\Toku\Invoice::class, $invoice);
$this->assertEquals($reference->id, $invoice->id);
$this->assertEquals($this->cuota->id, $invoice->cuota->id);
$this->assertEquals($reference->toku_id, $invoice->toku_id);
}
#[Depends('testSave')]
public function testFetchByCuota(Model\MediosPago\Toku\Invoice $reference): void
public function testFetchByCuota(Model\Venta\MediosPago\Toku\Invoice $reference): void
{
$result = [
'id' => $reference->id,
@ -103,7 +103,7 @@ class InvoiceTest extends TestCase
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$invoice = $repository->fetchByCuota($this->cuota->id);
$this->assertEquals($reference->id, $invoice->id);
@ -111,7 +111,7 @@ class InvoiceTest extends TestCase
$this->assertEquals($reference->toku_id, $invoice->toku_id);
}
#[Depends('testSave')]
public function testFetchByTokuId(Model\MediosPago\Toku\Invoice $reference): void
public function testFetchByTokuId(Model\Venta\MediosPago\Toku\Invoice $reference): void
{
$result = [
'id' => $reference->id,
@ -123,7 +123,7 @@ class InvoiceTest extends TestCase
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Invoice($this->connection, $this->cuotaRepository);
$invoice = $repository->fetchByTokuId($reference->toku_id);
$this->assertEquals($reference->id, $invoice->id);

View File

@ -1,13 +1,13 @@
<?php
namespace Tests\Unit\Repository\MediosPago\Toku;
namespace Tests\Unit\Repository\Venta\MediosPago\Toku;
use PDO;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Define;
use Incoviba\Model;
use Incoviba\Repository;
use PDO;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
class SubscriptionTest extends TestCase
{
@ -38,7 +38,7 @@ class SubscriptionTest extends TestCase
public function testCreate(): void
{
$repository = new Repository\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$faker = Faker\Factory::create();
$data = [
@ -50,9 +50,9 @@ class SubscriptionTest extends TestCase
$this->assertEquals($this->venta->id, $subscription->venta->id);
$this->assertEquals($data['toku_id'], $subscription->toku_id);
}
public function testSave(): Model\MediosPago\Toku\Subscription
public function testSave(): Model\Venta\MediosPago\Toku\Subscription
{
$repository = new Repository\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$faker = Faker\Factory::create();
$data = [
@ -69,7 +69,7 @@ class SubscriptionTest extends TestCase
return $subscription;
}
#[Depends('testSave')]
public function testFetch(Model\MediosPago\Toku\Subscription $reference): void
public function testFetch(Model\Venta\MediosPago\Toku\Subscription $reference): void
{
$result = [
'id' => $reference->id,
@ -82,15 +82,15 @@ class SubscriptionTest extends TestCase
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$subscription = $repository->fetchById($reference->id);
$this->assertInstanceOf(Model\MediosPago\Toku\Subscription::class, $subscription);
$this->assertInstanceOf(Model\Venta\MediosPago\Toku\Subscription::class, $subscription);
$this->assertEquals($reference->id, $subscription->id);
$this->assertEquals($this->venta->id, $subscription->venta->id);
$this->assertEquals($reference->toku_id, $subscription->toku_id);
}
#[Depends('testSave')]
public function testFetchByVenta(Model\MediosPago\Toku\Subscription $reference): void
public function testFetchByVenta(Model\Venta\MediosPago\Toku\Subscription $reference): void
{
$result = [
'id' => $reference->id,
@ -103,14 +103,14 @@ class SubscriptionTest extends TestCase
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$subscription = $repository->fetchByVenta($this->venta->id);
$this->assertEquals($reference->id, $subscription->id);
$this->assertEquals($this->venta->id, $subscription->venta->id);
$this->assertEquals($reference->toku_id, $subscription->toku_id);
}
#[Depends('testSave')]
public function testFetchByTokuId(Model\MediosPago\Toku\Subscription $reference): void
public function testFetchByTokuId(Model\Venta\MediosPago\Toku\Subscription $reference): void
{
$result = [
'id' => $reference->id,
@ -123,7 +123,7 @@ class SubscriptionTest extends TestCase
$resultSet->method('fetch')->willReturn($result);
$this->connection->method('execute')->willReturn($resultSet);
$repository = new Repository\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$repository = new Repository\Venta\MediosPago\Toku\Subscription($this->connection, $this->ventaRepository);
$subscription = $repository->fetchByTokuId($reference->toku_id);
$this->assertEquals($reference->id, $subscription->id);
$this->assertEquals($this->venta->id, $subscription->venta->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 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']);