Reservation Test
This commit is contained in:
@ -3,18 +3,22 @@ namespace Tests\Unit\Service;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Faker\Factory;
|
||||
use Incoviba\Service\Valor;
|
||||
use Incoviba\Service;
|
||||
|
||||
class ValorTest extends TestCase
|
||||
{
|
||||
protected Service\UF $ufService;
|
||||
protected static float $staticUF = 35498.76;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->ufService = $this->getMockBuilder(Service\UF::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->ufService->method('get')->willReturn(35000.0);
|
||||
$faker = Factory::create();
|
||||
$this->ufService->method('get')->willReturn(self::$staticUF);
|
||||
}
|
||||
|
||||
public static function cleanDataProvider(): array
|
||||
@ -55,14 +59,14 @@ class ValorTest extends TestCase
|
||||
$result = $valorService->toUF($input, $date);
|
||||
|
||||
$this->assertIsFloat($result);
|
||||
$this->assertEquals($input / 35000, $result);
|
||||
$this->assertEquals($input / self::$staticUF, $result);
|
||||
}
|
||||
|
||||
public static function pesosDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[1000.01, 1000.01*35000, false],
|
||||
[1000, 1000*35000, true],
|
||||
[1000.01, round(1000.01*self::$staticUF), false],
|
||||
[1000, round(1000*self::$staticUF), true],
|
||||
['1000', 1000, false],
|
||||
];
|
||||
}
|
||||
|
@ -54,6 +54,11 @@ class ReservationTest extends TestCase
|
||||
$persona->rut = $data['rut'];
|
||||
return $persona;
|
||||
});
|
||||
$this->personaService->method('getById')->willReturnCallback(function($id) {
|
||||
$persona = new Model\Persona();
|
||||
$persona->rut = $id;
|
||||
return $persona;
|
||||
});
|
||||
$this->brokerService = $this->getMockBuilder(Service\Proyecto\Broker::class)
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->promotionService = $this->getMockBuilder(Service\Venta\Promotion::class)
|
||||
@ -83,7 +88,7 @@ class ReservationTest extends TestCase
|
||||
$unitsValue = [];
|
||||
$unitsCount = $faker->numberBetween(1, 10);
|
||||
for ($i = 0; $i < $unitsCount; $i++) {
|
||||
$units[] = $faker->numberBetween(1, 100);
|
||||
$units[] = $faker->unique()->numberBetween(1, 100);
|
||||
$unitsValue[] = $faker->randomFloat(2, 1000, 10000);
|
||||
}
|
||||
$digit = $faker->boolean(100-round(1/11*100)) ? $faker->randomNumber(1) : 'K';
|
||||
|
Reference in New Issue
Block a user