diff options
-rw-r--r-- | includes/band.php | 15 | ||||
-rw-r--r-- | includes/concert.php | 4 | ||||
-rwxr-xr-x | run-tests | 2 | ||||
-rw-r--r-- | tests/BandTest.php | 2 |
4 files changed, 15 insertions, 8 deletions
diff --git a/includes/band.php b/includes/band.php index 47b663c..14daa18 100644 --- a/includes/band.php +++ b/includes/band.php @@ -12,12 +12,17 @@ if ( !class_exists('GiglogAdmin_Band') ) { private $bandname; private $country; - + /* + * Constructs a new band object from an array of attributes. + * The attributes are expected to be named as in the database, + * so this constructor can be used to construct the object + * directly from the database row. + */ public function __construct($attrs = []) { $this->id = isset($attrs->id) ? $attrs->id : NULL; - $this->bandname = isset($attrs->bandname) ? $attrs->bandname : NULL; - $this->country = isset($attrs->country) ? $attrs->country : 'NO'; + $this->bandname = isset($attrs->wpgband_name) ? $attrs->wpgband_name : NULL; + $this->country = isset($attrs->wpgband_country) ? $attrs->wpgband_country : 'NO'; } static function create($bandname, $country = 'NO') @@ -26,8 +31,8 @@ if ( !class_exists('GiglogAdmin_Band') ) { if ( ! $band ) { $band = new GiglogAdmin_Band((object) [ - 'bandname' => $bandname, - 'country' => $country, + 'wpgband_name' => $bandname, + 'wpgband_country' => $country, ]); $band->save(); diff --git a/includes/concert.php b/includes/concert.php index 54bdbc4..579fb16 100644 --- a/includes/concert.php +++ b/includes/concert.php @@ -15,8 +15,8 @@ if ( !class_exists('GiglogAdmin_Concert') ) { private $tickets; private $eventlink; - /* - * Constructs a new venue object from an array of attributes. + /* + * Constructs a new concert object from an array of attributes. * The attributes are expected to be named as in the database, * so this constructor can be used to construct the object * directly from the database row. @@ -1,2 +1,2 @@ #!/usr/bin/env bash -npm run wp-env run phpunit 'phpunit -c /var/www/html/wp-content/plugins/giglogadmin/phpunit.xml' +npm run wp-env run phpunit "phpunit -c /var/www/html/wp-content/plugins/giglogadmin/phpunit.xml $*" diff --git a/tests/BandTest.php b/tests/BandTest.php index 33b14f4..e4fccbe 100644 --- a/tests/BandTest.php +++ b/tests/BandTest.php @@ -39,6 +39,7 @@ final class BandTest extends WP_UnitTestCase $this->assertEquals($count, count(GiglogAdmin_Band::all_bands())); $this->assertEquals($existing_band->id(), $new_band->id()); + $this->assertEquals($existing_band->bandname(), $new_band->bandname()); } public function testCreateBandsWithSameNameInDifferentCountry() : void @@ -54,6 +55,7 @@ final class BandTest extends WP_UnitTestCase $found = GiglogAdmin_Band::find("The Flamboyant Blasphemers", "NO"); $this->assertNotNull($found); + $this->assertEquals("The Flamboyant Blasphemers", $found->bandname()); } public function testFindNonExistingBandReturnsNULL() : void |