-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit tests for hide comment bulk action dropdown based on user capability #8264
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,53 @@ static function () { | |
$this->assertStringContainsString( $expected, $output ); | ||
} | ||
|
||
/** | ||
* @ticket 59440 | ||
* | ||
* @covers WP_Comments_List_Table::bulk_actions | ||
*/ | ||
public function test_bulk_action_menu_should_be_shown_if_user_has_capability() { | ||
$u = self::factory()->user->create_and_get( | ||
array( | ||
'role' => 'administrator', | ||
) | ||
); | ||
|
||
wp_set_current_user( $u ); | ||
|
||
$this->assertTrue( current_user_can( 'moderate_comments' ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion is probably a bit pointless here. |
||
|
||
ob_start(); | ||
$this->table->bulk_actions(); | ||
$output = ob_get_clean(); | ||
Comment on lines
+142
to
+144
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use the |
||
|
||
$this->assertNotEmpty( $output ); | ||
$this->assertStringContainsString( '<option value="-1">Bulk actions</option>', $output ); | ||
} | ||
|
||
/** | ||
* @ticket 59440 | ||
* | ||
* @covers WP_Comments_List_Table::bulk_actions | ||
*/ | ||
public function test_bulk_action_menu_should_not_be_shown_if_user_has_no_capability() { | ||
$u = self::factory()->user->create_and_get( | ||
array( | ||
'role' => 'subscriber', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe author is a better choice here, a bit more realistic. |
||
) | ||
); | ||
|
||
wp_set_current_user( $u ); | ||
|
||
$this->assertFalse( current_user_can( 'moderate_comments' ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion is probably a bit pointless here. |
||
|
||
ob_start(); | ||
$this->table->bulk_actions(); | ||
$output = ob_get_clean(); | ||
Comment on lines
+166
to
+168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here about |
||
|
||
$this->assertEmpty( $output ); | ||
} | ||
|
||
/** | ||
* @ticket 45089 | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify.