summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-05-09 15:42:58 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-05-09 15:42:58 +0200
commitd116e23de0efcd528226acf6dbe4c7cbc5c5698b (patch)
treea2249944821123a35de6e593c713c06648900c9d /tests
parent883fbfab5dd0f7fabfed008341acaa63f365b1dc (diff)
downloadgigologadmin-d116e23de0efcd528226acf6dbe4c7cbc5c5698b.tar.gz
gigologadmin-d116e23de0efcd528226acf6dbe4c7cbc5c5698b.tar.bz2
gigologadmin-d116e23de0efcd528226acf6dbe4c7cbc5c5698b.zip
Include info from venue in concerts.
This makes the concert a full object containing all relevant info, while we can still segment the data in the db. Instead of this: $concert = GiglogAdmin_Concert::get($concert_id); $venue = GiglogAdmin_Venue::get($concert->venue()); echo "{$concert->name()} @ {$venue->name()} : {$concert->cdate()}" You can now do: $concert = GiglogAdmin_Concert::get($concert_id); echo "{$concert->name()} @ {$concert->venue()->name()} : {$concert->cdate()}" And yeah, renamed Concert::find_cid() to Concert::get() and changed it's semantics somewhat. It now either returns the given concert if it exists, or NULL if it does not. Simpler function; simpler to use.
Diffstat (limited to 'tests')
-rw-r--r--tests/ConcertTest.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/ConcertTest.php b/tests/ConcertTest.php
index 6d14b68..0517ad8 100644
--- a/tests/ConcertTest.php
+++ b/tests/ConcertTest.php
@@ -19,7 +19,7 @@ final class ConcertTest extends WP_UnitTestCase
"https://example.com/events/93");
$this->assertEquals("a concert", $concert->cname());
- $this->assertEquals($venue->id(), $concert->venue());
+ $this->assertEquals($venue->id(), $concert->venue()->id());
$this->assertEquals($today, $concert->cdate());
$this->assertEquals("https://example.com/tickets/42", $concert->tickets());
$this->assertEquals("https://example.com/events/93", $concert->eventlink());
@@ -68,4 +68,23 @@ final class ConcertTest extends WP_UnitTestCase
$this->assertNull($new);
}
+
+ public function testGetConcertByIdReturnsFullConcertObject() : void
+ {
+ $venue = GiglogAdmin_Venue::create("a venue");
+ $today = date("Y-m-d");
+
+ $gig = GiglogAdmin_Concert::create(
+ "a concert123",
+ $venue->id(),
+ $today,
+ "https://example.com/tickets/42",
+ "https://example.com/events/93");
+
+ $fetched_gig = GiglogAdmin_Concert::get($gig->id());
+
+ $this->assertEquals($gig->id(), $fetched_gig->id());
+ $this->assertEquals($gig->cname(), $fetched_gig->cname());
+ $this->assertEquals($venue->id(), $fetched_gig->venue()->id());
+ }
}