summaryrefslogtreecommitdiffstats
path: root/tests/ConcertTest.php
blob: 19267ee6ec9c26bc9acb0eb4de0357352a37827c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php declare(strict_types=1);
// SPDX-FileCopyrightText: 2021 Andrea Chirulescu <andrea.chirulescu@gmail.com>
// SPDX-FileCopyrightText: 2021 Harald Eilertsen <haraldei@anduin.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

final class ConcertTest extends WP_UnitTestCase
{
    public function testCreateConcert() : void
    {
        $venue = GiglogAdmin_Venue::create("a venue");
        $today = date("Y-m-d");

        $concert = GiglogAdmin_Concert::create(
            "a concert",
            $venue->id(),
            $today,
            "https://example.com/tickets/42",
            "https://example.com/events/93");

        $this->assertEquals("a concert", $concert->cname());
        $this->assertEquals($venue->id(), $concert->venue());
        $this->assertEquals($today, $concert->cdate());
        $this->assertEquals("https://example.com/tickets/42", $concert->tickets());
        $this->assertEquals("https://example.com/events/93", $concert->eventlink());
    }

    public function testCreateExistingConcert() : void
    {
        $venue = GiglogAdmin_Venue::create("a venue");
        $today = date("Y-m-d");

        GiglogAdmin_Concert::create(
            "a concert",
            $venue->id(),
            $today,
            "https://example.com/tickets/42",
            "https://example.com/events/93");

        $new = GiglogAdmin_Concert::create(
            "a concert",
            $venue->id(),
            $today,
            "https://example.com/tickets/42",
            "https://example.com/events/93");

        $this->assertEquals("dup", $new);
    }
}