UserRegistrationPasswordUserPasswordResetForm.php in User registration password 8
File
tests/src/Functional/UserRegistrationPasswordUserPasswordResetForm.php
View source
<?php
namespace Drupal\Tests\user_registrationpassword\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Test\AssertMailTrait;
class UserRegistrationPasswordUserPasswordResetForm extends BrowserTestBase {
use AssertMailTrait {
getMails as drupalGetMails;
}
protected $defaultTheme = 'stark';
public static $modules = [
'user_registrationpassword',
];
protected function setUp() {
parent::setUp();
global $base_url;
$this->base_url = $base_url;
}
public function testUserRegistrationPasswordUserPasswordResetForm() {
$edit1 = [];
$edit1['name'] = $this
->randomMachineName();
$edit1['mail'] = $edit1['name'] . '@example.com';
$edit1['pass[pass1]'] = $new_pass = $this
->randomMachineName();
$edit1['pass[pass2]'] = $new_pass;
$this
->drupalPostForm('user/register', $edit1, 'Create new account');
$this
->assertText('A welcome message with further instructions has been sent to your email address.', 'User registered successfully.');
$edit2 = [];
$edit2['name'] = $edit1['name'];
$this
->drupalPostForm('user/password', $edit2, 'Submit');
$this
->assertText('Further instructions have been sent to your email address.', 'Password reset form submitted successfully.');
$_emails = $this
->getMails();
$email = end($_emails);
$this
->assertNotEmpty($email['subject']);
$this
->assertNotEmpty($email['body']);
$this
->assertNotEqual($email['send'], 0);
}
}