summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/admin/views/_concerts_table.php6
-rw-r--r--tests/ConcertsTableTest.php29
2 files changed, 27 insertions, 8 deletions
diff --git a/includes/admin/views/_concerts_table.php b/includes/admin/views/_concerts_table.php
index 25bbef7..9c895de 100644
--- a/includes/admin/views/_concerts_table.php
+++ b/includes/admin/views/_concerts_table.php
@@ -157,7 +157,7 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
private function adminactions( GiglogAdmin_Concert $concert ) : string
{
return
- '<form method="POST" action="">'
+ '<form class="adminactions" method="POST" action="">'
. '<input type="hidden" name="cid" value="' . $concert->id() . '" />'
. \EternalTerror\ViewHelpers\select_field(
'selectstatus',
@@ -193,7 +193,7 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
//first check if current slot is taken by current user
if ( $assigned_user == $this->username ) {
- $f = '<form class="unassignit" method="POST" action="">'
+ $f = '<form class="unassign_concert" method="POST" action="">'
. ' <input type="hidden" name="cid" value="' . $concert->id() . '" />'
. ' <input type="hidden" name="pid" value="' . $role . '" />'
. ' <input type="submit" name="unassignitem" value=""/>'
@@ -208,7 +208,7 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
$f = '<span class="taken_by_self">-</span>';
}
else { //not taken by anyone
- $f = '<form method="POST" action="">'
+ $f = '<form class="assign_concert" method="POST" action="">'
. ' <input type="hidden" name="cid" value="' . $concert->id() . '" />'
. ' <input type="hidden" name="pid" value="' . $role. '" />'
. ' <input type="submit" name="assignitem" value=""/>'
diff --git a/tests/ConcertsTableTest.php b/tests/ConcertsTableTest.php
index 73852c8..ad0e65f 100644
--- a/tests/ConcertsTableTest.php
+++ b/tests/ConcertsTableTest.php
@@ -75,20 +75,39 @@ class ConcertsTableTest extends WP_UnitTestCase
}
function testShowAllControlsToAdminOnAdminPage() {
+ global $current_screen;
+ global $current_user;
+
+ $current_user = $this->factory()->user->create_and_get(['role' => 'administrator']);
+ $this->assertTrue( current_user_can( 'administrator' ) );
+
+ $oldscreen = $current_screen;
+ $current_screen = WP_Screen::get( 'admin_init' );
+ $this->assertTrue(is_admin());
+
$c = new GiglogAdmin_ConcertsTable();
$html = $c->render();
- //$this->assertEquals('balle', $html);
+
+ $current_screen = $oldscreen;
$doc = DOMDocument::loadHTML($html);
$forms = $doc->getElementsByTagName('form');
- $count = 0;
+
+ $assignit_count = 0;
+ $adminactions_count = 0;
+
foreach ($forms as $form) {
$cls = $form->attributes->getNamedItem('class')->nodeValue;
- if ($cls == 'assignit' || $cls == 'unassignit') {
- $count++;
+ if ($cls == 'assign_concert' || $cls == 'unassign_concert') {
+ $assignit_count++;
+ }
+
+ if ($cls == 'adminactions') {
+ $adminactions_count++;
}
}
- $this->assertEquals($count, 64);
+ $this->assertEquals(64, $assignit_count); // four for each gig
+ $this->assertEquals(16, $adminactions_count); // once for each gig
}
}