- Implemented the customer portal workflow progress component with detailed service progress tracking, including current status, workflow steps, and contact information. - Developed a management workflow analytics dashboard featuring key performance indicators, charts for revenue by branch, labor utilization, and recent quality issues. - Created tests for admin-only middleware to ensure proper access control for admin routes. - Added tests for customer portal view rendering and workflow integration, ensuring the workflow service operates correctly through various stages. - Introduced a .gitignore file for the debugbar storage directory to prevent unnecessary files from being tracked.
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Tests\TestCase;
|
|
|
|
class AdminOnlyMiddlewareTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
// Register a dummy route protected by admin.only to exercise middleware
|
|
Route::middleware(['web', 'auth', 'admin.only'])->get('/_admin-only-test', function () {
|
|
return 'ok';
|
|
});
|
|
}
|
|
|
|
public function test_guest_is_redirected_to_login(): void
|
|
{
|
|
$this->get('/_admin-only-test')->assertRedirect('/login');
|
|
}
|
|
|
|
public function test_customer_is_redirected_to_customer_portal(): void
|
|
{
|
|
$user = \Mockery::mock(User::class)->makePartial();
|
|
$user->shouldReceive('isCustomer')->andReturn(true);
|
|
$this->be($user);
|
|
$this->get('/_admin-only-test')->assertRedirect('/customer-portal');
|
|
}
|
|
|
|
public function test_admin_passes_through(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
if (method_exists($user, 'assignRole')) {
|
|
$user->assignRole('admin');
|
|
}
|
|
$this->actingAs($user);
|
|
$this->get('/_admin-only-test')->assertOk();
|
|
}
|
|
}
|