add all controllers logic
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Frontend;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\Frontend\LandingPageService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LandingPageServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_dashboard_for_user_returns_guest(): void
|
||||
{
|
||||
$service = app(LandingPageService::class);
|
||||
$payload = $service->dashboardForUser(null);
|
||||
|
||||
$this->assertSame('guest', $payload['role']);
|
||||
}
|
||||
|
||||
public function test_dashboard_for_user_returns_admin(): void
|
||||
{
|
||||
$roleId = DB::table('roles')->insertGetId([
|
||||
'name' => 'admin',
|
||||
'priority' => 1,
|
||||
'is_active' => 1,
|
||||
]);
|
||||
|
||||
$user = User::query()->create([
|
||||
'firstname' => 'Admin',
|
||||
'lastname' => 'User',
|
||||
'email' => 'admin@example.com',
|
||||
'cellphone' => '5555555555',
|
||||
'address_street' => '123 Main',
|
||||
'city' => 'City',
|
||||
'state' => 'ST',
|
||||
'zip' => '12345',
|
||||
'accept_school_policy' => 1,
|
||||
'status' => 'Active',
|
||||
'password' => bcrypt('secret'),
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
DB::table('user_roles')->insert([
|
||||
'user_id' => $user->id,
|
||||
'role_id' => $roleId,
|
||||
]);
|
||||
|
||||
$service = app(LandingPageService::class);
|
||||
$payload = $service->dashboardForUser($user);
|
||||
|
||||
$this->assertSame('admin', $payload['role']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user