Skip to content
Snippets Groups Projects

Resolve #3487705 "Refactor banuserform"

3 unresolved threads
@@ -88,6 +88,46 @@ class PrivateMessageUserBanTest extends BrowserTestBase {
$this->assertSession()->linkExists('Block');
}
/**
* Tests access to the ban listing.
*/
public function testBanPageRouteAccess() {
$this->drupalLogin($this->userA);
$this->drupalGet('/private-message/ban');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('Ban/Unban users');
$this->drupalLogout();
$this->drupalGet('/private-message/ban');
$this->assertSession()->statusCodeEquals(403);
}
/**
* Tests for BanUserForm.
*/
public function testBanUserFormSubmission() {
$this->drupalLogin($this->userA);
$this->drupalGet('/private-message/ban');
$edit = [
'banned_user' => $this->userA->getDisplayName() . ' (' . $this->userA->id() . ')',
];
$this->submitForm($edit, 'Block');
$this->assertSession()->statusMessageContains("You can't block yourself.", 'error');
$edit = [
'banned_user' => $this->userB->getDisplayName() . ' (' . $this->userB->id() . ')',
];
$this->submitForm($edit, 'Block');
$this->assertSession()->statusMessageContains("The user " . $this->userB->getDisplayName() . " has been banned.", 'status');
$edit = [
'banned_user' => $this->userB->getDisplayName() . ' (' . $this->userB->id() . ')',
];
$this->submitForm($edit, 'Block');
$this->assertSession()->statusMessageContains('The user is already blocked', 'error');
}
/**
* Returns a count of bans.
*/
Loading