Refactor Prop model to use enum for data types; remove PropDataType model and update related requests and migrations
This commit is contained in:
45
tests/Feature/Prop/PropControllerTest.php
Normal file
45
tests/Feature/Prop/PropControllerTest.php
Normal 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']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user