Files
shopit-back/tests/Feature/Prop/PropControllerTest.php

46 lines
1.2 KiB
PHP

<?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']);
}
}