feature/cierres (#25)

Varios cambios

Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl>
Reviewed-on: #25
This commit is contained in:
2025-07-22 13:18:00 +00:00
parent ba57cad514
commit 307f2ac7d7
418 changed files with 20045 additions and 984 deletions

View File

@ -0,0 +1,69 @@
<?php
namespace Test\Unit\Model\Venta\MediosPago\Toku;
use Faker;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Tests\Extension\ObjectHasMethodTrait;
use Incoviba\Model\Persona;
use Incoviba\Model\Venta\MediosPago\Toku\Customer;
class CustomerTest extends TestCase
{
use ObjectHasMethodTrait;
public static function dataProperties(): array
{
return [
['id'],
['persona'],
['toku_id']
];
}
#[DataProvider('dataProperties')]
public function testProperties(string $propertyName): void
{
$customer = new Customer();
$this->assertObjectHasProperty($propertyName, $customer);
}
public static function dataMethods(): array
{
return [
['rut']
];
}
#[DataProvider('dataMethods')]
public function testMethods(string $methodName): void
{
$customer = new Customer();
$this->assertObjectHasMethod($methodName, $customer);
}
public function testJson(): void
{
$faker = Faker\Factory::create();
$persona = $this->getMockBuilder(Persona::class)->disableOriginalConstructor()->getMock();
$persona->rut = $faker->randomNumber(8);
$persona->digito = 'k';
$toku_id = $faker->ean13();
$id = $faker->randomNumber(4);
$customer = new Customer();
$customer->id = $id;
$customer->persona = $persona;
$customer->toku_id = $toku_id;
$expected = json_encode([
'id' => $id,
'rut' => implode('', [$persona->rut, strtoupper($persona->digito)]),
'toku_id' => $toku_id
]);
$this->assertJsonStringEqualsJsonString($expected, json_encode($customer));
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Tests\Unit\Model\Venta\MediosPago\Toku;
use Faker;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Incoviba\Model;
class InvoiceTest extends TestCase
{
public static function dataProperties(): array
{
return [
['id'],
['cuota'],
['toku_id'],
];
}
#[DataProvider('dataProperties')]
public function testProperties(string $propertyName): void
{
$invoice = new Model\Venta\MediosPago\Toku\Invoice();
$this->assertObjectHasProperty($propertyName, $invoice);
}
public function testJson(): void
{
$faker = Faker\Factory::create();
$cuota = $this->getMockBuilder(Model\Venta\Cuota::class)
->disableOriginalConstructor()->getMock();
$cuota->id = $faker->randomNumber();
$toku_id = $faker->ean13();
$id = $faker->randomNumber();
$invoice = new Model\Venta\MediosPago\Toku\Invoice();
$invoice->id = $id;
$invoice->cuota = $cuota;
$invoice->toku_id = $toku_id;
$expected = json_encode([
'id' => $id,
'cuota_id' => $cuota->id,
'toku_id' => $toku_id,
]);
$this->assertEquals($expected, json_encode($invoice));
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Tests\Unit\Model\Venta\MediosPago\Toku;
use Faker;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Incoviba\Model;
class SubscriptionTest extends TestCase
{
public static function dataProperties(): array
{
return [
['id'],
['venta'],
['toku_id'],
];
}
#[DataProvider('dataProperties')]
public function testProperties(string $propertyName): void
{
$subscription = new Model\Venta\MediosPago\Toku\Subscription();
$this->assertObjectHasProperty($propertyName, $subscription);
}
public function testJson(): void
{
$faker = Faker\Factory::create();
$venta = $this->getMockBuilder(Model\Venta::class)->disableOriginalConstructor()->getMock();
$venta->id = $faker->randomNumber();
$toku_id = $faker->ean13();
$id = $faker->randomNumber();
$subscription = new Model\Venta\MediosPago\Toku\Subscription();
$subscription->id = $id;
$subscription->venta = $venta;
$subscription->toku_id = $toku_id;
$expected = json_encode([
'id' => $id,
'venta_id' => $venta->id,
'toku_id' => $toku_id,
]);
$this->assertEquals($expected, json_encode($subscription));
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Tests\Unit\Model\Venta;
use Incoviba\Model\Venta\Promotion;
use Tests\Extension\AbstractModel;
use Tests\Extension\testMethodsTrait;
use Tests\Extension\testPropertiesTrait;
class PromotionTest extends AbstractModel
{
use testPropertiesTrait, testMethodsTrait;
protected function setUp(): void
{
$this->model = new Promotion();
$this->properties = ['description', 'amount', 'startDate', 'endDate', 'validUntil', 'type', 'state'];
$this->methods = ['projects', 'brokers', 'unitTypes', 'unitLines', 'units', 'value'];
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Tests\Unit\Model\Venta\Reservation;
use Incoviba\Model\Venta\Reservation\State;
use Tests\Extension\AbstractModel;
use Tests\Extension\testPropertiesTrait;
class StateTest extends AbstractModel
{
use testPropertiesTrait;
protected function setUp(): void
{
$this->model = new State();
$this->properties = ['reservation', 'date', 'type'];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Tests\Unit\Model\Venta;
use Incoviba\Model\Venta\Reservation;
use Tests\Extension\AbstractModel;
use Tests\Extension\testMethodsTrait;
use Tests\Extension\testPropertiesTrait;
class ReservationTest extends AbstractModel
{
use testPropertiesTrait, testMethodsTrait;
protected function setUp(): void
{
$this->model = new Reservation();
$this->properties = ['buyer', 'date', 'units', 'promotions', 'broker'];
$this->methods = ['states', 'currentState', 'addUnit', 'removeUnit', 'findUnit', 'hasUnit'];
}
}