summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreaChirulescu <andrea.chirulescu@gmail.com>2021-09-05 17:04:58 +0200
committerAndreaChirulescu <andrea.chirulescu@gmail.com>2021-09-05 17:04:58 +0200
commit82ac435141e6be7a5386bfb926feec3b88c65c91 (patch)
treefea96f909ff1715179e0ebe2a51937c1e46447b7
parent39523bd49d12ccf0c17bd033a012d6b2b93ce763 (diff)
parent005d612a1a9ff04538024330899a7587543d84e9 (diff)
downloadgigologadmin-82ac435141e6be7a5386bfb926feec3b88c65c91.tar.gz
gigologadmin-82ac435141e6be7a5386bfb926feec3b88c65c91.tar.bz2
gigologadmin-82ac435141e6be7a5386bfb926feec3b88c65c91.zip
Merge branch 'dev' of https://code.volse.net/wordpress/plugins/gigologadmin.git into andreaschanges
-rw-r--r--includes/admin/views/_concerts_table.php8
-rw-r--r--tests/ConcertsTableTest.php94
2 files changed, 98 insertions, 4 deletions
diff --git a/includes/admin/views/_concerts_table.php b/includes/admin/views/_concerts_table.php
index cc9ce4d..a9e254e 100644
--- a/includes/admin/views/_concerts_table.php
+++ b/includes/admin/views/_concerts_table.php
@@ -70,7 +70,7 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
}
// Modify these to match the database structure
// $content .= '<td>' . $row->id. '</td>';
- $content .= '<td></br></br></td>';
+ $content .= '<td></td>';
$content .= '<td>' . $concert->cname() . '</td>';
$content .= '<td>' . $concert->venue()->name() . '</td>';
$fdate = strtotime($concert->cdate());
@@ -126,9 +126,9 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
"Select venue...");
}
//option to select own concerts only
- $select .= '<input class="ownconc" type="checkbox" value="1"';
- if(isset($_POST['ownconcerts'])) $select .=' checked="checked" ';
- $select.=' name="ownconcerts">Show own concerts only</input>';
+ $select .= '<input name="ownconcerts" class="ownconc" type="checkbox" value="1"'
+ . checked(isset($_POST['ownconcerts']) ? $_POST['ownconcerts'] : false)
+ . '><label for="ownconcerts">Show own concerts only</label>';
$select .= '<input type="submit" value="APPLY"></form>';
diff --git a/tests/ConcertsTableTest.php b/tests/ConcertsTableTest.php
new file mode 100644
index 0000000..73852c8
--- /dev/null
+++ b/tests/ConcertsTableTest.php
@@ -0,0 +1,94 @@
+<?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
+
+class ConcertsTableTest extends WP_UnitTestCase
+{
+ const VENUES = [
+ [ "Rockefeller Music Hall", "Oslo" ],
+ [ "Sentrum Scene", "Oslo" ],
+ [ "Revolver", "Oslo" ],
+ [ "Meieriet", "Sogndal" ],
+ ];
+
+ const CONCERTS = [
+ [ "Concert at Rockefeller #", 0, 2 ],
+ [ "Concert at Sentrum Scene #", 1, 4 ],
+ [ "Concert at Revolver #", 2, 5 ],
+ [ "Concert at Meieriet #", 3, 5 ],
+ ];
+
+ private static $concerts = [];
+
+ /* This function runs _once_ before all the test cases.
+ *
+ * Use it to set up a common state that all test cases can
+ * use
+ */
+ static function wpSetUpBeforeClass() : void
+ {
+ $created_venues = [];
+ foreach (self::VENUES as $venue) {
+ $created_venues[] = GiglogAdmin_Venue::find_or_create($venue[0], $venue[1]);
+ }
+
+ $today = date("Y-m-d");
+
+ foreach (self::CONCERTS as $concert) {
+ for ($i = 0; $i < $concert[2]; $i++) {
+ if ($concert[2] > 1) {
+ $concert_name = $concert[0] . ($i + 1);
+ }
+ else {
+ $concert_name = $concert[0];
+ }
+
+ self::$concerts[] = GiglogAdmin_Concert::create(
+ $concert_name,
+ $created_venues[$concert[1]]->id(),
+ $today,
+ "https://example.com/tickets/42",
+ "https://example.com/events/93");
+ }
+ }
+ }
+
+ /* This function runs _once_ after all the test cases in this class.
+ *
+ * It is needed to clean up changes in the database that we don't want
+ * to disturb any other tests.
+ */
+ static function wpTearDownAfterClass() : void
+ {
+ global $wpdb;
+
+ $tables = [
+ "wpg_concerts",
+ "wpg_venues",
+ ];
+
+ foreach( $tables as $table ) {
+ $wpdb->query("DELETE FROM {$table}");
+ }
+ }
+
+ function testShowAllControlsToAdminOnAdminPage() {
+ $c = new GiglogAdmin_ConcertsTable();
+ $html = $c->render();
+ //$this->assertEquals('balle', $html);
+
+ $doc = DOMDocument::loadHTML($html);
+ $forms = $doc->getElementsByTagName('form');
+ $count = 0;
+ foreach ($forms as $form) {
+ $cls = $form->attributes->getNamedItem('class')->nodeValue;
+ if ($cls == 'assignit' || $cls == 'unassignit') {
+ $count++;
+ }
+ }
+
+ $this->assertEquals($count, 64);
+ }
+}