createSchema(); DB::table('admin_website_types')->insert(['codigo' => 'shopit']); DB::table('storefront_website_types')->insert(['codigo' => 'shopit']); DB::table('menues')->insert([ ['code' => 'product.detail'], ['code' => 'help.faq'], ['code' => 'help.contact'], ['code' => 'account.tickets'], ['code' => 'event.index'], ]); $migration = require database_path('migrations/2026_09_24_000000_provision_mutual_smep_tenant.php'); $migration->up(); $migration->up(); $this->assertDatabaseCount('tenants', 1); $this->assertDatabaseHas('clients', [ 'code' => 'mutual_smep', 'name' => 'Mutual SMEP', ]); $this->assertDatabaseHas('tenants', [ 'codigo' => 'mutual_smep', 'nombre' => 'Mutual SMEP', 'dominio' => 'mutual-smep.localhost', 'site_title' => 'Tienda Mutual SMEP', 'primary_color' => '#4A7FF5', 'secondary_color' => '#0051A4', 'header_bg_color' => '#FFFFFF', 'footer_bg_color' => '#0051A4', 'admin_website_type_code' => 'shopit', 'storefront_website_type_code' => 'shopit', 'display_categories' => true, 'display_seach_bar' => true, 'display_cart' => true, 'cart_editing_policy' => 'quantity_and_remove', 'checkout_editing_policy' => 'disabled', ]); $this->assertSame([ 'mutual_smep_favicon.png', 'mutual_smep_footer.png', 'mutual_smep_header.png', ], DB::table('attachments')->orderBy('filename')->pluck('filename')->all()); DB::table('attachments')->orderBy('id')->each( fn (object $attachment) => Storage::disk('s3')->assertExists($attachment->path) ); $this->assertSame( ['instagram', 'facebook', 'whatsapp'], DB::table('tenant_social_media') ->where('tenant_code', 'mutual_smep') ->orderBy('orden') ->pluck('social_media_code') ->all(), ); $this->assertDatabaseHas('tenants_menues', [ 'tenant_code' => 'mutual_smep', 'menu_code' => 'product.detail', ]); $this->assertDatabaseMissing('tenants_menues', [ 'tenant_code' => 'mutual_smep', 'menu_code' => 'account.tickets', ]); $this->assertDatabaseMissing('tenants_menues', [ 'tenant_code' => 'mutual_smep', 'menu_code' => 'event.index', ]); $contact = json_decode( DB::table('tenants_menues') ->where('tenant_code', 'mutual_smep') ->where('menu_code', 'help.contact') ->value('static_content'), true, flags: JSON_THROW_ON_ERROR, ); $this->assertSame('https://wa.me/5493412474530', $contact['whatsapp']['whatsapp_url']); $this->assertSame('San Lorenzo 1543, Rosario, Santa Fe', $contact['locations']['rosario']['addresses'][0]['address']); $storedPaths = DB::table('attachments')->pluck('path')->all(); $migration->down(); $this->assertDatabaseMissing('tenants', ['codigo' => 'mutual_smep']); $this->assertDatabaseMissing('clients', ['code' => 'mutual_smep']); $this->assertDatabaseCount('attachments', 0); $this->assertDatabaseCount('tenant_social_media', 0); $this->assertDatabaseCount('tenants_menues', 0); foreach ($storedPaths as $storedPath) { Storage::disk('s3')->assertMissing($storedPath); } } private function createSchema(): void { Schema::create('clients', function (Blueprint $table): void { $table->id(); $table->string('code')->unique(); $table->string('name'); $table->timestamps(); }); Schema::create('attachments', function (Blueprint $table): void { $table->id(); $table->uuid('key'); $table->string('path'); $table->string('filename'); $table->string('type'); $table->string('mime_type'); $table->string('extension'); $table->unsignedBigInteger('size'); $table->timestamps(); }); Schema::create('admin_website_types', function (Blueprint $table): void { $table->id(); $table->string('codigo')->unique(); }); Schema::create('storefront_website_types', function (Blueprint $table): void { $table->id(); $table->string('codigo')->unique(); }); Schema::create('tenants', function (Blueprint $table): void { $table->id(); $table->foreignId('client_id'); $table->string('codigo')->unique(); $table->string('nombre'); $table->string('timezone'); $table->string('dominio'); $table->string('base_path'); $table->string('site_title'); $table->string('address'); $table->string('phone'); $table->string('primary_color'); $table->string('secondary_color'); $table->string('danger_color'); $table->string('success_color'); $table->string('header_bg_color'); $table->string('footer_bg_color'); $table->foreignId('header_logo_id'); $table->foreignId('footer_logo_id'); $table->foreignId('favicon_id'); $table->string('admin_website_type_code'); $table->string('storefront_website_type_code'); $table->boolean('display_categories'); $table->boolean('display_seach_bar'); $table->boolean('display_cart'); $table->string('cart_editing_policy'); $table->string('checkout_editing_policy'); $table->timestamps(); }); Schema::create('social_media', function (Blueprint $table): void { $table->id(); $table->string('code')->unique(); $table->string('icon'); $table->string('name'); $table->timestamps(); }); Schema::create('tenant_social_media', function (Blueprint $table): void { $table->id(); $table->string('tenant_code'); $table->string('social_media_code'); $table->string('url'); $table->unsignedInteger('orden'); $table->timestamps(); $table->unique(['tenant_code', 'social_media_code']); }); Schema::create('menues', function (Blueprint $table): void { $table->id(); $table->string('code')->unique(); }); Schema::create('tenants_menues', function (Blueprint $table): void { $table->id(); $table->string('tenant_code'); $table->string('menu_code'); $table->json('static_content')->nullable(); $table->timestamps(); $table->unique(['tenant_code', 'menu_code']); }); } }