70 lines
1.7 KiB
PHP
70 lines
1.7 KiB
PHP
<?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;
|
|
use Tests\Extension\ObjectHasMethodTrait;
|
|
|
|
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));
|
|
}
|
|
}
|