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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user