Skip to content

Commit 076b732

Browse files
committed
Minor refactor and comment updates
1 parent d49b562 commit 076b732

4 files changed

Lines changed: 18 additions & 23 deletions

File tree

database/migrations/2026_06_22_083853_create_policies_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function up(): void {
1818
// Use Eloquent built in to create nullable `created_at` and `updated_at` timestamp fields
1919
$table->timestamps();
2020

21-
// This prevents two policies of the same type with `active_from` set to the same value
21+
// Prevent two policies of the same type with `active_from` set to the same value
2222
// (including `null` for upcoming policies)
2323
$table->unique(['policy_type', 'active_from']);
2424
});

database/migrations/2026_06_22_083910_create_policy_acceptances_table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public function up(): void {
1818

1919
$table->foreignId('policy_id')->constrained()->restrictOnUpdate()->restrictOnDelete();
2020

21-
// Using a separate `accepted_at` column rather than renaming the default `created_at` column because:
21+
// Use a separate `accepted_at` column rather than renaming the default `created_at` column because:
2222
// * it reduces confusion by remaining consistent with other tables that use these default columns
2323
// * `accepted_at` will be before `created_at` when backfilling the terms-of-use acceptances
24-
// Using a DATETIME field as MariaDB has odd behavior around TIMESTAMPs and default values
24+
// Use a DATETIME field as MariaDB has odd behavior around TIMESTAMPs and default values
2525
// `accepted_at` can be NOT NULL if we use a DATETIME which provides us with more data safety
2626
$table->dateTime('accepted_at');
2727

tests/PolicyAcceptanceTest.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,20 @@ protected function setUp(): void {
2020
parent::setUp();
2121
$user = User::factory()->create();
2222
$this->userId = $user->id;
23-
$policy = Policy::create(
24-
[
25-
'policy_type' => 'terms-of-use',
26-
'active_from' => CarbonImmutable::yesterday(),
27-
'content_vue_file' => 'terms-of-use/example.vue',
28-
]);
23+
$policy = Policy::create([
24+
'policy_type' => 'terms-of-use',
25+
'active_from' => CarbonImmutable::yesterday(),
26+
'content_vue_file' => 'terms-of-use/example.vue',
27+
]);
2928
$this->policyId = $policy->id;
3029
}
3130

3231
public function testCreatesAndSavesSuccessfully(): void {
33-
$policyAcceptance = new PolicyAcceptance(
34-
[
35-
'user_id' => $this->userId,
36-
'policy_id' => $this->policyId,
37-
'accepted_at' => CarbonImmutable::now(),
38-
]
39-
);
32+
$policyAcceptance = new PolicyAcceptance([
33+
'user_id' => $this->userId,
34+
'policy_id' => $this->policyId,
35+
'accepted_at' => CarbonImmutable::now(),
36+
]);
4037
$policyAcceptance->save();
4138
$policyAcceptance->refresh();
4239

tests/PolicyTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ class PolicyTest extends TestCase {
1010
use RefreshDatabase;
1111

1212
public function testCreatesSuccessfully(): void {
13-
Policy::create(
14-
[
15-
'policy_type' => 'terms-of-use',
16-
'active_from' => CarbonImmutable::createMidnightDate(2025, 4, 1),
17-
'content_vue_file' => 'terms-of-use/example.vue',
18-
]
19-
);
13+
Policy::create([
14+
'policy_type' => 'terms-of-use',
15+
'active_from' => CarbonImmutable::createMidnightDate(2025, 4, 1),
16+
'content_vue_file' => 'terms-of-use/example.vue',
17+
]);
2018

2119
$this->assertDatabaseHas('policies', [
2220
'policy_type' => 'terms-of-use',

0 commit comments

Comments
 (0)