Merge pull request 'fix/details-incorrectly-sent-to-toku' (#38) from fix/details-incorrectly-sent-to-toku into develop
Reviewed-on: #38
This commit is contained in:
@ -33,7 +33,7 @@ Editar Propietario
|
|||||||
<div class="fields">
|
<div class="fields">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="calle">Dirección</label>
|
<label for="calle">Dirección</label>
|
||||||
<input type="text" name="calle" id="calle" value="{'{$propietario->datos->direccion->calle}}" />
|
<input type="text" name="calle" id="calle" value="{{$propietario->datos->direccion->calle}}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="numero">Número</label>
|
<label for="numero">Número</label>
|
||||||
|
@ -92,7 +92,6 @@ class Persona extends Ideal\Service
|
|||||||
throw new Create(__CLASS__, $exception);
|
throw new Create(__CLASS__, $exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$this->addDatos($persona, $data);
|
$this->addDatos($persona, $data);
|
||||||
|
|
||||||
|
@ -103,7 +103,11 @@ class Customer extends AbstractEndPoint
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!str_starts_with($value, '+')) {
|
if (!str_starts_with($value, '+')) {
|
||||||
$value = "+56{$value}";
|
if (str_starts_with($value, '56')) {
|
||||||
|
$value = "+{$value}";
|
||||||
|
} else {
|
||||||
|
$value = "+56{$value}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$params[$key] = $value;
|
$params[$key] = $value;
|
||||||
continue;
|
continue;
|
||||||
|
@ -104,7 +104,6 @@ class Propietario extends Service
|
|||||||
} catch (EmptyResult) {
|
} catch (EmptyResult) {
|
||||||
try {
|
try {
|
||||||
$propietario = $this->propietarioRepository->create($filtered_data);
|
$propietario = $this->propietarioRepository->create($filtered_data);
|
||||||
$this->logger->info('Propietario', ['propietario' => $propietario]);
|
|
||||||
$propietario = $this->propietarioRepository->save($propietario);
|
$propietario = $this->propietarioRepository->save($propietario);
|
||||||
} catch (PDOException $exception) {
|
} catch (PDOException $exception) {
|
||||||
throw new Create(__CLASS__, $exception);
|
throw new Create(__CLASS__, $exception);
|
||||||
|
@ -5,12 +5,10 @@ use Psr\Log\LoggerInterface;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Faker;
|
use Faker;
|
||||||
use Incoviba\Common\Implement;
|
use Incoviba\Common\Implement;
|
||||||
use Incoviba\Exception\ServiceAction;
|
|
||||||
use Incoviba\Model;
|
use Incoviba\Model;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Service;
|
use Incoviba\Service;
|
||||||
use Incoviba\Common\Define;
|
use Tests\Extension\Faker\Provider\Rut;
|
||||||
use Incoviba\Common\Ideal;
|
|
||||||
|
|
||||||
class PersonaTest extends TestCase
|
class PersonaTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -51,10 +49,11 @@ class PersonaTest extends TestCase
|
|||||||
$personaService = new Service\Persona($this->logger, $this->personaRepository, $this->datosPersonaRepository,
|
$personaService = new Service\Persona($this->logger, $this->personaRepository, $this->datosPersonaRepository,
|
||||||
$this->propietarioRepository, $this->direccionService);
|
$this->propietarioRepository, $this->direccionService);
|
||||||
$faker = Faker\Factory::create('es_ES');
|
$faker = Faker\Factory::create('es_ES');
|
||||||
$digit = $faker->boolean(100-round(1/11*100)) ? $faker->randomNumber(1) : 'K';
|
$faker->addProvider(new Rut($faker));
|
||||||
|
$rut = $faker->rut(false, false);
|
||||||
$data = [
|
$data = [
|
||||||
'rut' => $faker->randomNumber(8),
|
'rut' => $rut,
|
||||||
'digito' => $digit,
|
'digito' => $faker->digitoVerificador($rut),
|
||||||
'nombres' => $faker->name(),
|
'nombres' => $faker->name(),
|
||||||
'apellido_paterno' => $faker->lastName(),
|
'apellido_paterno' => $faker->lastName(),
|
||||||
'apellido_materno' => $faker->lastName(),
|
'apellido_materno' => $faker->lastName(),
|
||||||
@ -62,4 +61,64 @@ class PersonaTest extends TestCase
|
|||||||
$persona = $personaService->add($data);
|
$persona = $personaService->add($data);
|
||||||
$this->assertEquals($data['rut'], $persona->rut);
|
$this->assertEquals($data['rut'], $persona->rut);
|
||||||
}
|
}
|
||||||
|
public function testGetById(): void
|
||||||
|
{
|
||||||
|
$faker = Faker\Factory::create('es_ES');
|
||||||
|
$faker->addProvider(new Rut($faker));
|
||||||
|
$direccion = $this->getMockBuilder(Model\Direccion::class)
|
||||||
|
->disableOriginalConstructor()->getMock();
|
||||||
|
$direccion->id = $faker->randomNumber(2);
|
||||||
|
$datos = new Model\Venta\Datos();
|
||||||
|
$datos->direccion = $direccion;
|
||||||
|
$datos->telefono = $faker->randomNumber(8);
|
||||||
|
$datos->email = $faker->email();
|
||||||
|
$datos->sexo = $faker->randomElement(['M', 'F']);
|
||||||
|
$rut = $faker->rut(false, false);
|
||||||
|
$propietario = new Model\Venta\Propietario();
|
||||||
|
$propietario->rut = $rut;
|
||||||
|
$propietario->dv = $faker->digitoVerificador($rut);
|
||||||
|
$propietario->nombres = $faker->name();
|
||||||
|
$propietario->apellidos['paterno'] = $faker->lastName();
|
||||||
|
$propietario->apellidos['materno'] = $faker->lastName();
|
||||||
|
$propietario->datos = $datos;
|
||||||
|
$propietarioRepository = $this->getMockBuilder(Repository\Venta\Propietario::class)
|
||||||
|
->disableOriginalConstructor()->getMock();
|
||||||
|
$personaRepository = $this->getMockBuilder(Repository\Persona::class)
|
||||||
|
->disableOriginalConstructor()->getMock();
|
||||||
|
$personaRepository->method('fetchById')->willThrowException(new Implement\Exception\EmptyResult(''));
|
||||||
|
$personaRepository->method('create')->willReturnCallback(function($data) {
|
||||||
|
$persona = new Model\Persona();
|
||||||
|
$persona->rut = $data['rut'];
|
||||||
|
$persona->digito = $data['digito'];
|
||||||
|
$persona->nombres = $data['nombres'];
|
||||||
|
$persona->apellidoPaterno = $data['apellido_paterno'];
|
||||||
|
$persona->apellidoMaterno = $data['apellido_materno'];
|
||||||
|
return $persona;
|
||||||
|
});
|
||||||
|
$personaRepository->method('save')->willReturnArgument(0);
|
||||||
|
$datosPersona = new Model\Persona\Datos();
|
||||||
|
$datosPersona->direccion = $direccion;
|
||||||
|
$datosPersona->telefono = $datos->telefono;
|
||||||
|
$datosPersona->email = $datos->email;
|
||||||
|
$datosPersona->sexo = $datos->sexo;
|
||||||
|
$datosPersonaRepository = $this->getMockBuilder(Repository\Persona\Datos::class)
|
||||||
|
->disableOriginalConstructor()->getMock();
|
||||||
|
$datosPersonaRepository->method('fetchByPersona')->willReturn($datosPersona);
|
||||||
|
$propietarioRepository->method('fetchById')->willReturn($propietario);
|
||||||
|
$direccionService = $this->getMockBuilder(Service\Direccion::class)
|
||||||
|
->disableOriginalConstructor()->getMock();
|
||||||
|
$direccionService->method('add')->willReturn($direccion);
|
||||||
|
$personaService = new Service\Persona($this->logger, $personaRepository, $datosPersonaRepository,
|
||||||
|
$propietarioRepository, $direccionService);
|
||||||
|
$persona = $personaService->getById($rut);
|
||||||
|
$this->assertEquals($rut, $persona->rut);
|
||||||
|
$this->assertEquals($propietario->dv, $persona->digito);
|
||||||
|
$this->assertEquals($propietario->nombres, $persona->nombres);
|
||||||
|
$this->assertEquals($propietario->apellidos['paterno'], $persona->apellidoPaterno);
|
||||||
|
$this->assertEquals($propietario->apellidos['materno'], $persona->apellidoMaterno);
|
||||||
|
$this->assertEquals($datos->direccion, $persona->datos->direccion);
|
||||||
|
$this->assertEquals($datos->telefono, $persona->datos->telefono);
|
||||||
|
$this->assertEquals($datos->email, $persona->datos->email);
|
||||||
|
$this->assertEquals($datos->sexo, $persona->datos->sexo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user