v7.0.0-beta.2 release
This commit is contained in:
1 parent
6595fd0eb5
commit
fa8eba7a0d
1165 files changed
+107118
-762127
No files matched your search
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace Tests\Unit\Console\Commands;
|
||||
|
||||
use App\Events\Dashboard\DashboardUpdated;
|
||||
use App\Services\DashboardService;
|
||||
use App\Events\GenericBroadcastEvent;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
@@ -21,43 +20,39 @@ class BroadcastDashboardResourcesTest extends TestCase
|
||||
|
||||
public function test_command_broadcasts_resources_update(): void
|
||||
{
|
||||
Event::fake([DashboardUpdated::class]);
|
||||
Event::fake([GenericBroadcastEvent::class]);
|
||||
|
||||
// 커맨드 실행
|
||||
$this->artisan('dashboard:broadcast-resources')
|
||||
->expectsOutput('시스템 리소스 정보가 브로드캐스트되었습니다.')
|
||||
->assertExitCode(0);
|
||||
|
||||
// 이벤트 디스패치 확인
|
||||
Event::assertDispatched(DashboardUpdated::class, function ($event) {
|
||||
return $event->type === 'resources';
|
||||
Event::assertDispatched(GenericBroadcastEvent::class, function ($event) {
|
||||
return $event->channel === 'core.admin.dashboard'
|
||||
&& $event->eventName === 'dashboard.resources.updated'
|
||||
&& $event->payload['type'] === 'resources';
|
||||
});
|
||||
}
|
||||
|
||||
public function test_command_sends_correct_resource_data(): void
|
||||
{
|
||||
Event::fake([DashboardUpdated::class]);
|
||||
Event::fake([GenericBroadcastEvent::class]);
|
||||
|
||||
// 커맨드 실행
|
||||
$this->artisan('dashboard:broadcast-resources')
|
||||
->assertExitCode(0);
|
||||
|
||||
// 이벤트에 올바른 데이터가 포함되어 있는지 확인
|
||||
Event::assertDispatched(DashboardUpdated::class, function ($event) {
|
||||
// resources 타입인지 확인
|
||||
if ($event->type !== 'resources') {
|
||||
Event::assertDispatched(GenericBroadcastEvent::class, function ($event) {
|
||||
if ($event->payload['type'] !== 'resources') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// data가 배열인지 확인
|
||||
if (! is_array($event->data)) {
|
||||
$data = $event->payload['data'] ?? null;
|
||||
if (! is_array($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 필수 필드가 있는지 확인
|
||||
return isset($event->data['cpu']) &&
|
||||
isset($event->data['memory']) &&
|
||||
isset($event->data['disk']);
|
||||
return isset($data['cpu'])
|
||||
&& isset($data['memory'])
|
||||
&& isset($data['disk']);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user