up
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\Models\Confeccion;
|
||||
use App\Models\Recepcion;
|
||||
use App\Models\Proveedor;
|
||||
use App\Models\OrdenProduccion;
|
||||
|
||||
class ConfeccionRecepcionesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function recibido_total_and_faltantes_are_calculated_from_recepciones()
|
||||
{
|
||||
$proveedor = Proveedor::factory()->create(['categoria' => 'talleres']);
|
||||
$op = OrdenProduccion::factory()->create(['cantidad_total' => 100]);
|
||||
|
||||
$conf = Confeccion::create([
|
||||
'proveedor_id' => $proveedor->id,
|
||||
'orden_produccion_id' => $op->id,
|
||||
'cantidad_enviada' => 100,
|
||||
]);
|
||||
|
||||
// Crear recepciones 40 y 40
|
||||
Recepcion::create(['referencia_type' => Confeccion::class,'referencia_id' => $conf->id,'cantidad' => 40]);
|
||||
Recepcion::create(['referencia_type' => Confeccion::class,'referencia_id' => $conf->id,'cantidad' => 40]);
|
||||
|
||||
$conf->refresh();
|
||||
|
||||
$this->assertEquals(80, $conf->recibido_total);
|
||||
$this->assertEquals(20, $conf->faltantes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user