diff options
Diffstat (limited to 'tests/ConcertTest.php')
-rw-r--r-- | tests/ConcertTest.php | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/tests/ConcertTest.php b/tests/ConcertTest.php index 96fc72b..7edda46 100644 --- a/tests/ConcertTest.php +++ b/tests/ConcertTest.php @@ -86,6 +86,30 @@ final class ConcertTest extends WP_UnitTestCase $this->assertEquals($gig->id(), $fetched_gig->id()); $this->assertEquals($gig->cname(), $fetched_gig->cname()); $this->assertEquals($venue->id(), $fetched_gig->venue()->id()); + $this->assertEquals(GiglogAdmin_Concert::STATUS_NONE, $fetched_gig->status()); + $this->assertEquals([], $fetched_gig->roles()); + } + + public function testSetConcertStatus() : 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()); + $fetched_gig->set_status( GiglogAdmin_Concert::STATUS_ACCRED_REQ ); + $this->assertEquals( GiglogAdmin_Concert::STATUS_ACCRED_REQ, $fetched_gig->status() ); + + $fetched_gig->save(); + + $fetched_gig_2 = GiglogAdmin_Concert::get($gig->id()); + $this->assertEquals( GiglogAdmin_Concert::STATUS_ACCRED_REQ, $fetched_gig_2->status() ); } public function testOnlyFetchConcertsFromGivenCity() : void @@ -106,7 +130,7 @@ final class ConcertTest extends WP_UnitTestCase GiglogAdmin_Concert::create('Concert ' . $i, $venue3->id(), '', '', ''); } - $gigs_in_svene = GiglogAdmin_Concert::find_concerts_in("Svene"); + $gigs_in_svene = GiglogAdmin_Concert::find_concerts([ "city" => "Svene"]); $this->assertEquals(4, count($gigs_in_svene)); while ($gig = array_pop($gigs_in_svene)) { @@ -114,14 +138,14 @@ final class ConcertTest extends WP_UnitTestCase } - $gigs_in_oslo = GiglogAdmin_Concert::find_concerts_in("Oslo"); + $gigs_in_oslo = GiglogAdmin_Concert::find_concerts(["city" => "Oslo"]); $this->assertEquals(2, count($gigs_in_oslo)); while ($gig = array_pop($gigs_in_oslo)) { $this->assertEquals("Oslo", $gig->venue()->city()); } - $gigs_in_sogndal = GiglogAdmin_Concert::find_concerts_in("Sogndal"); + $gigs_in_sogndal = GiglogAdmin_Concert::find_concerts(["city" => "Sogndal"]); $this->assertEquals(5, count($gigs_in_sogndal)); while ($gig = array_pop($gigs_in_sogndal)) { @@ -147,25 +171,48 @@ final class ConcertTest extends WP_UnitTestCase GiglogAdmin_Concert::create('Concert ' . $i, $venue3->id(), '', '', ''); } - $gigs_at_ss = GiglogAdmin_Concert::find_concerts_at($venue1); + $gigs_at_ss = GiglogAdmin_Concert::find_concerts(["venue_id" => $venue1->id()]); $this->assertEquals(4, count($gigs_at_ss)); while ($gig = array_pop($gigs_at_ss)) { $this->assertEquals("Sentrum Scene", $gig->venue()->name()); } - $gigs_at_rmh = GiglogAdmin_Concert::find_concerts_at($venue2); + $gigs_at_rmh = GiglogAdmin_Concert::find_concerts(["venue_id" => $venue2->id()]); $this->assertEquals(2, count($gigs_at_rmh)); while ($gig = array_pop($gigs_at_rmh)) { $this->assertEquals("Rockefeller Music Hall", $gig->venue()->name()); } - $gigs_at_r = GiglogAdmin_Concert::find_concerts_at($venue3); + $gigs_at_r = GiglogAdmin_Concert::find_concerts(["venue_id" => $venue3->id()]); $this->assertEquals(5, count($gigs_at_r)); while ($gig = array_pop($gigs_at_r)) { $this->assertEquals("Revolver", $gig->venue()->name()); } } + + public function testFetchAllConcerts() : void + { + $venue1 = GiglogAdmin_Venue::create("Svene Bedehus", "Svene"); + $venue2 = GiglogAdmin_Venue::create("Rockefeller Music Hall", "Oslo"); + $venue3 = GiglogAdmin_Venue::create("Meieriet", "Sogndal"); + + for ($i = 0; $i < 4; $i++) { + GiglogAdmin_Concert::create('Concert ' . $i, $venue1->id(), '', '', ''); + } + + for ($i = 4; $i < 6; $i++) { + GiglogAdmin_Concert::create('Concert ' . $i, $venue2->id(), '', '', ''); + } + + for ($i = 6; $i < 11; $i++) { + GiglogAdmin_Concert::create('Concert ' . $i, $venue3->id(), '', '', ''); + } + + $gigs = GiglogAdmin_Concert::find_concerts(); + + $this->assertEquals(11, count($gigs)); + } } |