Refactor Prop model to use enum for data types; remove PropDataType model and update related requests and migrations

This commit is contained in:
2026-06-22 13:13:22 -03:00
parent 7075704dad
commit 55694b2048
12 changed files with 454 additions and 70 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace Tests\Feature\Prop;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PropControllerTest extends TestCase
{
use RefreshDatabase;
public function test_it_creates_a_prop_using_enum_data_type(): void
{
$response = $this->postJson('/api/prop-models/tenant/props', [
'codigo' => 'color_primario',
'nombre' => 'Color primario',
'is_required' => false,
'data_type' => 'string',
]);
$response
->assertCreated()
->assertJsonPath('propable_type', 'tenant')
->assertJsonPath('data_type', 'string');
$this->assertDatabaseHas('props', [
'codigo' => 'color_primario',
'data_type' => 'string',
]);
}
public function test_it_rejects_unknown_enum_data_type(): void
{
$response = $this->postJson('/api/prop-models/tenant/props', [
'codigo' => 'color_primario',
'nombre' => 'Color primario',
'is_required' => false,
'data_type' => 'unsupported-type',
]);
$response
->assertUnprocessable()
->assertJsonValidationErrors(['data_type']);
}
}