-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #754 from City-of-Helsinki/UHF-9832
UHF-9832 User cancellation form
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
delete user accounts: | ||
title: Delete user accounts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\Tests\helfi_platform_config\Functional; | ||
|
||
use Drupal\Tests\helfi_api_base\Functional\BrowserTestBase; | ||
|
||
/** | ||
* Tests user cancel method form. | ||
* | ||
* @group helfi_platform_config | ||
*/ | ||
class UserCancelFormTest extends BrowserTestBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = [ | ||
'user', | ||
'helfi_platform_config', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $defaultTheme = 'stark'; | ||
|
||
/** | ||
* Tests user cancel method form. | ||
*/ | ||
public function testUserCancelForm(): void { | ||
// Create user accounts for testing the delete methods. | ||
$superAdminUser = $this->drupalCreateUser([], 'superAdminUser', TRUE); | ||
$adminUser = $this->drupalCreateUser([ | ||
'access user profiles', | ||
'administer users', | ||
'cancel account', | ||
], 'superUser'); | ||
$editorUser = $this->drupalCreateUser([ | ||
'access user profiles', | ||
'cancel account', | ||
], 'editorUser'); | ||
$testUser = $this->drupalCreateUser([], 'testUser'); | ||
|
||
// Test that the superAdminUser can see all cancellation methods | ||
// for the testUser account. | ||
$this->drupalLogin($superAdminUser); | ||
$this->drupalGet('/user/' . $testUser->id() . '/cancel'); | ||
$this->assertSession()->statusCodeEquals(200); | ||
$this->assertSession()->elementExists('xpath', '//input[@value="user_cancel_block"]'); | ||
$this->assertSession()->elementExists('xpath', '//input[@value="user_cancel_block_unpublish"]'); | ||
$this->assertSession()->elementExists('xpath', '//input[@value="user_cancel_reassign"]'); | ||
$this->assertSession()->elementExists('xpath', '//input[@value="user_cancel_delete"]'); | ||
|
||
// Test that the adminUser can see all only cancellation methods, but not | ||
// deletion methods for the testUser account. | ||
$this->drupalLogin($adminUser); | ||
$this->drupalGet('/user/' . $testUser->id() . '/cancel'); | ||
$this->assertSession()->statusCodeEquals(200); | ||
$this->assertSession()->elementExists('xpath', '//input[@value="user_cancel_block"]'); | ||
$this->assertSession()->elementExists('xpath', '//input[@value="user_cancel_block_unpublish"]'); | ||
$this->assertSession()->elementNotExists('xpath', '//input[@value="user_cancel_reassign"]'); | ||
$this->assertSession()->elementNotExists('xpath', '//input[@value="user_cancel_delete"]'); | ||
|
||
// Test that the editorUser cannot access the cancel page. | ||
$this->drupalLogin($editorUser); | ||
$this->drupalGet('/user/' . $testUser->id() . '/cancel'); | ||
$this->assertSession()->statusCodeEquals(403); | ||
} | ||
|
||
} |