public function RegistrationTest::testPageLink in Legal 2.0.x
Same name and namespace in other branches
- 8 tests/src/Functional/RegistrationTest.php \Drupal\Tests\legal\Functional\RegistrationTest::testPageLink()
Test if T&Cs page link displays and behaves correctly.
File
- tests/
src/ Functional/ RegistrationTest.php, line 115
Class
- RegistrationTest
- Tests a user creating an account.
Namespace
Drupal\Tests\legal\FunctionalCode
public function testPageLink() {
// Set conditions to display in an un-editable HTML text area.
$this
->config('legal.settings')
->set('registration_terms_style', 3)
->set('registration_container', 0)
->save();
// Go to registration page.
$this
->drupalGet('user/register');
// Check link display.
$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');
// Click the link.
$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');
// Check user is on page displaying T&C.
$current_url = $this
->getUrl();
$expected_url = $this->baseUrl . '/legal';
$this
->assertEquals($current_url, $expected_url);
}