feat(seeder): add WebsiteTypeSeeder and update DatabaseSeeder to include it

This commit is contained in:
2026-07-29 14:42:03 -03:00
parent 04bf03fc2e
commit 5416c0fd61
3 changed files with 205 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
<?php
namespace Tests\Feature\Seeders;
use App\Domains\Tenant\Models\WebsiteType;
use Database\Seeders\WebsiteTypeSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class WebsiteTypeSeederTest extends TestCase
{
use RefreshDatabase;
public function test_it_seeds_website_types_and_their_config_schemas_idempotently(): void
{
$this->seed(WebsiteTypeSeeder::class);
$this->seed(WebsiteTypeSeeder::class);
$this->assertSame(2, WebsiteType::query()->count());
$shopIt = WebsiteType::query()
->where('codigo', 'shopit')
->with('extras')
->sole();
$this->assertSame('ShopIt', $shopIt->nombre);
$this->assertSame(['carousel'], $shopIt->extras->pluck('nombre')->all());
$this->assertSame([
'request_rules' => [
'$' => 'required|array|max:10',
'$.*' => 'required|image_or_base64|distinct',
],
'transforms' => [
'$.*' => [
'handler' => 'attachment',
'attachment_type' => 'image',
],
],
'database_rules' => [
'$' => 'required|array',
'$.*' => 'required|integer|distinct|exists:attachments,id',
],
], $shopIt->extras->sole()->config_schema);
$onTicket = WebsiteType::query()
->where('codigo', 'onticket')
->with('extras')
->sole();
$this->assertSame('OnTicket', $onTicket->nombre);
$this->assertEqualsCanonicalizing(
['heroConfig', 'eventConfig'],
$onTicket->extras->pluck('nombre')->all(),
);
$heroSchema = $onTicket->extras->firstWhere('nombre', 'heroConfig')->config_schema;
$this->assertSame([
'request_rules' => [
'$' => 'required|array',
'title_html' => 'nullable|string',
'description_html' => 'nullable|string',
'button_text' => 'nullable|string',
'button_href' => 'nullable|string',
'background_image_id' => 'nullable|image_or_base64',
],
'transforms' => [
'background_image_id' => [
'handler' => 'attachment',
'attachment_type' => 'image',
],
],
'database_rules' => [
'$' => 'required|array',
'title_html' => 'nullable|string',
'description_html' => 'nullable|string',
'button_text' => 'nullable|string',
'button_href' => 'nullable|string',
'background_image_id' => 'nullable|integer|exists:attachments,id',
],
], $heroSchema);
$eventSchema = $onTicket->extras->firstWhere('nombre', 'eventConfig')->config_schema;
$this->assertSame([
'request_rules' => [
'$' => 'required|array',
'title' => 'nullable|string',
'location' => 'nullable|string',
'dates' => 'nullable|array',
'dates.*' => 'required|date_format:Y-m-d|distinct',
],
'transforms' => [],
'database_rules' => [
'$' => 'required|array',
'title' => 'nullable|string',
'location' => 'nullable|string',
'dates' => 'nullable|array',
'dates.*' => 'required|date_format:Y-m-d|distinct',
],
], $eventSchema);
}
}