Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/Dto/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function __construct(
public readonly bool $usesOctane = false,
public readonly bool $usesHibernation = false,
public readonly ?int $hibernationWakeUpInterval = null,
public readonly ?string $trigger = null,
public readonly ?string $triggerReference = null,
public readonly ?Environment $environment = null,
public readonly ?User $initiator = null,
) {
Expand Down Expand Up @@ -124,6 +126,8 @@ public static function createFromResponse(array $response): self
'usesOctane' => $attributes['uses_octane'] ?? false,
'usesHibernation' => $attributes['uses_hibernation'] ?? false,
'hibernationWakeUpInterval' => $attributes['hibernation_wake_up_interval'] ?? null,
'trigger' => $attributes['trigger'] ?? null,
'triggerReference' => $attributes['trigger_reference'] ?? null,
];

if (isset($relationships['environment']['data'])) {
Expand Down
25 changes: 25 additions & 0 deletions tests/Unit/DeploymentDtoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
'hibernation_wake_up_interval' => 30,
'started_at' => '2026-10-01T12:00:00.000000Z',
'finished_at' => '2026-10-01T12:02:00.000000Z',
'trigger' => null,
'trigger_reference' => null,
],
],
]);
Expand All @@ -32,5 +34,28 @@
->and($deployment->commitHash)->toBe('abc1234')
->and($deployment->commitMessage)->toBe('Fix bug')
->and($deployment->commitAuthor)->toBe('Taylor')
->and($deployment->trigger)->toBeNull()
->and($deployment->triggerReference)->toBeNull()
->and($deployment->toArray())->not->toHaveKeys(['createdAt', 'updatedAt']);
});

it('maps why Laravel Cloud started a deployment itself', function () {
$deployment = Deployment::createFromResponse([
'data' => [
'id' => 'deploy-2',
'type' => 'deployments',
'attributes' => [
'status' => 'deployment.succeeded',
'trigger' => 'patch',
'trigger_reference' => 'CVE-2026-12345',
],
],
]);

expect($deployment->trigger)->toBe('patch')
->and($deployment->triggerReference)->toBe('CVE-2026-12345')
->and($deployment->toArray())->toMatchArray([
'trigger' => 'patch',
'triggerReference' => 'CVE-2026-12345',
]);
});