UserNotBlockedTest.php in Create user permission 2.x
File
tests/src/Functional/UserNotBlockedTest.php
View source
<?php
namespace Drupal\Tests\create_user_permission\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class UserNotBlockedTest extends BrowserTestBase {
use StringTranslationTrait;
protected $defaultTheme = 'stark';
protected static $modules = [
'create_user_permission',
];
public function testNotBlocked() {
$values = [
'visitors_admin_approval',
'admin_only',
];
foreach ($values as $value) {
\Drupal::configFactory()
->getEditable('user.settings')
->set('register', $value)
->save();
$create_user = $this
->drupalCreateUser([
'create users',
]);
$this
->drupalLogin($create_user);
$this
->drupalGet('admin/people/create');
$testmail = 'testuser1@example.com';
$password = 'testpassword';
$this
->drupalPostForm('admin/people/create', [
'mail' => $testmail,
'name' => $testmail,
'pass[pass1]' => $password,
'pass[pass2]' => $password,
], $this
->t('Create new account'));
$user = user_load_by_mail($testmail);
$this
->assertFalse($user
->isBlocked());
}
}
}