Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

788 B
Raw Blame
<?php

use App\Events\DatabaseStatusChanged;
use App\Jobs\DatabaseStartJob;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;

uses(TestCase::class, RefreshDatabase::class);

it('broadcasts failed database starts to the initiating user even when the activity is missing', function () {
    Event::fake([DatabaseStatusChanged::class]);

    $job = new DatabaseStartJob(
        databaseClass: 'MissingDatabase',
        databaseId: 123,
        teamId: 456,
        activityId: 789,
        userId: 42,
    );

    $job->failed(new RuntimeException('Database start failed.'));

    Event::assertDispatched(
        DatabaseStatusChanged::class,
        fn (DatabaseStatusChanged $event): bool => $event->userId === 42,
    );
});