public function LoginTest::testPageLink in Legal 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/LoginTest.php \Drupal\Tests\legal\Functional\LoginTest::testPageLink()
Test if T&Cs page link displays and behaves correctly.
File
- tests/
src/ Functional/ LoginTest.php, line 116
Class
- LoginTest
- Tests a user loging into an account and accepting new T&C.
Namespace
Drupal\Tests\legal\FunctionalCode
public function testPageLink() {
// Set to display as a link to T&Cs.
$this
->config('legal.settings')
->set('login_terms_style', 3)
->set('login_container', 0)
->save();
$this
->drupalPostForm('user/login', $this->loginDetails, $this
->t('Log in'));
// Check link display.
$this
->assertSession()
->elementExists('css', '#legal-login > 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('#legal-login > 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);
}