assertRegistrationFormCacheTagsWithUserFields example

$this->assertSession()->pageTextNotContains($field->label());
    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:core.entity_form_display.user.user.register');
    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:user.settings');

    // Have the field appear on the registration form.     $display_repository->getFormDisplay('user', 'user', 'register')
      ->setComponent('test_user_field', ['type' => 'test_field_widget'])
      ->save();

    $this->drupalGet('user/register');
    $this->assertSession()->pageTextContains($field->label());
    $this->assertRegistrationFormCacheTagsWithUserFields();

    // Check that validation errors are correctly reported.     $edit = [];
    $edit['name'] = $name = $this->randomMachineName();
    $edit['mail'] = $mail = $edit['name'] . '@example.com';
    // Missing input in required field.     $edit['test_user_field[0][value]'] = '';
    $this->submitForm($edit, 'Create new account');
    $this->assertRegistrationFormCacheTagsWithUserFields();
    $this->assertSession()->pageTextContains("{$field->label()} field is required.");
    // Invalid input.
Home | Imprint | This part of the site doesn't use cookies.