Pruebas de modelos
This commit is contained in:
53
app/tests/unit/src/Model/MediosPago/Toku/CustomerTest.php
Normal file
53
app/tests/unit/src/Model/MediosPago/Toku/CustomerTest.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
namespace Test\Unit\Model\MediosPago\Toku;
|
||||||
|
|
||||||
|
use Faker;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Incoviba\Model\MediosPago\Toku\Customer;
|
||||||
|
use Incoviba\Model\Persona;
|
||||||
|
|
||||||
|
class CustomerTest extends TestCase
|
||||||
|
{
|
||||||
|
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 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, $persona->digito]),
|
||||||
|
'toku_id' => $toku_id
|
||||||
|
]);
|
||||||
|
$this->assertJsonStringEqualsJsonString($expected, json_encode($customer));
|
||||||
|
}
|
||||||
|
}
|
50
app/tests/unit/src/Model/MediosPago/Toku/InvoiceTest.php
Normal file
50
app/tests/unit/src/Model/MediosPago/Toku/InvoiceTest.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Unit\Model\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\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\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));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Unit\Model\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\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\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));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user