diff options
| author | Harald Eilertsen <haraldei@anduin.net> | 2022-06-18 18:18:23 +0200 | 
|---|---|---|
| committer | Harald Eilertsen <haraldei@anduin.net> | 2022-06-18 18:24:11 +0200 | 
| commit | 1fa1654de0527440d057c5ed05891bed6cc0b69c (patch) | |
| tree | ac075a8301b4a1e5887b3fcb49b33ee3ff0192d4 /tests/ConcertTest.php | |
| parent | ad803da0439f0d52eb051fbe7b0a147cc777b4d2 (diff) | |
| download | gigologadmin-1fa1654de0527440d057c5ed05891bed6cc0b69c.tar.gz gigologadmin-1fa1654de0527440d057c5ed05891bed6cc0b69c.tar.bz2 gigologadmin-1fa1654de0527440d057c5ed05891bed6cc0b69c.zip  | |
Fix concert tests.
Diffstat (limited to 'tests/ConcertTest.php')
| -rw-r--r-- | tests/ConcertTest.php | 47 | 
1 files changed, 25 insertions, 22 deletions
diff --git a/tests/ConcertTest.php b/tests/ConcertTest.php index dc2a712..d84e6a9 100644 --- a/tests/ConcertTest.php +++ b/tests/ConcertTest.php @@ -38,7 +38,7 @@ final class ConcertTest extends WP_UnitTestCase              $created_venues[] = GiglogAdmin_Venue::find_or_create($venue[0], $venue[1]);          } -        $today = date("Y-m-d"); +        $today = new DateTime();          foreach (self::CONCERTS as $concert) {              for ($i = 0; $i < $concert[2]; $i++) { @@ -49,10 +49,13 @@ final class ConcertTest extends WP_UnitTestCase                      $concert_name = $concert[0];                  } +                $offset = rand(1, 13); +                $concert_date = $today->modify( "+$offset days" ); +                  self::$concerts[] = GiglogAdmin_Concert::create(                      $concert_name,                      $created_venues[$concert[1]]->id(), -                    $today, +                    $concert_date->format( 'Y-m-d' ),                      "https://example.com/tickets/42",                      "https://example.com/events/93");              } @@ -82,30 +85,30 @@ final class ConcertTest extends WP_UnitTestCase      {          $this->expectException(GiglogAdmin_DuplicateConcertException::class); -        $venue = GiglogAdmin_Venue::find_or_create("a venue", "Somewhere"); -        $today = date("Y-m-d"); +        $origin = self::$concerts[0];          $new = GiglogAdmin_Concert::create( -            "a concert", -            $venue->id(), -            $today, -            "https://example.com/tickets/42", -            "https://example.com/events/93"); +            $origin->cname(), +            $origin->venue()->id(), +            $origin->cdate(), +            $origin->tickets(), +            $origin->eventlink() +        );      }      public function testCreateExistingConcertVariableCase() : void      {          $this->expectException(GiglogAdmin_DuplicateConcertException::class); -        $venue = GiglogAdmin_Venue::find_or_create("a venue", "Somewhere"); -        $today = date("Y-m-d"); +        $origin = self::$concerts[0];          $new = GiglogAdmin_Concert::create( -            "a CoNceRt", -            $venue->id(), -            $today, -            "https://example.com/tickets/42", -            "https://example.com/events/93"); +            strtoupper( $origin->cname() ), +            $origin->venue()->id(), +            $origin->cdate(), +            $origin->tickets(), +            $origin->eventlink() +        );      }      public function testGetConcertByIdReturnsFullConcertObject() : void @@ -201,17 +204,17 @@ final class ConcertTest extends WP_UnitTestCase      public function testFetchConcertByNameVenueAndDate() : void      { +        $origin = self::$concerts[0]; +          $gigs = GiglogAdmin_Concert::find_concerts([ -            'name' => 'a concert', -            'venue' => 'a venue', -            'date' => date('Y-m-d') +            'name' => $origin->cname(), +            'venue' => $origin->venue()->name(), +            'date' => $origin->cdate(),          ]);          $this->assertEquals(1, count($gigs));          $gig = array_shift($gigs); -        $this->assertEquals('a concert', $gig->cname()); -        $this->assertEquals('a venue', $gig->venue()->name()); -        $this->assertEquals(date('Y-m-d'), explode(' ', $gig->cdate())[0]); +        $this->assertEquals($origin, $gig);      }  }  | 
