UserRegisterFormTest.php

Namespace

Drupal\Tests\user\FunctionalJavascript

File

core/modules/user/tests/src/FunctionalJavascript/UserRegisterFormTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\user\FunctionalJavascript;

use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

/**
 * Tests user registration forms via JS.
 */
class UserRegisterFormTest extends WebDriverTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  
  /**
   * Tests if registration form writes to localStorage.
   */
  public function testRegistrationFormStorage() : void {
    // Load register form.
    $this->drupalGet('user/register');
    // Register user.
    $name = $this->randomMachineName();
    $page = $this->getSession()
      ->getPage();
    $page->fillField('edit-name', $name);
    $page->fillField('edit-mail', $name . '@example.com');
    $page->pressButton('edit-submit');
    // Test if localStorage is set now.
    $this->assertJsCondition("localStorage.getItem('Drupal.visitor.name') === null", 10000, 'Failed to assert that the visitor name was not written to localStorage.');
  }

}

Classes

Title Deprecated Summary
UserRegisterFormTest Tests user registration forms via JS.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.