Skip to content

Commit

Permalink
Replace usage of native date function in SpaceInvite model
Browse files Browse the repository at this point in the history
  • Loading branch information
range-of-motion committed Oct 16, 2023
1 parent 90057dc commit 01bf6ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/Models/SpaceInvite.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ protected function status(): Attribute
}

if ($this->accepted === true) {
return 'Accepted (' . date('d-m', strtotime($this->updated_at)) . ')';
return 'Accepted (' . $this->updated_at->format('d-m') . ')';
}

if ($this->accepted === false) {
return 'Denied (' . date('d-m', strtotime($this->updated_at)) . ')';
return 'Denied (' . $this->updated_at->format('d-m') . ')';
}

return 'Unknown';
Expand Down
7 changes: 5 additions & 2 deletions tests/Unit/Models/SpaceInviteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Unit\Models;

use App\Models\SpaceInvite;
use Carbon\Carbon;
use Tests\TestCase;

class SpaceInviteTest extends TestCase
Expand All @@ -19,15 +20,17 @@ public function testStatusAttribute(): void
$acceptedSpaceInvite = SpaceInvite::factory()
->make([
'accepted' => true,
'updated_at' => Carbon::parse('2021-02-14'),
]);

$this->assertStringStartsWith('Accepted', $acceptedSpaceInvite->status);
$this->assertEquals('Accepted (14-02)', $acceptedSpaceInvite->status);

$deniedSpaceInvite = SpaceInvite::factory()
->make([
'accepted' => false,
'updated_at' => Carbon::parse('2021-02-14'),
]);

$this->assertStringStartsWith('Denied', $deniedSpaceInvite->status);
$this->assertEquals('Denied (14-02)', $deniedSpaceInvite->status);
}
}

0 comments on commit 01bf6ef

Please sign in to comment.