From 61c48191a8e9ab757be4bf845072f4cfdbf9075f Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 9 May 2021 22:12:21 +0200 Subject: Method to find concerts at given venue --- tests/ConcertTest.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests') diff --git a/tests/ConcertTest.php b/tests/ConcertTest.php index dc82839..96fc72b 100644 --- a/tests/ConcertTest.php +++ b/tests/ConcertTest.php @@ -128,4 +128,44 @@ final class ConcertTest extends WP_UnitTestCase $this->assertEquals("Sogndal", $gig->venue()->city()); } } + + public function testOnlyFetchConcertsAtGivenVenue() : void + { + $venue1 = GiglogAdmin_Venue::create("Sentrum Scene", "Oslo"); + $venue2 = GiglogAdmin_Venue::create("Rockefeller Music Hall", "Oslo"); + $venue3 = GiglogAdmin_Venue::create("Revolver", "Oslo"); + + 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_at_ss = GiglogAdmin_Concert::find_concerts_at($venue1); + + $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); + + $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); + + $this->assertEquals(5, count($gigs_at_r)); + while ($gig = array_pop($gigs_at_r)) { + $this->assertEquals("Revolver", $gig->venue()->name()); + } + } } -- cgit v1.2.3