46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Tenant;
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class TenantPropControllerTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_it_creates_a_tenant_prop(): void
|
|
{
|
|
$response = $this->postJson('/api/tenant-props', [
|
|
'codigo' => 'primary_color',
|
|
'nombre' => 'Primary Color',
|
|
'descripcion' => 'Brand color',
|
|
'is_required' => false,
|
|
'data_type' => 'string',
|
|
]);
|
|
|
|
$response
|
|
->assertCreated()
|
|
->assertJsonPath('codigo', 'primary_color')
|
|
->assertJsonPath('data_type', 'string');
|
|
|
|
$this->assertDatabaseHas('tenant_props', [
|
|
'codigo' => 'primary_color',
|
|
'data_type' => 'string',
|
|
]);
|
|
}
|
|
|
|
public function test_it_rejects_unknown_data_type(): void
|
|
{
|
|
$response = $this->postJson('/api/tenant-props', [
|
|
'codigo' => 'primary_color',
|
|
'nombre' => 'Primary Color',
|
|
'data_type' => 'unsupported',
|
|
]);
|
|
|
|
$response
|
|
->assertUnprocessable()
|
|
->assertJsonValidationErrors(['data_type']);
|
|
}
|
|
}
|