Skip to content

Commit

Permalink
Add event meetup date (#55)
Browse files Browse the repository at this point in the history
* Add event meetup date to model

* Update test

* Update fixtures

* Fix failing check regarding cs

* Update fixtures to be complete

* Add missing event index fixtures

---------

Co-authored-by: Coolio85 <[email protected]>
  • Loading branch information
coolio85 and Coolio85 authored Nov 26, 2023
1 parent c0868af commit dc9049a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Models/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ class Event extends Model
*/
protected Carbon $startAt;

/**
* The event meetup date.
*
* @var Carbon|null
*/
protected ?Carbon $meetupAt;

/**
* The event banner.
*
Expand Down Expand Up @@ -216,6 +223,10 @@ public function __construct(Client $client, array $event)
);

$this->startAt = new Carbon($this->getValue('start_at'), 'UTC');

$meetupAt = $this->getValue('meetup_at');
$this->meetupAt = $meetupAt ? new Carbon($meetupAt, 'UTC') : null;

$this->banner = $this->getValue('banner');
$this->map = $this->getValue('map');
$this->description = $this->getValue('description');
Expand Down Expand Up @@ -346,6 +357,16 @@ public function getStartAt(): Carbon
return $this->startAt;
}

/**
* Get the start date of the event.
*
* @return Carbon|null
*/
public function getMeetupAt(): ?Carbon
{
return $this->meetupAt;
}

/**
* Get the banner of the event.
*
Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/Models/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ public function testItHasAStartDate()
$this->assertDate('2023-01-04 14:32:28', $this->event->getStartAt());
}

public function testItHasAMeetupDate()
{
$this->assertDate('2023-01-04 14:02:28', $this->event->getMeetupAt());
}

public function testItHasABanner()
{
$this->assertSame('https://static.truckersmp.com/images/event/cover/cover.png', $this->event->getBanner());
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Models/fixtures/event.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"city": "Stuttgart"
},
"start_at": "2023-01-04 14:32:28",
"meetup_at": "2023-01-04 14:02:28",
"banner": "https://static.truckersmp.com/images/event/cover/cover.png",
"map": "https://static.truckersmp.com/images/event/map/map.png",
"description": "Description",
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Requests/fixtures/event.index.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"city": "Stuttgart"
},
"start_at": "2023-01-15 19:00:00",
"meetup_at": "2023-01-15 18:00:00",
"banner": "https://static.truckersmp.com/images/event/cover/cover.jpeg",
"map": "https://static.truckersmp.com/images/event/map/map.png",
"description": "Description",
Expand Down Expand Up @@ -75,6 +76,7 @@
"city": "Stuttgart"
},
"start_at": "2023-01-04 17:00:00",
"meetup_at": "2023-01-04 16:00:00",
"banner": "https://static.truckersmp.com/images/event/cover/cover.png",
"map": "https://static.truckersmp.com/images/event/map/map.jpeg",
"description": "",
Expand Down Expand Up @@ -127,6 +129,7 @@
"city": "Dover"
},
"start_at": "2023-01-07 13:00:00",
"meetup_at": "2023-01-07 12:00:00",
"banner": "https://static.truckersmp.com/images/event/cover/cover.jpeg",
"map": "https://static.truckersmp.com/images/event/map/map.png",
"description": "Description",
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Requests/fixtures/event.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"city": "Stuttgart"
},
"start_at": "2023-01-04 14:32:28",
"meetup_at": "2023-01-04 14:02:28",
"banner": "https://static.truckersmp.com/images/event/cover/cover.png",
"map": "https://static.truckersmp.com/images/event/map/map.png",
"description": "Description",
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Requests/fixtures/event.user.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"city": "Verona"
},
"start_at": "2023-02-19 18:30:00",
"meetup_at": "2023-02-19 18:00:00",
"banner": "https://static.truckersmp.com/images/event/cover/cover.png",
"map": "https://static.truckersmp.com/images/event/map/map.png",
"description": "Description",
Expand Down

0 comments on commit dc9049a

Please sign in to comment.