summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-06-27 13:05:08 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-06-27 23:29:03 +0200
commit224f0149ea513146b164736f461e6cbba4b86add (patch)
treef989ad000bea8109713cec28bc99fdf325f13a97
parent184f1e3f971423fad351de2b2fbde6f436e6d9ce (diff)
downloadgigologadmin-224f0149ea513146b164736f461e6cbba4b86add.tar.gz
gigologadmin-224f0149ea513146b164736f461e6cbba4b86add.tar.bz2
gigologadmin-224f0149ea513146b164736f461e6cbba4b86add.zip
Begin move roles and status field to concerts table.
-rw-r--r--giglogadmin.php1
-rw-r--r--includes/concert.php5
-rw-r--r--includes/roles.php12
-rw-r--r--tests/ConcertTest.php25
4 files changed, 43 insertions, 0 deletions
diff --git a/giglogadmin.php b/giglogadmin.php
index c35c470..dec54a7 100644
--- a/giglogadmin.php
+++ b/giglogadmin.php
@@ -34,6 +34,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) {
require_once __DIR__ . '/includes/admin/helpfiles/instr_reviewers.php';
require_once __DIR__ . '/includes/admin/helpfiles/instr_photog.php';
require_once __DIR__ . '/includes/view-helpers/select_field.php';
+ require_once __DIR__ . '/includes/roles.php';
class GiglogAdmin_Plugin
{
diff --git a/includes/concert.php b/includes/concert.php
index 6257fab..db8d68a 100644
--- a/includes/concert.php
+++ b/includes/concert.php
@@ -274,6 +274,11 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
{
return $this->roles;
}
+
+ public function assign_role( int $role, string $username ) : void
+ {
+ $this->roles[$role] = $username;
+ }
}
}
?>
diff --git a/includes/roles.php b/includes/roles.php
new file mode 100644
index 0000000..dbbedd2
--- /dev/null
+++ b/includes/roles.php
@@ -0,0 +1,12 @@
+<?php
+
+if ( ! class_exists( 'GiglogAdmin_Roles' ) )
+{
+ class GiglogAdmin_Roles
+ {
+ public const PHOTO1 = 0;
+ public const PHOTO2 = 1;
+ public const TEXT1 = 2;
+ public const TEXT2 = 3;
+ }
+}
diff --git a/tests/ConcertTest.php b/tests/ConcertTest.php
index 77b1ed3..0bf345c 100644
--- a/tests/ConcertTest.php
+++ b/tests/ConcertTest.php
@@ -133,6 +133,31 @@ final class ConcertTest extends WP_UnitTestCase
$this->assertEquals( GiglogAdmin_Concert::STATUS_ACCRED_REQ, $fetched_gig_2->status() );
}
+ public function testAssignConcertRoles() : 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");
+
+ $gig->assign_role( GiglogAdmin_Roles::PHOTO1, 'user1' );
+ $this->assertEquals( [ GiglogAdmin_Roles::PHOTO1 => 'user1' ], $gig->roles() );
+
+ $gig->save();
+
+ var_dump($gig);
+
+ $fetched_gig = GiglogAdmin_Concert::get( $gig->id() );
+ global $wpdb;
+ $wpdb->print_error();
+ $this->assertEquals( [ GiglogAdmin_Roles::PHOTO1 => 'user1' ], $fetched_gig->roles() );
+ }
+
public function testOnlyFetchConcertsFromGivenCity() : void
{
$gigs_in_svene = GiglogAdmin_Concert::find_concerts([ "city" => "Svene"]);