feat: Refactor bootstrap functionality by adding AdminApp and Tenant controllers, requests, resources, and services; remove deprecated event form components
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Forms;
|
||||
|
||||
use App\Domains\Auth\Models\User;
|
||||
use App\Domains\Authorization\Enums\RoleCode;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Tenant\Models\WebsiteType;
|
||||
use Database\Seeders\AuthorizationSeeder;
|
||||
use Database\Seeders\SocialMediaSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminAppEventFormControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->seed([AuthorizationSeeder::class, SocialMediaSeeder::class]);
|
||||
WebsiteType::query()->create([
|
||||
'codigo' => 'onticket',
|
||||
'nombre' => 'OnTicket',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_authentication_is_required(): void
|
||||
{
|
||||
$this->getJson('/api/v1/adminapp/forms/event')->assertUnauthorized();
|
||||
}
|
||||
|
||||
public function test_an_adminapp_user_can_get_the_event_form(): void
|
||||
{
|
||||
$tenant = Tenant::query()->create([
|
||||
'codigo' => 'acme',
|
||||
'nombre' => 'Acme',
|
||||
'dominio' => 'acme.test',
|
||||
'website_type_code' => 'onticket',
|
||||
]);
|
||||
Sanctum::actingAs(User::factory()->create([
|
||||
'rol_codigo' => RoleCode::AdminApp->value,
|
||||
'tenant_codigo' => $tenant->codigo,
|
||||
]));
|
||||
|
||||
$this->getJson('/api/v1/adminapp/forms/event')
|
||||
->assertOk()
|
||||
->assertJsonCount(4, 'data.social_media')
|
||||
->assertJsonPath('data.social_media.0.code', 'facebook')
|
||||
->assertJsonPath('data.social_media.0.name', 'Facebook')
|
||||
->assertJsonPath('data.social_media.0.icon', 'fa-brands fa-facebook')
|
||||
->assertJsonPath('data.social_media.3.code', 'linkedin');
|
||||
}
|
||||
|
||||
public function test_a_customer_cannot_get_the_event_form(): void
|
||||
{
|
||||
Sanctum::actingAs(User::factory()->create([
|
||||
'rol_codigo' => RoleCode::User->value,
|
||||
'tenant_codigo' => null,
|
||||
]));
|
||||
|
||||
$this->getJson('/api/v1/adminapp/forms/event')->assertForbidden();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace Tests\Feature\Tenant;
|
||||
|
||||
use App\Domains\Attachable\Models\Attachment;
|
||||
use App\Domains\Tenant\Models\WebsiteType;
|
||||
use Database\Seeders\SocialMediaSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -13,6 +14,7 @@ class BootstrapAdminAppControllerTest extends TestCase
|
||||
|
||||
public function test_it_publicly_bootstraps_the_admin_app_by_domain(): void
|
||||
{
|
||||
$this->seed(SocialMediaSeeder::class);
|
||||
$footerLogo = Attachment::factory()->create();
|
||||
|
||||
WebsiteType::query()->create([
|
||||
@@ -41,6 +43,10 @@ class BootstrapAdminAppControllerTest extends TestCase
|
||||
->assertJsonPath('data.login_header_footer_color', '#313131')
|
||||
->assertJsonPath('data.site_logo', null)
|
||||
->assertJsonPath('data.footer_logo', $footerLogo->getTemporaryUrl(1440))
|
||||
->assertJsonPath('data.forms.0.code', 'event')
|
||||
->assertJsonCount(4, 'data.forms.0.social_media')
|
||||
->assertJsonPath('data.forms.0.social_media.0.code', 'facebook')
|
||||
->assertJsonPath('data.forms.0.social_media.3.code', 'linkedin')
|
||||
->assertJsonMissingPath('data.codigo')
|
||||
->assertJsonMissingPath('data.nombre')
|
||||
->assertJsonMissingPath('data.dominio');
|
||||
|
||||
40
tests/Unit/Bootstrap/AdminAppBootstrapResourceTest.php
Normal file
40
tests/Unit/Bootstrap/AdminAppBootstrapResourceTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Bootstrap;
|
||||
|
||||
use App\Domains\Bootstrap\Resources\AdminAppBootstrapResource;
|
||||
use App\Domains\Tenant\Models\SocialMedia;
|
||||
use App\Domains\Tenant\Models\WebsiteType;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminAppBootstrapResourceTest extends TestCase
|
||||
{
|
||||
public function test_it_exposes_the_website_type_and_forms(): void
|
||||
{
|
||||
$websiteType = new WebsiteType([
|
||||
'codigo' => 'shopit',
|
||||
'nombre' => 'ShopIt',
|
||||
'dominio' => 'admin.shopit.test',
|
||||
]);
|
||||
$websiteType->setRelation('siteLogo', null);
|
||||
$websiteType->setRelation('footerLogo', null);
|
||||
$socialMedia = new SocialMedia([
|
||||
'code' => 'instagram',
|
||||
'name' => 'Instagram',
|
||||
'icon' => 'fa-brands fa-instagram',
|
||||
]);
|
||||
|
||||
$data = AdminAppBootstrapResource::make([
|
||||
'website_type' => $websiteType,
|
||||
'social_media' => new Collection([$socialMedia]),
|
||||
])->resolve(request());
|
||||
|
||||
$this->assertSame('shopit', $data['website_type_code']);
|
||||
$this->assertSame('event', $data['forms'][0]['code']);
|
||||
$this->assertSame(
|
||||
'instagram',
|
||||
$data['forms'][0]['social_media']->resolve(request())[0]['code']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Tenant;
|
||||
|
||||
use App\Domains\Tenant\Models\WebsiteType;
|
||||
use App\Domains\Tenant\Resources\AdminApp\BootstrapAdminAppResource;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BootstrapAdminAppResourceTest extends TestCase
|
||||
{
|
||||
public function test_it_exposes_the_website_type_code(): void
|
||||
{
|
||||
$websiteType = new WebsiteType([
|
||||
'codigo' => 'shopit',
|
||||
'nombre' => 'ShopIt',
|
||||
'dominio' => 'admin.shopit.test',
|
||||
]);
|
||||
$websiteType->setRelation('siteLogo', null);
|
||||
|
||||
$data = BootstrapAdminAppResource::make($websiteType)->resolve(request());
|
||||
|
||||
$this->assertSame('shopit', $data['codigo']);
|
||||
$this->assertSame('shopit', $data['website_type_code']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user