up
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\Models\OrdenProduccion;
|
||||
use App\Models\TrasladoPrenda;
|
||||
|
||||
class OrdenProduccionAutoProductoTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function advancing_to_finalizada_creates_producto_with_codigo_barras()
|
||||
{
|
||||
$op = OrdenProduccion::create([
|
||||
'prenda_modelo' => 'Test Model',
|
||||
'referencia' => 'REF-T',
|
||||
'cantidad_total' => 10,
|
||||
'fecha_inicio' => now()->toDateString(),
|
||||
'fecha_entrega_estimada' => now()->addDays(7)->toDateString(),
|
||||
'estado' => 'en_acabados',
|
||||
]);
|
||||
|
||||
// Crear traslado a bodega para que al finalizar se cree inventario y producto
|
||||
TrasladoPrenda::create([
|
||||
'orden_produccion_id' => $op->id,
|
||||
'referencia_type' => OrdenProduccion::class,
|
||||
'referencia_id' => $op->id,
|
||||
'origen' => 'acabados',
|
||||
'destino' => 'bodega',
|
||||
'cantidad_enviada' => 10,
|
||||
'cantidad_recibida' => 10,
|
||||
'fecha_envio' => now(),
|
||||
'fecha_recepcion' => now(),
|
||||
'estado' => 'recibido',
|
||||
]);
|
||||
|
||||
$op->avanzarEstado(); // debe pasar a finalizada y crear inventario/producto
|
||||
|
||||
$op->refresh();
|
||||
|
||||
$this->assertEquals('finalizada', $op->estado);
|
||||
$this->assertNotNull($op->producto_id);
|
||||
|
||||
$producto = \App\Models\Producto::find($op->producto_id);
|
||||
|
||||
$this->assertNotNull($producto);
|
||||
$this->assertNotEmpty($producto->codigo_barras);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user