resetFilterCaches example

// Create three text formats. Two text formats are created for all users so     // that the drop-down list appears for all tests.     $this->drupalLogin($this->filterAdminUser);
    $formats = [];
    for ($i = 0; $i < 3; $i++) {
      $edit = [
        'format' => mb_strtolower($this->randomMachineName()),
        'name' => $this->randomMachineName(),
      ];
      $this->drupalGet('admin/config/content/formats/add');
      $this->submitForm($edit, 'Save configuration');
      $this->resetFilterCaches();
      $formats[] = FilterFormat::load($edit['format']);
    }
    [$this->allowedFormat, $this->secondAllowedFormat, $this->disallowedFormat] = $formats;
    $this->drupalLogout();

    // Create a regular user with access to two of the formats.     $this->webUser = $this->drupalCreateUser([
      'create page content',
      'edit any page content',
      $this->allowedFormat->getPermissionName(),
      $this->secondAllowedFormat->getPermissionName(),
    ]);
    // both formats, but the second user only has access to the second one.     $admin_user = $this->drupalCreateUser(['administer filters']);
    $this->drupalLogin($admin_user);
    $formats = [];
    for ($i = 0; $i < 2; $i++) {
      $edit = [
        'format' => mb_strtolower($this->randomMachineName()),
        'name' => $this->randomMachineName(),
      ];
      $this->drupalGet('admin/config/content/formats/add');
      $this->submitForm($edit, 'Save configuration');
      $this->resetFilterCaches();
      $formats[] = FilterFormat::load($edit['format']);
    }
    [$first_format$second_format] = $formats;
    $second_format_permission = $second_format->getPermissionName();
    $first_user = $this->drupalCreateUser([
      $first_format->getPermissionName(),
      $second_format_permission,
    ]);
    $second_user = $this->drupalCreateUser([$second_format_permission]);

    // Adjust the weights so that the first and second formats (in that order)
Home | Imprint | This part of the site doesn't use cookies.