View source
<?php
namespace Drupal\Tests\legal\Functional;
use Drupal\user\UserInterface;
class RegistrationTest extends LegalTestBase {
public function setUp() {
parent::setUp();
$this
->config('user.settings')
->set('verify_mail', FALSE)
->set('register', UserInterface::REGISTER_VISITORS)
->save();
}
public function testRegistration() {
$edit = [
'mail' => 'roy@example.com',
'name' => 'Roy Batty',
'pass[pass1]' => 'xyz',
'pass[pass2]' => 'xyz',
'legal_accept' => TRUE,
];
$this
->drupalPostForm('user/register', $edit, 'Create new account');
$this
->assertText('Registration successful. You are now logged in.');
}
public function testScrollBox() {
$this
->config('legal.settings')
->set('registration_terms_style', 0)
->set('registration_container', 0)
->save();
$this
->drupalGet('user/register');
$readonly = $this
->assertSession()
->elementExists('css', 'textarea#edit-conditions')
->getAttribute('readonly');
$this
->assertEquals($readonly, 'readonly');
$this
->assertSession()
->elementTextContains('css', 'textarea#edit-conditions', $this->conditionsPlainText);
}
public function testScrollBoxCss() {
$this
->config('legal.settings')
->set('registration_terms_style', 1)
->set('registration_container', 0)
->save();
$this
->drupalGet('user/register');
$this
->assertSession()
->elementExists('css', '#user-register-form > div.legal-terms-scroll');
$this
->assertSession()
->elementContains('css', '#user-register-form > div.legal-terms-scroll', $this->conditions);
}
public function testHtml() {
$this
->config('legal.settings')
->set('registration_terms_style', 2)
->set('registration_container', 0)
->save();
$this
->drupalGet('user/register');
$this
->assertSession()
->elementContains('css', '#user-register-form > div.legal-terms', $this->conditions);
}
public function testPageLink() {
$this
->config('legal.settings')
->set('registration_terms_style', 3)
->set('registration_container', 0)
->save();
$this
->drupalGet('user/register');
$this
->assertSession()
->elementExists('css', '#user-register-form > div.js-form-item.form-item.js-form-type-checkbox.form-type-checkbox.js-form-item-legal-accept.form-item-legal-accept > label > a');
$this
->click('#user-register-form > div.js-form-item.form-item.js-form-type-checkbox.form-type-checkbox.js-form-item-legal-accept.form-item-legal-accept > label > a');
$current_url = $this
->getUrl();
$expected_url = $this->baseUrl . '/legal';
$this
->assertEquals($current_url, $expected_url);
}
}