updates for admin area
This commit is contained in:
@@ -26,11 +26,12 @@ class AccountAndAdminRoutesTest extends TestCase
|
||||
$admin = User::factory()->create();
|
||||
$admin->assignRole('admin');
|
||||
|
||||
$sections = ['users', 'djs', 'clients', 'bookings', 'payments', 'reviews', 'messages', 'notifications', 'support', 'reports', 'content', 'roles', 'privacy', 'settings'];
|
||||
$sections = ['users', 'clients', 'djs', 'businesses', 'bookings', 'payments', 'reviews', 'messages', 'notifications', 'support', 'reports', 'content', 'roles', 'privacy', 'settings'];
|
||||
|
||||
$this->actingAs($admin)->get('/admin')->assertSuccessful();
|
||||
foreach ($sections as $section) {
|
||||
$this->actingAs($admin)->get('/admin/'.$section)->assertSuccessful();
|
||||
$this->actingAs($admin)->get('/admin/'.$section.'/create')->assertSuccessful();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\AppSetting;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminCrudTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutMiddleware(PreventRequestForgery::class);
|
||||
Role::create(['name' => 'admin', 'guard_name' => 'web']);
|
||||
}
|
||||
|
||||
public function test_admin_can_create_edit_and_delete_setting(): void
|
||||
{
|
||||
$admin = User::factory()->create();
|
||||
$admin->assignRole('admin');
|
||||
|
||||
$this->actingAs($admin)->post('/admin/settings', [
|
||||
'label' => 'Marketplace name',
|
||||
'key' => 'marketplace.name',
|
||||
'value' => 'BeatBook',
|
||||
'type' => 'text',
|
||||
'group' => 'general',
|
||||
'description' => 'Displayed marketplace name.',
|
||||
])->assertRedirect('/admin/settings');
|
||||
|
||||
$setting = AppSetting::firstOrFail();
|
||||
$this->assertSame('BeatBook', $setting->value);
|
||||
|
||||
$this->actingAs($admin)->put('/admin/settings/'.$setting->id, [
|
||||
'label' => 'Marketplace name',
|
||||
'key' => 'marketplace.name',
|
||||
'value' => 'BeatBook UK',
|
||||
'type' => 'text',
|
||||
'group' => 'general',
|
||||
'description' => 'Displayed marketplace name.',
|
||||
])->assertRedirect('/admin/settings');
|
||||
|
||||
$this->assertDatabaseHas('app_settings', ['id' => $setting->id, 'value' => 'BeatBook UK']);
|
||||
$this->actingAs($admin)->delete('/admin/settings/'.$setting->id)->assertRedirect('/admin/settings');
|
||||
$this->assertDatabaseMissing('app_settings', ['id' => $setting->id]);
|
||||
}
|
||||
|
||||
public function test_admin_can_create_client(): void
|
||||
{
|
||||
$admin = User::factory()->create();
|
||||
$admin->assignRole('admin');
|
||||
|
||||
$this->actingAs($admin)->post('/admin/clients', [
|
||||
'name' => 'New Client',
|
||||
'email' => 'new-client@example.test',
|
||||
'phone' => '01234567890',
|
||||
'password' => 'password12345',
|
||||
'marketing_opt_in' => '0',
|
||||
])->assertRedirect('/admin/clients');
|
||||
|
||||
$client = User::where('email', 'new-client@example.test')->firstOrFail();
|
||||
$this->assertTrue($client->hasRole('client'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user