GenpassTest.php in Generate Password 8
File
tests/src/FunctionalJavascript/GenpassTest.php
View source
<?php
namespace Drupal\Tests\genpass\FunctionalJavascript;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Tests\BrowserTestBase;
class GenpassTest extends BrowserTestBase {
use StringTranslationTrait;
public static $modules = [
'user',
'toolbar',
'genpass',
];
protected $defaultTheme = 'stark';
protected $webUser;
protected function setUp() {
parent::setUp();
$permissions = [
'access toolbar',
'view the administration theme',
'administer account settings',
'administer users',
];
$this->webUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->webUser);
}
public function testGenpassConfigsAndCreateUsersByAdmin() {
$this
->drupalGet('admin/config/people/accounts');
$this
->assertSession()
->pageTextContains($this
->t('Account settings'));
$this
->assertSession()
->pageTextContains($this
->t('Password handling'));
$this
->assertSession()
->pageTextContains($this
->t('Generated password length'));
$this
->assertSession()
->pageTextContains($this
->t('Password generation algorithm'));
$this
->assertSession()
->pageTextContains($this
->t('Generated password display'));
$this
->getSession()
->getPage()
->selectFieldOption('genpass_mode', '2');
$this
->getSession()
->getPage()
->pressButton($this
->t('Save configuration'));
$this
->assertSession()
->pageTextContains($this
->t('The configuration options have been saved.'));
$this
->drupalGet('admin/people/create');
$this
->assertSession()
->pageTextContains($this
->t('Add user'));
$this
->getSession()
->getPage()
->fillField('mail', 'authenticated.test@drupal.org');
$this
->getSession()
->getPage()
->fillField('Username', 'test_authenticated');
$this
->getSession()
->getPage()
->pressButton('Create new account');
$this
->assertSession()
->pageTextContains($this
->t('Since you did not provide a password, it was generated automatically for this account.'));
$this
->assertSession()
->pageTextContains($this
->t('Created a new user account for test_authenticated. No email has been sent.'));
}
}