You are here

class SimplenewsAdministrationTest in Simplenews 8

Managing of newsletter categories and content types.

@group simplenews

Hierarchy

Expanded class hierarchy of SimplenewsAdministrationTest

File

src/Tests/SimplenewsAdministrationTest.php, line 17

Namespace

Drupal\simplenews\Tests
View source
class SimplenewsAdministrationTest extends SimplenewsTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array(
    'help',
  );

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $this
      ->drupalPlaceBlock('help_block');
  }

  /**
   * Implement getNewsletterFieldId($newsletter_id)
   */
  function getNewsletterFieldId($newsletter_id) {
    return 'edit-subscriptions-' . str_replace('_', '-', $newsletter_id);
  }

  /**
   * Test various combinations of newsletter settings.
   */
  function testNewsletterSettings() {

    // Allow registration of new accounts without approval.
    $site_config = $this
      ->config('user.settings');
    $site_config
      ->set('verify_mail', FALSE);
    $site_config
      ->save();
    $admin_user = $this
      ->drupalCreateUser(array(
      'administer blocks',
      'administer content types',
      'administer nodes',
      'access administration pages',
      'administer permissions',
      'administer newsletters',
      'administer simplenews subscriptions',
      'create simplenews_issue content',
      'send newsletter',
    ));
    $this
      ->drupalLogin($admin_user);
    $this
      ->drupalGet('admin/config/services/simplenews');

    // Check if the help text is displayed.
    $this
      ->assertText('Newsletter allow you to send periodic e-mails to subscribers.');

    // Create a newsletter for all possible setting combinations.
    $new_account = array(
      'none',
      'off',
      'on',
      'silent',
    );
    $opt_inout = array(
      'hidden',
      'single',
      'double',
    );
    foreach ($new_account as $new_account_setting) {
      foreach ($opt_inout as $opt_inout_setting) {
        $this
          ->clickLink(t('Add newsletter'));
        $edit = array(
          'name' => implode('-', array(
            $new_account_setting,
            $opt_inout_setting,
          )),
          'id' => implode('_', array(
            $new_account_setting,
            $opt_inout_setting,
          )),
          'description' => $this
            ->randomString(20),
          'new_account' => $new_account_setting,
          'opt_inout' => $opt_inout_setting,
          'priority' => rand(0, 5),
          'receipt' => rand(0, 1) ? TRUE : FALSE,
          'from_name' => $this
            ->randomMachineName(),
          'from_address' => $this
            ->randomEmail(),
        );
        $this
          ->drupalPostForm(NULL, $edit, t('Save'));
      }
    }

    // New title should be saved correctly.
    $this
      ->drupalPostForm('admin/config/services/simplenews/manage/default', [
      'subject' => 'Edited subject',
    ], t('Save'));
    $this
      ->drupalGet('admin/config/services/simplenews/manage/default');
    $this
      ->assertFieldByName('subject', 'Edited subject');
    $newsletters = simplenews_newsletter_get_all();

    // Check registration form.
    $this
      ->drupalLogout();
    $this
      ->drupalGet('user/register');
    foreach ($newsletters as $newsletter) {
      if (strpos($newsletter->name, '-') === FALSE) {
        continue;
      }

      // Explicitly subscribe to the off-double newsletter.
      if ($newsletter->name == 'off-double') {
        $off_double_newsletter_id = $newsletter
          ->id();
      }
      list($new_account_setting, $opt_inout_setting) = explode('-', $newsletter->name);
      if ($newsletter->new_account == 'on' && $newsletter->opt_inout != 'hidden') {
        $this
          ->assertFieldChecked($this
          ->getNewsletterFieldId($newsletter
          ->id()));
      }
      elseif ($newsletter->new_account == 'off' && $newsletter->opt_inout != 'hidden') {
        $this
          ->assertNoFieldChecked($this
          ->getNewsletterFieldId($newsletter
          ->id()));
      }
      else {
        $this
          ->assertNoField('subscriptions[' . $newsletter
          ->id() . ']', t('Hidden or silent newsletter is not shown.'));
      }
    }

    // Register a new user through the form.
    $edit = array(
      'name' => $this
        ->randomMachineName(),
      'mail' => $this
        ->randomEmail(),
      'pass[pass1]' => $pass = $this
        ->randomMachineName(),
      'pass[pass2]' => $pass,
      'subscriptions[' . $off_double_newsletter_id . ']' => $off_double_newsletter_id,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Create new account'));

    // Verify confirmation messages.
    $this
      ->assertText(t('Registration successful. You are now logged in.'));
    foreach ($newsletters as $newsletter) {

      // Check confirmation message for all on and non-hidden newsletters and
      // the one that was explicitly selected.
      if ($newsletter->new_account == 'on' && $newsletter->opt_inout != 'hidden' || $newsletter->name == 'off-double') {
        $this
          ->assertText(t('You have been subscribed to @name.', array(
          '@name' => $newsletter->name,
        )));
      }
      else {

        // All other newsletters must not show a message, e.g. those which were
        // subscribed silently.
        $this
          ->assertNoText(t('You have been subscribed to @name.', array(
          '@name' => $newsletter->name,
        )));
      }
    }

    // Log out again.
    $this
      ->drupalLogout();
    $user = user_load_by_name($edit['name']);

    // Set the password so that the login works.
    $user->pass_raw = $edit['pass[pass1]'];

    // Verify newsletter subscription pages.
    $this
      ->drupalLogin($user);
    foreach (array(
      'newsletter/subscriptions',
      'user/' . $user
        ->id() . '/simplenews',
    ) as $path) {
      $this
        ->drupalGet($path);
      foreach ($newsletters as $newsletter) {
        if (strpos($newsletter->name, '-') === FALSE) {
          continue;
        }
        list($new_account_setting, $opt_inout_setting) = explode('-', $newsletter->name);
        if ($newsletter->opt_inout == 'hidden') {
          $this
            ->assertNoField('subscriptions[' . $newsletter
            ->id() . ']', t('Hidden newsletter is not shown.'));
        }
        elseif ($newsletter->new_account == 'on' || $newsletter->name == 'off-double' || $newsletter->new_account == 'silent') {

          // All on, silent and the explicitly selected newsletter should be checked.
          $this
            ->assertFieldChecked($this
            ->getNewsletterFieldId($newsletter
            ->id()));
        }
        else {
          $this
            ->assertNoFieldChecked($this
            ->getNewsletterFieldId($newsletter
            ->id()));
        }
      }
    }

    // Unsubscribe from a newsletter.
    $edit = array(
      'subscriptions[' . $off_double_newsletter_id . ']' => FALSE,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Save'));
    $this
      ->drupalGet('user/' . $user
      ->id() . '/simplenews');
    $this
      ->assertNoFieldChecked($this
      ->getNewsletterFieldId($off_double_newsletter_id));

    // Get a newsletter which has the block enabled.

    /*foreach ($newsletters as $newsletter) {
        // The default newsletter is missing the from mail address. Use another one.
        if ($newsletter->block == TRUE && $newsletter->newsletter_id != 1 && $newsletter->opt_inout != 'hidden') {
          $edit_newsletter = $newsletter;
          break;
        }
      }*/

    // Check saving the subscriber as admin does not wipe the hidden newsletter settings.
    $this
      ->drupalLogin($admin_user);
    $subscriber = simplenews_subscriber_load_by_mail($user
      ->getEmail());
    $this
      ->drupalGet('admin/people/simplenews/edit/' . $subscriber
      ->id());
    $this
      ->assertNoField($this
      ->getNewsletterFieldId('on_hidden'));
    $this
      ->assertNoField('mail');
    $this
      ->drupalPostForm('admin/people/simplenews/edit/' . $subscriber
      ->id(), [], t('Save'));
    $this
      ->drupalGet('admin/people/simplenews/edit/' . $subscriber
      ->id());
    $this
      ->assertTrue($subscriber
      ->isSubscribed('on_hidden'));
    $this
      ->assertTrue($subscriber
      ->isUnsubscribed($off_double_newsletter_id));

    /*$this->setupSubscriptionBlock($edit_newsletter->newsletter_id, $settings = array(
          'issue count' => 2,
          'previous issues' => 1,
        ));

        // Create a bunch of newsletters.
        $generated_names = array();
        $date = strtotime('monday this week');
        for ($index = 0; $index < 3; $index++) {
          $name = $this->randomMachineName();
          $generated_names[] = $name;
          $this->drupalGet('node/add/simplenews_issue');
          $edit = array(
            'title' => $name,
            'simplenews_newsletter[und]' => $edit_newsletter->newsletter_id,
            'date' => date('c', strtotime('+' . $index . ' day', $date)),
          );
          $this->drupalPostForm(NULL, $edit, ('Save'));
          $this->clickLink(t('Newsletter'));
          $this->drupalPostForm(NULL, array('simplenews[send]' => SIMPLENEWS_COMMAND_SEND_NOW), t('Submit'));
        }

        // Display the two recent issues.
        $this->drupalGet('');
        $this->assertText(t('Previous issues'), 'Should display recent issues.');

        $displayed_issues = $this->xpath("//div[@class='issues-list']/div/ul/li/a");

        $this->assertEqual(count($displayed_issues), 2, 'Displys two recent issues.');

        $this->assertFalse(in_array($generated_names[0], $displayed_issues));
        $this->assertTrue(in_array($generated_names[1], $displayed_issues));
        $this->assertTrue(in_array($generated_names[2], $displayed_issues));

        $this->drupalGet('admin/config/services/simplenews/manage/' . $edit_newsletter->id());
        $this->assertFieldByName('name', $edit_newsletter->name, t('Newsletter name is displayed when editing'));
        $this->assertFieldByName('description', $edit_newsletter->description, t('Newsletter description is displayed when editing'));

        $edit = array('block' => FALSE);
        $this->drupalPostForm(NULL, $edit, t('Save'));

        \Drupal::entityManager()->getStorage('simplenews_newsletter')->resetCache();
        $updated_newsletter = simplenews_newsletter_load($edit_newsletter->newsletter_id);
        $this->assertEqual(0, $updated_newsletter->block, t('Block for newsletter disabled'));

        $this->drupalGet('admin/structure/block');
        $this->assertNoText($edit_newsletter->name, t('Newsletter block was removed'));

        // Delete a newsletter.
        $this->drupalGet('admin/config/services/simplenews/manage/' . $edit_newsletter->id());
        $this->clickLink(t('Delete'));
        $this->drupalPostForm(NULL, array(), t('Delete'));

        // Verify that the newsletter has been deleted.
        \Drupal::entityManager()->getStorage('simplenews_newsletter')->resetCache();
        $this->assertFalse(simplenews_newsletter_load($edit_newsletter->newsletter_id));
        $this->assertFalse(db_query('SELECT newsletter_id FROM {simplenews_newsletter} WHERE newsletter_id = :newsletter_id', array(':newsletter_id' => $edit_newsletter->newsletter_id))->fetchField());*/

    // Check if the help text is displayed.
    $this
      ->drupalGet('admin/help/simplenews');
    $this
      ->assertText('Simplenews adds elements to the newsletter node add/edit');
    $this
      ->drupalGet('admin/config/services/simplenews/add');
    $this
      ->assertText('You can create different newsletters (or subjects)');
  }

  /**
   * Test newsletter subscription management.
   *
   * Steps performed:
   */
  function testSubscriptionManagement() {
    $admin_user = $this
      ->drupalCreateUser(array(
      'administer newsletters',
      'administer simplenews settings',
      'administer simplenews subscriptions',
      'administer users',
    ));
    $this
      ->drupalLogin($admin_user);

    // Create a newsletter.
    $newsletter_name = mb_strtolower($this
      ->randomMachineName());
    $edit = array(
      'name' => $newsletter_name,
      'id' => $newsletter_name,
    );
    $this
      ->drupalPostForm('admin/config/services/simplenews/add', $edit, t('Save'));

    // This test adds a number of subscribers to each newsletter separately and
    // then adds another bunch to both. First step is to create some arrays
    // that describe the actions to take.
    $subscribers = array();
    $groups = array();
    $newsletters = simplenews_newsletter_get_all();
    foreach ($newsletters as $newsletter) {
      $groups[$newsletter
        ->id()] = array(
        $newsletter
          ->id(),
      );
    }
    $groups['all'] = array_keys($groups);
    $subscribers_flat = array();
    foreach ($groups as $key => $group) {
      for ($i = 0; $i < 5; $i++) {
        $mail = $this
          ->randomEmail();
        $subscribers[$key][$mail] = $mail;
        $subscribers_flat[$mail] = $mail;
      }
    }

    // Create a user and assign him one of the mail addresses of the all group.
    // The other subscribers will not be users, just anonymous subscribers.
    $user = $this
      ->drupalCreateUser(array(
      'subscribe to newsletters',
    ));

    // Make sure that user_save() does not update the user object, as it will
    // override the pass_raw property which we'll need to log this user in
    // later on.
    $user_mail = current($subscribers['all']);
    $user
      ->setEmail($user_mail);
    $user
      ->save();
    $delimiters = array(
      ',',
      ' ',
      "\n",
    );

    // Add the subscribers using mass subscribe.
    $this
      ->drupalGet('admin/people');
    $this
      ->clickLink('Subscribers');
    $i = 0;
    foreach ($groups as $key => $group) {
      $this
        ->clickLink(t('Mass subscribe'));
      $edit = array(
        // Implode with a different, supported delimiter for each group.
        'emails' => implode($delimiters[$i++], $subscribers[$key]),
      );
      foreach ($group as $newsletter_id) {
        $edit['newsletters[' . $newsletter_id . ']'] = TRUE;
      }
      $this
        ->drupalPostForm(NULL, $edit, t('Subscribe'));
    }

    // Verify that all addresses are displayed in the table.
    $rows = $this
      ->xpath('//tbody/tr');
    $mail_addresses = array();
    for ($i = 0; $i < count($subscribers_flat); $i++) {
      $email = trim((string) $rows[$i]->td[0]);
      $mail_addresses[] = $email;
      if ($email == $user_mail) {

        // The user to which the mail was assigned should show the user name.
        $this
          ->assertEqual(trim((string) $rows[$i]->td[1]
          ->children()[0]), $user
          ->getAccountName());
      }
      else {

        // Blank value for user name.
        $this
          ->assertEqual($rows[$i]->td[1]
          ->count(), 0);
      }
    }
    $this
      ->assertEqual(15, count($mail_addresses));
    foreach ($mail_addresses as $mail_address) {
      $mail_address = (string) $mail_address;
      $this
        ->assertTrue(isset($subscribers_flat[$mail_address]));
      unset($subscribers_flat[$mail_address]);
    }

    // All entries of the array should be removed by now.
    $this
      ->assertTrue(empty($subscribers_flat));
    reset($groups);
    $first = 'default';
    $first_mail = array_rand($subscribers[$first]);
    $all_mail = array_rand($subscribers['all']);

    // Limit list to subscribers of the first newsletter only.
    // Build a flat list of the subscribers of this list.
    $subscribers_flat = array_merge($subscribers[$first], $subscribers['all']);
    $this
      ->drupalGet('admin/people/simplenews', array(
      'query' => array(
        'subscriptions_target_id' => $first,
      ),
    ));

    // Verify that all addresses are displayed in the table.
    $rows = $this
      ->xpath('//tbody/tr');
    $mail_addresses = array();
    for ($i = 0; $i < count($subscribers_flat); $i++) {
      $mail_addresses[] = trim((string) $rows[$i]->td[0]);
    }
    $this
      ->assertEqual(10, count($mail_addresses));
    foreach ($mail_addresses as $mail_address) {
      $mail_address = (string) $mail_address;
      $this
        ->assertTrue(isset($subscribers_flat[$mail_address]));
      unset($subscribers_flat[$mail_address]);
    }

    // All entries of the array should be removed by now.
    $this
      ->assertTrue(empty($subscribers_flat));

    // Filter a single mail address, the one assigned to a user.
    $edit = array(
      'mail' => mb_substr(current($subscribers['all']), 0, 4),
    );
    $this
      ->drupalGet('admin/people/simplenews', array(
      'query' => array(
        'mail' => $edit['mail'],
      ),
    ));
    $rows = $this
      ->xpath('//tbody/tr');
    $this
      ->assertEqual(1, count($rows));
    $this
      ->assertEqual(current($subscribers['all']), trim((string) $rows[0]->td[0]));

    // Mysteriously, the username is sometimes a span and sometimes a link.  Accept both.
    $this
      ->assertEqual($user
      ->label(), trim((string) $rows[0]->td[1]
      ->xpath('span|a')[0]));

    // Reset the filter.
    $this
      ->drupalGet('admin/people/simplenews');

    // Test mass-unsubscribe, unsubscribe one from the first group and one from
    // the all group, but only from the first newsletter.
    unset($subscribers[$first][$first_mail]);
    $edit = array(
      'emails' => $first_mail . ', ' . $all_mail,
      'newsletters[' . $first . ']' => TRUE,
    );
    $this
      ->clickLink(t('Mass unsubscribe'));
    $this
      ->drupalPostForm(NULL, $edit, t('Unsubscribe'));

    // The all mail is still displayed because it's still subscribed to the
    // second newsletter. Reload the page to get rid of the confirmation
    // message.
    $this
      ->drupalGet('admin/people/simplenews');
    $this
      ->assertNoText($first_mail);
    $this
      ->assertText($all_mail);

    // Limit to first newsletter, the all mail shouldn't be shown anymore.
    $this
      ->drupalGet('admin/people/simplenews', array(
      'query' => array(
        'subscriptions_target_id' => $first,
      ),
    ));
    $this
      ->assertNoText($first_mail);
    $this
      ->assertNoText($all_mail);

    // Check exporting.
    $this
      ->clickLink(t('Export'));
    $this
      ->drupalPostForm(NULL, array(
      'newsletters[' . $first . ']' => TRUE,
    ), t('Export'));
    $export_field = $this
      ->xpath($this
      ->constructFieldXpath('name', 'emails'));
    $exported_mails = (string) $export_field[0];
    foreach ($subscribers[$first] as $mail) {
      $this
        ->assertTrue(strpos($exported_mails, $mail) !== FALSE, t('Mail address exported correctly.'));
    }
    foreach ($subscribers['all'] as $mail) {
      if ($mail != $all_mail) {
        $this
          ->assertTrue(strpos($exported_mails, $mail) !== FALSE, t('Mail address exported correctly.'));
      }
      else {
        $this
          ->assertFALSE(strpos($exported_mails, $mail) !== FALSE, t('Unsubscribed mail address not exported.'));
      }
    }

    // Only export unsubscribed mail addresses.
    $edit = array(
      'subscribed[subscribed]' => FALSE,
      'subscribed[unsubscribed]' => TRUE,
      'newsletters[' . $first . ']' => TRUE,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Export'));
    $export_field = $this
      ->xpath($this
      ->constructFieldXpath('name', 'emails'));
    $exported_mails = (string) $export_field[0];
    $exported_mails = explode(', ', $exported_mails);
    $this
      ->assertEqual(2, count($exported_mails));
    $this
      ->assertTrue(in_array($all_mail, $exported_mails));
    $this
      ->assertTrue(in_array($first_mail, $exported_mails));

    /** @var \Drupal\simplenews\Subscription\SubscriptionManagerInterface $subscription_manager */
    $subscription_manager = \Drupal::service('simplenews.subscription_manager');

    // Make sure there are unconfirmed subscriptions.
    $unconfirmed = array();
    $unconfirmed[] = $this
      ->randomEmail();
    $unconfirmed[] = $this
      ->randomEmail();
    foreach ($unconfirmed as $mail) {
      $subscription_manager
        ->subscribe($mail, $first, TRUE);
    }

    // Export unconfirmed active and inactive users.
    $edit = array(
      'states[active]' => TRUE,
      'states[inactive]' => TRUE,
      'subscribed[subscribed]' => FALSE,
      'subscribed[unconfirmed]' => TRUE,
      'subscribed[unsubscribed]' => FALSE,
      'newsletters[' . $first . ']' => TRUE,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Export'));
    $export_field = $this
      ->xpath($this
      ->constructFieldXpath('name', 'emails'));
    $exported_mails = (string) $export_field[0];
    $exported_mails = explode(', ', $exported_mails);
    $this
      ->assertTrue(in_array($unconfirmed[0], $exported_mails));
    $this
      ->assertTrue(in_array($unconfirmed[1], $exported_mails));

    // Only export unconfirmed mail addresses.
    $edit = array(
      'subscribed[subscribed]' => FALSE,
      'subscribed[unconfirmed]' => TRUE,
      'subscribed[unsubscribed]' => FALSE,
      'newsletters[' . $first . ']' => TRUE,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Export'));
    $export_field = $this
      ->xpath($this
      ->constructFieldXpath('name', 'emails'));
    $exported_mails = (string) $export_field[0];
    $exported_mails = explode(', ', $exported_mails);
    $this
      ->assertEqual(2, count($exported_mails));
    $this
      ->assertTrue(in_array($unconfirmed[0], $exported_mails));
    $this
      ->assertTrue(in_array($unconfirmed[1], $exported_mails));

    // Make sure the user is subscribed to the first newsletter_id.
    $subscription_manager
      ->subscribe($user_mail, $first, FALSE);
    $before_count = simplenews_count_subscriptions($first);

    // Block the user.
    $user
      ->block();
    $user
      ->save();
    $this
      ->drupalGet('admin/people/simplenews');

    // Verify updated subscriptions count.
    drupal_static_reset('simplenews_count_subscriptions');
    $after_count = simplenews_count_subscriptions($first);
    $this
      ->assertEqual($before_count - 1, $after_count, t('Blocked users are not counted in subscription count.'));

    // Test mass subscribe with previously unsubscribed users.
    for ($i = 0; $i < 3; $i++) {
      $tested_subscribers[] = $this
        ->randomEmail();
    }
    $subscription_manager
      ->subscribe($tested_subscribers[0], $first, FALSE);
    $subscription_manager
      ->subscribe($tested_subscribers[1], $first, FALSE);
    $subscription_manager
      ->unsubscribe($tested_subscribers[0], $first, FALSE);
    $subscription_manager
      ->unsubscribe($tested_subscribers[1], $first, FALSE);
    $unsubscribed = implode(', ', array_slice($tested_subscribers, 0, 2));
    $edit = array(
      'emails' => implode(', ', $tested_subscribers),
      'newsletters[' . $first . ']' => TRUE,
    );
    $this
      ->drupalPostForm('admin/people/simplenews/import', $edit, t('Subscribe'));
    \Drupal::entityTypeManager()
      ->getStorage('simplenews_subscriber')
      ->resetCache();
    $subscription_manager
      ->reset();
    $this
      ->assertFalse($subscription_manager
      ->isSubscribed($tested_subscribers[0], $first), t('Subscriber not resubscribed through mass subscription.'));
    $this
      ->assertFalse($subscription_manager
      ->isSubscribed($tested_subscribers[1], $first), t('Subscriber not resubscribed through mass subscription.'));
    $this
      ->assertTrue($subscription_manager
      ->isSubscribed($tested_subscribers[2], $first), t('Subscriber subscribed through mass subscription.'));
    $substitutes = array(
      '@name' => simplenews_newsletter_load($first)
        ->label(),
      '@mail' => $unsubscribed,
    );
    $this
      ->assertText(t('The following addresses were skipped because they have previously unsubscribed from @name: @mail.', $substitutes));
    $this
      ->assertText(t("If you would like to resubscribe them, use the 'Force resubscription' option."));

    // Try to mass subscribe without specifying newsletters.
    $tested_subscribers[2] = $this
      ->randomEmail();
    $edit = array(
      'emails' => implode(', ', $tested_subscribers),
      'resubscribe' => TRUE,
    );
    $this
      ->drupalPostForm('admin/people/simplenews/import', $edit, t('Subscribe'));
    $this
      ->assertText('Subscribe to field is required.');

    // Test mass subscribe with previously unsubscribed users and force
    // resubscription.
    $tested_subscribers[2] = $this
      ->randomEmail();
    $edit = array(
      'emails' => implode(', ', $tested_subscribers),
      'newsletters[' . $first . ']' => TRUE,
      'resubscribe' => TRUE,
    );
    $this
      ->drupalPostForm('admin/people/simplenews/import', $edit, t('Subscribe'));
    $subscription_manager
      ->reset();
    \Drupal::entityTypeManager()
      ->getStorage('simplenews_subscriber')
      ->resetCache();
    $this
      ->assertTrue($subscription_manager
      ->isSubscribed($tested_subscribers[0], $first, t('Subscriber resubscribed trough mass subscription.')));
    $this
      ->assertTrue($subscription_manager
      ->isSubscribed($tested_subscribers[1], $first, t('Subscriber resubscribed trough mass subscription.')));
    $this
      ->assertTrue($subscription_manager
      ->isSubscribed($tested_subscribers[2], $first, t('Subscriber subscribed trough mass subscription.')));

    // Try to mass unsubscribe without specifying newsletters.
    $tested_subscribers[2] = $this
      ->randomEmail();
    $edit = array(
      'emails' => implode(', ', $tested_subscribers),
    );
    $this
      ->drupalPostForm('admin/people/simplenews/unsubscribe', $edit, t('Unsubscribe'));
    $this
      ->assertText('Unsubscribe from field is required.');

    // Create two blocks, to ensure that they are updated/deleted when a
    // newsletter is deleted.
    $only_first_block = $this
      ->setupSubscriptionBlock([
      'newsletters' => [
        $first,
      ],
    ]);
    $all_block = $this
      ->setupSubscriptionBlock([
      'newsletters' => array_keys($groups),
    ]);
    $enabled_newsletters = $all_block
      ->get('settings')['newsletters'];
    $this
      ->assertTrue(in_array($first, $enabled_newsletters));

    // Delete newsletter.
    \Drupal::entityTypeManager()
      ->getStorage('simplenews_newsletter')
      ->resetCache();
    $this
      ->drupalGet('admin/config/services/simplenews/manage/' . $first);
    $this
      ->clickLink(t('Delete'));
    $this
      ->drupalPostForm(NULL, array(), t('Delete'));
    $this
      ->assertText(t('All subscriptions to newsletter @newsletter have been deleted.', array(
      '@newsletter' => $newsletters[$first]->name,
    )));

    // Verify that all related data has been deleted/updated.
    $this
      ->assertNull(Newsletter::load($first));
    $this
      ->assertNull(Block::load($only_first_block
      ->id()));
    $all_block = Block::load($all_block
      ->id());
    $enabled_newsletters = $all_block
      ->get('settings')['newsletters'];
    $this
      ->assertFalse(in_array($first, $enabled_newsletters));

    // Verify that all subscriptions of that newsletter have been removed.
    $this
      ->drupalGet('admin/people/simplenews');
    foreach ($subscribers[$first] as $mail) {
      $this
        ->assertNoText($mail);
    }
    $this
      ->clickLink(t('Edit'), 1);

    // Get the subscriber id from the path.
    $this
      ->assertTrue(preg_match('|admin/people/simplenews/edit/(\\d+)\\?destination|', $this
      ->getUrl(), $matches), 'Subscriber found');
    $subscriber = Subscriber::load($matches[1]);
    $this
      ->assertTitle(t('Edit subscriber @mail', array(
      '@mail' => $subscriber
        ->getMail(),
    )) . ' | Drupal');
    $this
      ->assertFieldChecked('edit-status');

    // Disable account.
    $edit = array(
      'status' => FALSE,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Save'));
    \Drupal::entityTypeManager()
      ->getStorage('simplenews_subscriber')
      ->resetCache();
    $subscription_manager
      ->reset();
    $this
      ->assertFalse($subscription_manager
      ->isSubscribed($subscriber
      ->getMail(), $this
      ->getRandomNewsletter()), t('Subscriber is not active'));

    // Re-enable account.
    $this
      ->drupalGet('admin/people/simplenews/edit/' . $subscriber
      ->id());
    $this
      ->assertTitle(t('Edit subscriber @mail', array(
      '@mail' => $subscriber
        ->getMail(),
    )) . ' | Drupal');
    $this
      ->assertNoFieldChecked('edit-status');
    $edit = array(
      'status' => TRUE,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Save'));
    \Drupal::entityTypeManager()
      ->getStorage('simplenews_subscriber')
      ->resetCache();
    $subscription_manager
      ->reset();
    $this
      ->assertTrue($subscription_manager
      ->isSubscribed($subscriber
      ->getMail(), $this
      ->getRandomNewsletter()), t('Subscriber is active again.'));

    // Remove the newsletter.
    $this
      ->drupalGet('admin/people/simplenews/edit/' . $subscriber
      ->id());
    $this
      ->assertTitle(t('Edit subscriber @mail', array(
      '@mail' => $subscriber
        ->getMail(),
    )) . ' | Drupal');
    \Drupal::entityTypeManager()
      ->getStorage('simplenews_subscriber')
      ->resetCache();
    $subscriber = Subscriber::load($subscriber
      ->id());
    $nlids = $subscriber
      ->getSubscribedNewsletterIds();

    // If the subscriber still has subscribed to newsletter, try to unsubscribe.
    $newsletter_id = reset($nlids);
    $edit['subscriptions[' . $newsletter_id . ']'] = FALSE;
    $this
      ->drupalPostForm(NULL, $edit, t('Save'));
    \Drupal::entityTypeManager()
      ->getStorage('simplenews_subscriber')
      ->resetCache();
    $subscription_manager
      ->reset();
    $nlids = $subscriber
      ->getSubscribedNewsletterIds();
    $this
      ->assertFalse($subscription_manager
      ->isSubscribed($subscriber
      ->getMail(), reset($nlids)), t('Subscriber not subscribed anymore.'));

    // @todo Test Admin subscriber edit preferred language $subscription->language
    // Register a subscriber with an insecure e-mail address through the API
    // and make sure the address is correctly encoded.
    $xss_mail = "<script>alert('XSS');</script>";
    $subscription_manager
      ->subscribe($xss_mail, $this
      ->getRandomNewsletter(), FALSE);
    $this
      ->drupalGet('admin/people/simplenews');
    $this
      ->assertNoRaw($xss_mail);
    $this
      ->assertRaw(Html::escape($xss_mail));
    $xss_subscriber = simplenews_subscriber_load_by_mail($xss_mail);
    $this
      ->drupalGet('admin/people/simplenews/edit/' . $xss_subscriber
      ->id());
    $this
      ->assertNoRaw($xss_mail);
    $this
      ->assertRaw(Html::escape($xss_mail));

    // Create a new user for the next test.
    $new_user = $this
      ->drupalCreateUser(array(
      'subscribe to newsletters',
    ));

    // Test for saving the subscription for no newsletter.
    $this
      ->drupalPostForm('user/' . $new_user
      ->id() . '/simplenews', null, t('Save'));
    $this
      ->assertText('The newsletter subscriptions for user ' . $new_user
      ->getAccountName() . ' have been updated.');

    // Editing a subscriber with subscription.
    $edit = array(
      'subscriptions[' . $newsletter_name . ']' => TRUE,
      'status' => TRUE,
      'mail[0][value]' => 'edit@example.com',
    );
    $this
      ->drupalPostForm('admin/people/simplenews/edit/' . $xss_subscriber
      ->id(), $edit, t('Save'));
    $this
      ->assertText('Subscriber edit@example.com has been updated.');

    // Create a second newsletter.
    $second_newsletter_name = mb_strtolower($this
      ->randomMachineName());
    $edit2 = array(
      'name' => $second_newsletter_name,
      'id' => $second_newsletter_name,
    );
    $this
      ->drupalPostForm('admin/config/services/simplenews/add', $edit2, t('Save'));

    // Test for adding a subscriber.
    $subscribe = array(
      'newsletters[' . $newsletter_name . ']' => TRUE,
      'emails' => 'drupaltest@example.com',
    );
    $this
      ->drupalPostForm('admin/people/simplenews/import', $subscribe, t('Subscribe'));

    // The subscriber should appear once in the list.
    $rows = $this
      ->xpath('//tbody/tr');
    $counter = 0;
    foreach ($rows as $value) {
      if (trim((string) $value->td[0]) == 'drupaltest@example.com') {
        $counter++;
      }
    }
    $this
      ->assertEqual(1, $counter);
    $this
      ->assertText(t('The following addresses were added or updated: @email.', [
      '@email' => 'drupaltest@example.com',
    ]));
    $this
      ->assertText(t('The addresses were subscribed to the following newsletters: @newsletter.', [
      '@newsletter' => $newsletter_name,
    ]));

    // Check exact subscription statuses.
    $subscriber = simplenews_subscriber_load_by_mail('drupaltest@example.com');
    $this
      ->assertEqual($subscriber
      ->getSubscription($newsletter_name)
      ->get('status')
      ->getValue(), SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);

    // The second newsletter was not subscribed, so there should be no
    // subscription record at all.
    $this
      ->assertFalse($subscriber
      ->getSubscription($second_newsletter_name));
  }

  /**
   * Test content type configuration.
   */
  function testContentTypes() {
    $admin_user = $this
      ->drupalCreateUser(array(
      'administer blocks',
      'administer content types',
      'administer nodes',
      'access administration pages',
      'administer permissions',
      'administer newsletters',
      'administer simplenews subscriptions',
      'bypass node access',
      'send newsletter',
    ));
    $this
      ->drupalLogin($admin_user);
    $this
      ->drupalGet('admin/structure/types');
    $this
      ->clickLink(t('Add content type'));
    $edit = array(
      'name' => $name = $this
        ->randomMachineName(),
      'type' => $type = strtolower($name),
      'simplenews_content_type' => TRUE,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Save content type'));

    // Verify that the newsletter settings are shown.
    $this
      ->drupalGet('node/add/' . $type);
    $this
      ->assertText(t('Issue'));

    // Create an issue.
    $edit = array(
      'title[0][value]' => $this
        ->randomMachineName(),
      'body[0][value]' => 'User ID: [current-user:uid]',
      'simplenews_issue' => $this
        ->getRandomNewsletter(),
    );
    $this
      ->drupalPostForm(NULL, $edit, 'Save');
    $node = $this
      ->drupalGetNodeByTitle($edit['title[0][value]']);
    $edit = array(
      'title[0][value]' => $this
        ->randomMachineName(),
      'body[0][value]' => 'Sample body text - Newsletter issue',
      'simplenews_issue' => $this
        ->getRandomNewsletter(),
    );
    $this
      ->drupalPostForm('node/add/simplenews_issue', $edit, 'Save');

    // Assert that body text is displayed.
    $this
      ->assertText('Sample body text - Newsletter issue');
    $node2 = $this
      ->drupalGetNodeByTitle($edit['title[0][value]']);

    // Assert subscriber count.
    $this
      ->clickLink(t('Newsletter'));
    $this
      ->assertText(t('Send newsletter issue to 0 subscribers.'));

    // Create some subscribers.
    $subscribers = array();
    for ($i = 0; $i < 3; $i++) {
      $subscribers[] = Subscriber::create(array(
        'mail' => $this
          ->randomEmail(),
      ));
    }
    foreach ($subscribers as $subscriber) {
      $subscriber
        ->setStatus(SubscriberInterface::ACTIVE);
    }

    // Subscribe to the default newsletter and set subscriber status.
    $subscribers[0]
      ->subscribe('default', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
    $subscribers[1]
      ->subscribe('default', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
    $subscribers[2]
      ->subscribe('default', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
    foreach ($subscribers as $subscriber) {
      $subscriber
        ->save();
    }

    // Check if the subscribers are listed in the newsletter tab.
    $this
      ->drupalGet('node/1/simplenews');
    $this
      ->assertText('Send newsletter issue to 3 subscribers.');

    // Send mails.
    $this
      ->assertField('test_address', $admin_user
      ->getEmail());

    // Test newsletter to empty address and check the error message.
    $this
      ->drupalPostForm(NULL, array(
      'test_address' => '',
    ), t('Send test newsletter issue'));
    $this
      ->assertText(t('Missing test email address.'));

    // Test newsletter to invalid address and check the error message.
    $this
      ->drupalPostForm(NULL, array(
      'test_address' => 'invalid_address',
    ), t('Send test newsletter issue'));
    $this
      ->assertText(t('Invalid email address "invalid_address"'));
    $this
      ->drupalPostForm(NULL, array(
      'test_address' => $admin_user
        ->getEmail(),
    ), t('Send test newsletter issue'));
    $this
      ->assertText(t('Test newsletter sent to user @name &lt;@email&gt;', array(
      '@name' => $admin_user
        ->getAccountName(),
      '@email' => $admin_user
        ->getEmail(),
    )));
    $mails = $this
      ->drupalGetMails();
    $this
      ->assertEqual('simplenews_test', $mails[0]['id']);
    $this
      ->assertEqual($admin_user
      ->getEmail(), $mails[0]['to']);
    $this
      ->assertEqual(t('[Default newsletter] @title', array(
      '@title' => $node
        ->getTitle(),
    )), $mails[0]['subject']);
    $this
      ->assertTrue(strpos($mails[0]['body'], 'User ID: ' . $admin_user
      ->id()));

    // Update the content type, remove the simpletest checkbox.
    $edit = array(
      'simplenews_content_type' => FALSE,
    );
    $this
      ->drupalPostForm('admin/structure/types/manage/' . $type, $edit, t('Save content type'));

    // Verify that the newsletter settings are still shown.
    // Note: Previously the field got autoremoved. We leave it remaining due to potential data loss.
    $this
      ->drupalGet('node/add/' . $type);
    $this
      ->assertNoText(t('Replacement patterns'));
    $this
      ->assertText(t('Issue'));

    // Test the visibility of subscription user component.
    $this
      ->drupalGet('node/' . $node
      ->id());
    $this
      ->assertNoText('Subscribed to');

    // Delete created nodes.
    $node
      ->delete();
    $node2
      ->delete();

    // @todo: Test node update/delete.
    // Delete content type.
    // @todo: Add assertions.
    $this
      ->drupalPostForm('admin/structure/types/manage/' . $type . '/delete', array(), t('Delete'));

    // Check the Add Newsletter Issue button.
    $this
      ->drupalGet('admin/content/simplenews');
    $this
      ->clickLink(t('Add Newsletter Issue'));
    $this
      ->assertUrl('node/add/simplenews_issue');

    // Check if the help text is displayed.
    $this
      ->assertText('Add this newsletter issue to a newsletter by selecting a newsletter from the select list.');
  }

  /**
   * Test content subscription status filter in subscriber view.
   */
  function testSubscriberStatusFilter() {

    // Make sure subscription overview can't be accessed without permission.
    $this
      ->drupalGet('admin/people/simplenews');
    $this
      ->assertResponse(403);
    $admin_user = $this
      ->drupalCreateUser(array(
      'administer newsletters',
      'create simplenews_issue content',
      'administer nodes',
      'administer simplenews subscriptions',
    ));
    $this
      ->drupalLogin($admin_user);
    $subscribers = array();

    // Create some subscribers.
    for ($i = 0; $i < 3; $i++) {
      $subscribers[] = Subscriber::create(array(
        'mail' => $this
          ->randomEmail(),
      ));
    }
    foreach ($subscribers as $subscriber) {
      $subscriber
        ->setStatus(SubscriberInterface::ACTIVE);
    }

    // Subscribe to the default newsletter and set subscriber status.
    $subscribers[0]
      ->subscribe('default', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
    $subscribers[1]
      ->subscribe('default', SIMPLENEWS_SUBSCRIPTION_STATUS_UNCONFIRMED);
    $subscribers[2]
      ->subscribe('default', SIMPLENEWS_SUBSCRIPTION_STATUS_UNSUBSCRIBED);
    foreach ($subscribers as $subscriber) {
      $subscriber
        ->save();
    }
    $newsletters = simplenews_newsletter_get_all();

    // Filter out subscribers by their subscription status and assert the output.
    $this
      ->drupalGet('admin/people/simplenews', array(
      'query' => array(
        'subscriptions_status' => SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED,
      ),
    ));
    $row = $this
      ->xpath('//tbody/tr');
    $this
      ->assertEqual(1, count($row));
    $this
      ->assertEqual($subscribers[0]
      ->getMail(), trim((string) $row[0]->td[0]));
    $this
      ->drupalGet('admin/people/simplenews', array(
      'query' => array(
        'subscriptions_status' => SIMPLENEWS_SUBSCRIPTION_STATUS_UNCONFIRMED,
      ),
    ));
    $row = $this
      ->xpath('//tbody/tr');
    $this
      ->assertEqual(1, count($row));
    $this
      ->assertEqual($subscribers[1]
      ->getMail(), trim((string) $row[0]->td[0]));
    $this
      ->assertText($newsletters['default']->name . ' (' . t('Unconfirmed') . ')');
    $this
      ->drupalGet('admin/people/simplenews', array(
      'query' => array(
        'subscriptions_status' => SIMPLENEWS_SUBSCRIPTION_STATUS_UNSUBSCRIBED,
      ),
    ));
    $row = $this
      ->xpath('//tbody/tr');
    $this
      ->assertEqual(1, count($row));
    $this
      ->assertEqual($subscribers[2]
      ->getMail(), trim((string) $row[0]->td[0]));
    $this
      ->assertText($newsletters['default']->name . ' (' . t('Unsubscribed') . ')');
  }

  /**
   * Test newsletter issue overview.
   */
  function testNewsletterIssuesOverview() {

    // Verify newsletter overview isn't available without permission.
    $this
      ->drupalGet('admin/content/simplenews');
    $this
      ->assertResponse(403);
    $admin_user = $this
      ->drupalCreateUser(array(
      'administer newsletters',
      'create simplenews_issue content',
      'administer simplenews subscriptions',
      'administer nodes',
      'send newsletter',
    ));
    $this
      ->drupalLogin($admin_user);

    // Create a newsletter.
    $edit = array(
      'name' => $name = $this
        ->randomMachineName(),
      'id' => mb_strtolower($name),
    );
    $this
      ->drupalPostForm('admin/config/services/simplenews/add', $edit, t('Save'));

    // Create a newsletter issue and publish.
    $edit = array(
      'title[0][value]' => 'Test_issue_1',
      'simplenews_issue' => mb_strtolower($name),
    );
    $this
      ->drupalPostForm('node/add/simplenews_issue', $edit, t('Save'));

    // Create another newsletter issue and keep unpublished.
    $edit = array(
      'title[0][value]' => 'Test_issue_2',
      'simplenews_issue' => mb_strtolower($name),
      'status[value]' => FALSE,
    );
    $this
      ->drupalPostForm('node/add/simplenews_issue', $edit, t('Save'));

    // Test mass subscribe with previously unsubscribed users.
    for ($i = 0; $i < 3; $i++) {
      $subscribers[] = $this
        ->randomEmail();
    }
    $edit = array(
      'emails' => implode(', ', $subscribers),
      'newsletters[' . mb_strtolower($name) . ']' => TRUE,
    );
    $this
      ->drupalPostForm('admin/people/simplenews/import', $edit, t('Subscribe'));
    $this
      ->drupalGet('admin/content/simplenews');

    // Check the correct values are present in the view.
    $rows = $this
      ->xpath('//tbody/tr');

    // Check the number of results in the view.
    $this
      ->assertEqual(2, count($rows));
    foreach ($rows as $row) {
      if ($row->td[1]->a == 'Test_issue_2') {
        $this
          ->assertEqual($name, trim((string) $row->td[2]->a));
        $this
          ->assertEqual('Newsletter issue will be sent to 3 subscribers.', trim((string) $row->td[5]->span['title']));
        $this
          ->assertEqual('✖', trim((string) $row->td[3]));
        $this
          ->assertEqual('0/3', trim((string) $row->td[5]->span));
      }
      else {
        $this
          ->assertEqual('✔', trim((string) $row->td[3]));
      }
    }

    // Send newsletter issues using bulk operations.
    $edit = array(
      'node_bulk_form[0]' => TRUE,
      'node_bulk_form[1]' => TRUE,
      'action' => 'simplenews_send_action',
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Apply to selected items'));

    // Check the relevant messages.
    $this
      ->assertText('Newsletter issue Test_issue_2 is unpublished and will be sent on publish.');
    $this
      ->assertText('The following newsletter(s) are now pending: Test_issue_1.');
    $rows = $this
      ->xpath('//tbody/tr');

    // Assert the status message of each newsletter.
    foreach ($rows as $row) {
      if ($row->td[1]->a == 'Test_issue_2') {
        $this
          ->assertEqual('Newsletter issue will be sent to 3 subscribers on publish.', trim((string) $row->td[5]->span['title']));
      }
      else {
        $this
          ->assertEqual('Newsletter issue is pending, 0 mails sent out of 3.', trim((string) $row->td[5]->img['title']));
        $this
          ->assertEqual(file_url_transform_relative(file_create_url(drupal_get_path('module', 'simplenews') . '/images/sn-cron.png')), trim((string) $row->td[5]->img['src']));
      }
    }

    // Stop sending the pending newsletters.
    $edit = array(
      'node_bulk_form[0]' => TRUE,
      'node_bulk_form[1]' => TRUE,
      'action' => 'simplenews_stop_action',
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Apply to selected items'));

    // Check the stop message.
    $this
      ->assertText('Sending of Test_issue_1 was stopped. 3 pending email(s) were deleted.');
    $rows = $this
      ->xpath('//tbody/tr');

    // Check the send status of each issue.
    foreach ($rows as $row) {
      if ($row->td[1]->a == 'Test_issue_2') {
        $this
          ->assertEqual('Newsletter issue will be sent to 3 subscribers on publish.', trim((string) $row->td[5]->span['title']));
      }
      else {
        $this
          ->assertEqual('Newsletter issue will be sent to 3 subscribers.', trim((string) $row->td[5]->span['title']));
      }
    }

    // Send newsletter issues using bulk operations.
    $edit = array(
      'node_bulk_form[0]' => TRUE,
      'node_bulk_form[1]' => TRUE,
      'action' => 'simplenews_send_action',
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Apply to selected items'));

    // Run cron to send the mails.
    $this
      ->cronRun();
    $this
      ->drupalGet('admin/content/simplenews');
    $rows = $this
      ->xpath('//tbody/tr');

    // Check the send status of each issue.
    foreach ($rows as $row) {
      if ($row->td[1]->a == 'Test_issue_2') {
        $this
          ->assertEqual('Newsletter issue will be sent to 3 subscribers on publish.', trim((string) $row->td[5]->span['title']));
      }
      else {
        $this
          ->assertEqual('Newsletter issue sent to 3 subscribers.', trim((string) $row->td[5]->img['title']));
        $this
          ->assertEqual(file_url_transform_relative(file_create_url(drupal_get_path('module', 'simplenews') . '/images/sn-sent.png')), trim((string) $row->td[5]->img['src']));
      }
    }
  }

  /**
   * Test access for subscriber admin page.
   */
  function testAccess() {
    $admin_user = $this
      ->drupalCreateUser(array(
      'administer newsletters',
      'administer simplenews subscriptions',
    ));
    $this
      ->drupalLogin($admin_user);

    // Create a newsletter.
    $newsletter_name = mb_strtolower($this
      ->randomMachineName());
    $edit = array(
      'name' => $newsletter_name,
      'id' => $newsletter_name,
    );
    $this
      ->drupalPostForm('admin/config/services/simplenews/add', $edit, t('Save'));

    // Create a user and subscribe them.
    $user = $this
      ->drupalCreateUser();
    $subscriber = Subscriber::create(array(
      'mail' => $user
        ->getEmail(),
    ));
    $subscriber
      ->subscribe('default', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
    $subscriber
      ->setStatus(SubscriberInterface::ACTIVE);
    $subscriber
      ->save();

    // Check anonymous user can't access admin page.
    $this
      ->drupalLogout();
    $this
      ->drupalGet('admin/people/simplenews');
    $this
      ->assertResponse(403);

    // Turn off the access permission on the view.
    $view = View::load('simplenews_subscribers');
    $display =& $view
      ->getDisplay('default');
    $display['display_options']['access'] = [
      'type' => 'none',
      'options' => [],
    ];
    $view
      ->save();
    \Drupal::service('router.builder')
      ->rebuild();

    // Check username is public but email is not shown.
    $this
      ->drupalGet('admin/people/simplenews');
    $this
      ->assertText($user
      ->getAccountName());
    $this
      ->assertNoText($user
      ->getEmail());

    // Grant view permission.
    $view_user = $this
      ->drupalCreateUser(array(
      'view simplenews subscriptions',
    ));
    $this
      ->drupalLogin($view_user);

    // Check can see username and email.
    $this
      ->drupalGet('admin/people/simplenews');
    $this
      ->assertText($user
      ->getAccountName());
    $this
      ->assertText($user
      ->getEmail());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssertContentTrait::$content protected property The current raw content.
AssertContentTrait::$drupalSettings protected property The drupalSettings value from the current raw $content.
AssertContentTrait::$elements protected property The XML structure parsed from the current raw $content. 1
AssertContentTrait::$plainTextContent protected property The plain-text content of raw $content (text nodes).
AssertContentTrait::assertEscaped protected function Passes if the raw text IS found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertField protected function Asserts that a field exists with the given name or ID.
AssertContentTrait::assertFieldById protected function Asserts that a field exists with the given ID and value.
AssertContentTrait::assertFieldByName protected function Asserts that a field exists with the given name and value.
AssertContentTrait::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
AssertContentTrait::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
AssertContentTrait::assertFieldsByValue protected function Asserts that a field exists in the current page with a given Xpath result.
AssertContentTrait::assertLink protected function Passes if a link with the specified label is found.
AssertContentTrait::assertLinkByHref protected function Passes if a link containing a given href (part) is found.
AssertContentTrait::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
AssertContentTrait::assertNoEscaped protected function Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertNoField protected function Asserts that a field does not exist with the given name or ID.
AssertContentTrait::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
AssertContentTrait::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
AssertContentTrait::assertNoFieldByXPath protected function Asserts that a field does not exist or its value does not match, by XPath.
AssertContentTrait::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
AssertContentTrait::assertNoLink protected function Passes if a link with the specified label is not found.
AssertContentTrait::assertNoLinkByHref protected function Passes if a link containing a given href (part) is not found.
AssertContentTrait::assertNoLinkByHrefInMainRegion protected function Passes if a link containing a given href is not found in the main region.
AssertContentTrait::assertNoOption protected function Asserts that a select option in the current page does not exist.
AssertContentTrait::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
AssertContentTrait::assertNoPattern protected function Triggers a pass if the perl regex pattern is not found in raw content.
AssertContentTrait::assertNoRaw protected function Passes if the raw text is NOT found on the loaded page, fail otherwise.
AssertContentTrait::assertNoText protected function Passes if the page (with HTML stripped) does not contains the text.
AssertContentTrait::assertNoTitle protected function Pass if the page title is not the given string.
AssertContentTrait::assertNoUniqueText protected function Passes if the text is found MORE THAN ONCE on the text version of the page.
AssertContentTrait::assertOption protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertOptionByText protected function Asserts that a select option with the visible text exists.
AssertContentTrait::assertOptionSelected protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionSelectedWithDrupalSelector protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionWithDrupalSelector protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertPattern protected function Triggers a pass if the Perl regex pattern is found in the raw content.
AssertContentTrait::assertRaw protected function Passes if the raw text IS found on the loaded page, fail otherwise.
AssertContentTrait::assertText protected function Passes if the page (with HTML stripped) contains the text.
AssertContentTrait::assertTextHelper protected function Helper for assertText and assertNoText.
AssertContentTrait::assertTextPattern protected function Asserts that a Perl regex pattern is found in the plain-text content.
AssertContentTrait::assertThemeOutput protected function Asserts themed output.
AssertContentTrait::assertTitle protected function Pass if the page title is the given string.
AssertContentTrait::assertUniqueText protected function Passes if the text is found ONLY ONCE on the text version of the page.
AssertContentTrait::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
AssertContentTrait::buildXPathQuery protected function Builds an XPath query.
AssertContentTrait::constructFieldXpath protected function Helper: Constructs an XPath for the given set of attributes and value.
AssertContentTrait::cssSelect protected function Searches elements using a CSS selector in the raw content.
AssertContentTrait::getAllOptions protected function Get all option elements, including nested options, in a select.
AssertContentTrait::getDrupalSettings protected function Gets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::getRawContent protected function Gets the current raw content.
AssertContentTrait::getSelectedItem protected function Get the selected value from a select field.
AssertContentTrait::getTextContent protected function Retrieves the plain-text content from the current raw content.
AssertContentTrait::getUrl protected function Get the current URL from the cURL handler. 1
AssertContentTrait::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
AssertContentTrait::removeWhiteSpace protected function Removes all white-space between HTML tags from the raw content.
AssertContentTrait::setDrupalSettings protected function Sets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::setRawContent protected function Sets the raw content (e.g. HTML).
AssertContentTrait::xpath protected function Performs an xpath search on the contents of the internal browser.
AssertHelperTrait::castSafeStrings protected static function Casts MarkupInterface objects into strings.
AssertMailTrait::assertMail protected function Asserts that the most recently sent email message has the given value.
AssertMailTrait::assertMailPattern protected function Asserts that the most recently sent email message has the pattern in it.
AssertMailTrait::assertMailString protected function Asserts that the most recently sent email message has the string in it.
AssertMailTrait::getMails protected function Gets an array containing all emails sent during this test case. Aliased as: drupalGetMails
AssertMailTrait::verboseEmail protected function Outputs to verbose the most recent $count emails sent.
AssertPageCacheContextsAndTagsTrait::assertCacheContext protected function Asserts whether an expected cache context was present in the last response.
AssertPageCacheContextsAndTagsTrait::assertCacheContexts protected function Ensures that some cache contexts are present in the current response.
AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge protected function Asserts the max age header.
AssertPageCacheContextsAndTagsTrait::assertCacheTags protected function Ensures that some cache tags are present in the current response.
AssertPageCacheContextsAndTagsTrait::assertNoCacheContext protected function Asserts that a cache context was not present in the last response.
AssertPageCacheContextsAndTagsTrait::assertPageCacheContextsAndTags protected function Asserts page cache miss, then hit for the given URL; checks cache headers.
AssertPageCacheContextsAndTagsTrait::debugCacheTags protected function Provides debug information for cache tags.
AssertPageCacheContextsAndTagsTrait::enablePageCaching protected function Enables page caching.
AssertPageCacheContextsAndTagsTrait::getCacheHeaderValues protected function Gets a specific header value as array.
BlockCreationTrait::placeBlock protected function Creates a block instance based on default settings. Aliased as: drupalPlaceBlock
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
ContentTypeCreationTrait::createContentType protected function Creates a custom content type based on default settings. Aliased as: drupalCreateContentType 1
CronRunTrait::cronRun protected function Runs cron on the test site.
EntityViewTrait::buildEntityView protected function Builds the renderable view of an entity. Aliased as: drupalBuildEntityView
FunctionalTestSetupTrait::$apcuEnsureUniquePrefix protected property The flag to set 'apcu_ensure_unique_prefix' setting. 1
FunctionalTestSetupTrait::$classLoader protected property The class loader to use for installation and initialization of setup.
FunctionalTestSetupTrait::$configDirectories Deprecated protected property The config directories used in this test.
FunctionalTestSetupTrait::$rootUser protected property The "#1" admin user.
FunctionalTestSetupTrait::doInstall protected function Execute the non-interactive installer. 1
FunctionalTestSetupTrait::getDatabaseTypes protected function Returns all supported database driver installer objects.
FunctionalTestSetupTrait::initConfig protected function Initialize various configurations post-installation. 2
FunctionalTestSetupTrait::initKernel protected function Initializes the kernel after installation.
FunctionalTestSetupTrait::initSettings protected function Initialize settings created during install.
FunctionalTestSetupTrait::initUserSession protected function Initializes user 1 for the site to be installed.
FunctionalTestSetupTrait::installDefaultThemeFromClassProperty protected function Installs the default theme defined by `static::$defaultTheme` when needed.
FunctionalTestSetupTrait::installModulesFromClassProperty protected function Install modules defined by `static::$modules`. 1
FunctionalTestSetupTrait::installParameters protected function Returns the parameters that will be used when Simpletest installs Drupal. 9
FunctionalTestSetupTrait::prepareEnvironment protected function Prepares the current environment for running the test. 23
FunctionalTestSetupTrait::prepareRequestForGenerator protected function Creates a mock request and sets it on the generator.
FunctionalTestSetupTrait::prepareSettings protected function Prepares site settings and services before installation. 2
FunctionalTestSetupTrait::rebuildAll protected function Resets and rebuilds the environment after setup.
FunctionalTestSetupTrait::rebuildContainer protected function Rebuilds \Drupal::getContainer().
FunctionalTestSetupTrait::resetAll protected function Resets all data structures after having enabled new modules.
FunctionalTestSetupTrait::setContainerParameter protected function Changes parameters in the services.yml file.
FunctionalTestSetupTrait::setupBaseUrl protected function Sets up the base URL based upon the environment variable.
FunctionalTestSetupTrait::writeSettings protected function Rewrites the settings.php file of the test site.
GeneratePermutationsTrait::generatePermutations public static function Converts a list of possible parameters into a stack of permutations.
NodeCreationTrait::createNode protected function Creates a node based on default settings. Aliased as: drupalCreateNode
NodeCreationTrait::getNodeByTitle public function Get a node from the database based on its title. Aliased as: drupalGetNodeByTitle
RandomGeneratorTrait::$randomGenerator protected property The random generator.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers. 1
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RandomGeneratorTrait::randomStringValidate public function Callback for random string validation.
RefreshVariablesTrait::refreshVariables protected function Refreshes in-memory configuration and state information. 3
SessionTestTrait::$sessionName protected property The name of the session cookie.
SessionTestTrait::generateSessionName protected function Generates a session cookie name.
SessionTestTrait::getSessionName protected function Returns the session name in use on the child site.
SimplenewsAdministrationTest::$modules public static property Modules to enable. Overrides SimplenewsTestBase::$modules
SimplenewsAdministrationTest::getNewsletterFieldId function Implement getNewsletterFieldId($newsletter_id)
SimplenewsAdministrationTest::setUp public function Sets up a Drupal site for running functional and integration tests. Overrides SimplenewsTestBase::setUp
SimplenewsAdministrationTest::testAccess function Test access for subscriber admin page.
SimplenewsAdministrationTest::testContentTypes function Test content type configuration.
SimplenewsAdministrationTest::testNewsletterIssuesOverview function Test newsletter issue overview.
SimplenewsAdministrationTest::testNewsletterSettings function Test various combinations of newsletter settings.
SimplenewsAdministrationTest::testSubscriberStatusFilter function Test content subscription status filter in subscriber view.
SimplenewsAdministrationTest::testSubscriptionManagement function Test newsletter subscription management.
SimplenewsTestBase::$config protected property The Simplenews settings config object.
SimplenewsTestBase::addField protected function Creates and saves a field storage and instance.
SimplenewsTestBase::assertMailText protected function Checks if a string is found in the latest sent mail.
SimplenewsTestBase::getLatestSubscriber protected function Returns the last created Subscriber.
SimplenewsTestBase::getMail protected function Returns the body content of mail that has been sent.
SimplenewsTestBase::getRandomNewsletter function Select randomly one of the available newsletters.
SimplenewsTestBase::randomEmail function Generates a random email address.
SimplenewsTestBase::registerUser protected function Visits and submits the user registration form.
SimplenewsTestBase::resetPassLogin protected function Login a user, resetting their password.
SimplenewsTestBase::setUpSubscribers function
SimplenewsTestBase::setupSubscriptionBlock function Enable newsletter subscription block.
SimplenewsTestBase::subscribe protected function Visits and submits a newsletter management form.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
TestBase::$assertions protected property Assertions thrown in that test case.
TestBase::$configImporter protected property The config importer that can used in a test.
TestBase::$databasePrefix protected property The database prefix of this test run.
TestBase::$dieOnFail public property Whether to die in case any test assertion fails.
TestBase::$httpAuthCredentials protected property HTTP authentication credentials (<username>:<password>).
TestBase::$httpAuthMethod protected property HTTP authentication method (specified as a CURLAUTH_* constant).
TestBase::$originalConf protected property The original configuration (variables), if available.
TestBase::$originalConfig protected property The original configuration (variables).
TestBase::$originalConfigDirectories protected property The original configuration directories.
TestBase::$originalContainer protected property The original container.
TestBase::$originalFileDirectory protected property The original file directory, before it was changed for testing purposes.
TestBase::$originalLanguage protected property The original language.
TestBase::$originalPrefix protected property The original database prefix when running inside Simpletest.
TestBase::$originalSessionName protected property The name of the session cookie of the test-runner.
TestBase::$originalSettings protected property The settings array.
TestBase::$results public property Current results of this test case.
TestBase::$skipClasses protected property This class is skipped when looking for the source of an assertion.
TestBase::$timeLimit protected property Time limit for the test.
TestBase::$translationFilesDirectory protected property The translation file directory for the test environment.
TestBase::$verbose public property TRUE if verbose debugging is enabled.
TestBase::$verboseClassName protected property Safe class name for use in verbose output filenames.
TestBase::$verboseDirectory protected property Directory where verbose output files are put.
TestBase::$verboseDirectoryUrl protected property URL to the verbose output file directory.
TestBase::$verboseId protected property Incrementing identifier for verbose output filenames.
TestBase::assert protected function Internal helper: stores the assert.
TestBase::assertEqual protected function Check to see if two values are equal.
TestBase::assertErrorLogged protected function Asserts that a specific error has been logged to the PHP error log.
TestBase::assertFalse protected function Check to see if a value is false.
TestBase::assertIdentical protected function Check to see if two values are identical.
TestBase::assertIdenticalObject protected function Checks to see if two objects are identical.
TestBase::assertNoErrorsLogged protected function Asserts that no errors have been logged to the PHP error.log thus far.
TestBase::assertNotEqual protected function Check to see if two values are not equal.
TestBase::assertNotIdentical protected function Check to see if two values are not identical.
TestBase::assertNotNull protected function Check to see if a value is not NULL.
TestBase::assertNull protected function Check to see if a value is NULL.
TestBase::assertTrue protected function Check to see if a value is not false.
TestBase::beforePrepareEnvironment protected function Act on global state information before the environment is altered for a test. 1
TestBase::checkRequirements protected function Checks the matching requirements for Test. 1
TestBase::checkTestHierarchyMismatch public function Fail the test if it belongs to a PHPUnit-based framework.
TestBase::config protected function Configuration accessor for tests. Returns non-overridden configuration.
TestBase::deleteAssert public static function Delete an assertion record by message ID.
TestBase::error protected function Fire an error assertion. 1
TestBase::errorHandler public function Handle errors during test runs.
TestBase::exceptionHandler protected function Handle exceptions.
TestBase::fail protected function Fire an assertion that is always negative.
TestBase::filePreDeleteCallback public static function Ensures test files are deletable.
TestBase::getAssertionCall protected function Cycles through backtrace until the first non-assertion method is found.
TestBase::getDatabasePrefix public function Gets the database prefix.
TestBase::getTempFilesDirectory public function Gets the temporary files directory.
TestBase::insertAssert Deprecated public static function Store an assertion from outside the testing context. 1
TestBase::pass protected function Fire an assertion that is always positive.
TestBase::prepareDatabasePrefix private function Generates a database prefix for running tests. Overrides TestSetupTrait::prepareDatabasePrefix
TestBase::restoreEnvironment private function Cleans up the test environment and restores the original environment.
TestBase::run public function Run all tests in this class. 2
TestBase::settingsSet protected function Changes in memory settings.
TestBase::storeAssertion protected function Helper method to store an assertion record in the configured database. 1
TestBase::verbose protected function Logs a verbose message in a text file.
TestFileCreationTrait::$generatedTestFiles protected property Whether the files were copied to the test files directory.
TestFileCreationTrait::compareFiles protected function Compares two files based on size and file name. Aliased as: drupalCompareFiles
TestFileCreationTrait::generateFile public static function Generates a test file.
TestFileCreationTrait::getTestFiles protected function Gets a list of files that can be used in tests. Aliased as: drupalGetTestFiles
TestSetupTrait::$configSchemaCheckerExclusions protected static property An array of config object names that are excluded from schema checking.
TestSetupTrait::$container protected property The dependency injection container used in the test.
TestSetupTrait::$kernel protected property The DrupalKernel instance used in the test.
TestSetupTrait::$originalSite protected property The site directory of the original parent site.
TestSetupTrait::$privateFilesDirectory protected property The private file directory for the test environment.
TestSetupTrait::$publicFilesDirectory protected property The public file directory for the test environment.
TestSetupTrait::$siteDirectory protected property The site directory of this test run.
TestSetupTrait::$strictConfigSchema protected property Set to TRUE to strict check all configuration saved. 2
TestSetupTrait::$tempFilesDirectory protected property The temporary file directory for the test environment.
TestSetupTrait::$testId protected property The test run ID.
TestSetupTrait::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
TestSetupTrait::getConfigSchemaExclusions protected function Gets the config schema exclusions for this test.
TestSetupTrait::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
UserCreationTrait::checkPermissions protected function Checks whether a given list of permission names is valid.
UserCreationTrait::createAdminRole protected function Creates an administrative role. Aliased as: drupalCreateAdminRole
UserCreationTrait::createRole protected function Creates a role with specified permissions. Aliased as: drupalCreateRole
UserCreationTrait::createUser protected function Create a user with a given set of permissions. Aliased as: drupalCreateUser
UserCreationTrait::grantPermissions protected function Grant permissions to a user role.
UserCreationTrait::setCurrentUser protected function Switch the current logged in user.
UserCreationTrait::setUpCurrentUser protected function Creates a random user account and sets it as current user.
WebTestBase::$additionalCurlOptions protected property Additional cURL options.
WebTestBase::$assertAjaxHeader protected property Whether or not to assert the presence of the X-Drupal-Ajax-Token.
WebTestBase::$cookieFile protected property The current cookie file used by cURL.
WebTestBase::$cookies protected property The cookies of the page currently loaded in the internal browser.
WebTestBase::$curlCookies protected property Cookies to set on curl requests.
WebTestBase::$curlHandle protected property The handle of the current cURL connection.
WebTestBase::$customTranslations protected property An array of custom translations suitable for drupal_rewrite_settings().
WebTestBase::$dumpHeaders protected property Indicates that headers should be dumped if verbose output is enabled. 1
WebTestBase::$headers protected property The headers of the page currently loaded in the internal browser.
WebTestBase::$loggedInUser protected property The current user logged in using the internal browser.
WebTestBase::$maximumMetaRefreshCount protected property The number of meta refresh redirects to follow, or NULL if unlimited.
WebTestBase::$maximumRedirects protected property The maximum number of redirects to follow when handling responses.
WebTestBase::$metaRefreshCount protected property The number of meta refresh redirects followed during ::drupalGet().
WebTestBase::$originalBatch protected property The original batch, before it was changed for testing purposes.
WebTestBase::$originalShutdownCallbacks protected property The original shutdown handlers array, before it was cleaned for testing. Overrides TestBase::$originalShutdownCallbacks
WebTestBase::$originalUser protected property The original user, before it was changed to a clean uid = 1 for testing. Overrides TestBase::$originalUser
WebTestBase::$profile protected property The profile to install as a basis for testing. 2
WebTestBase::$redirectCount protected property The number of redirects followed during the handling of a request.
WebTestBase::$sessionId protected property The current session ID, if available.
WebTestBase::$url protected property The URL currently loaded in the internal browser.
WebTestBase::addCustomTranslations protected function Queues custom translations to be written to settings.php.
WebTestBase::assertBlockAppears protected function Checks to see whether a block appears on the page.
WebTestBase::assertCacheTag protected function Asserts whether an expected cache tag was present in the last response.
WebTestBase::assertHeader protected function Check if a HTTP response header exists and has the expected value.
WebTestBase::assertNoBlockAppears protected function Checks to see whether a block does not appears on the page.
WebTestBase::assertNoCacheTag protected function Asserts whether an expected cache tag was absent in the last response.
WebTestBase::assertNoResponse protected function Asserts the page did not return the specified response code.
WebTestBase::assertResponse protected function Asserts the page responds with the specified response code. 1
WebTestBase::assertUrl protected function Passes if the internal browser's URL matches the given path.
WebTestBase::buildUrl protected function Builds an a absolute URL from a system path or a URL object.
WebTestBase::checkForMetaRefresh protected function Checks for meta refresh tag and if found call drupalGet() recursively.
WebTestBase::clickLink protected function Follows a link by complete name.
WebTestBase::clickLinkHelper protected function Provides a helper for ::clickLink() and ::clickLinkPartialName().
WebTestBase::clickLinkPartialName protected function Follows a link by partial name.
WebTestBase::curlClose protected function Close the cURL handler and unset the handler.
WebTestBase::curlExec protected function Initializes and executes a cURL request. 1
WebTestBase::curlHeaderCallback protected function Reads headers and registers errors received from the tested site.
WebTestBase::curlInitialize protected function Initializes the cURL connection.
WebTestBase::drupalGet protected function Retrieves a Drupal path or an absolute path. 1
WebTestBase::drupalGetAjax protected function Requests a path or URL in drupal_ajax format and JSON-decodes the response.
WebTestBase::drupalGetHeader protected function Gets the value of an HTTP response header. 1
WebTestBase::drupalGetHeaders protected function Gets the HTTP response headers of the requested page. 1
WebTestBase::drupalGetJSON protected function Retrieves a Drupal path or an absolute path and JSON decodes the result.
WebTestBase::drupalGetWithFormat protected function Retrieves a Drupal path or an absolute path for a given format.
WebTestBase::drupalGetXHR protected function Requests a Drupal path or an absolute path as if it is a XMLHttpRequest.
WebTestBase::drupalHead protected function Retrieves only the headers for a Drupal path or an absolute path.
WebTestBase::drupalLogin protected function Log in a user with the internal browser.
WebTestBase::drupalLogout protected function Logs a user out of the internal browser and confirms.
WebTestBase::drupalPost protected function Perform a POST HTTP request.
WebTestBase::drupalPostAjaxForm protected function Executes an Ajax form submission.
WebTestBase::drupalPostForm protected function Executes a form submission.
WebTestBase::drupalPostWithFormat protected function Performs a POST HTTP request with a specific format.
WebTestBase::drupalProcessAjaxResponse protected function Processes an AJAX response into current content.
WebTestBase::drupalUserIsLoggedIn protected function Returns whether a given user account is logged in.
WebTestBase::findBlockInstance protected function Find a block instance on the page.
WebTestBase::getAbsoluteUrl protected function Takes a path and returns an absolute path.
WebTestBase::getAjaxPageStatePostData protected function Get the Ajax page state from drupalSettings and prepare it for POSTing.
WebTestBase::handleForm protected function Handles form input related to drupalPostForm().
WebTestBase::isInChildSite protected function Returns whether the test is being executed from within a test site.
WebTestBase::restoreBatch protected function Restore the original batch.
WebTestBase::serializePostValues protected function Serialize POST HTTP request values.
WebTestBase::setBatch protected function Preserve the original batch, and instantiate the test batch.
WebTestBase::setHttpResponseDebugCacheabilityHeaders protected function Enables/disables the cacheability headers.
WebTestBase::tearDown protected function Cleans up after testing. Overrides TestBase::tearDown 1
WebTestBase::translatePostValues protected function Transforms a nested array into a flat array suitable for WebTestBase::drupalPostForm().
WebTestBase::writeCustomTranslations protected function Writes custom translations to the test site's settings.php.
WebTestBase::__construct public function Constructor for \Drupal\simpletest\WebTestBase. Overrides TestBase::__construct 1
XdebugRequestTrait::extractCookiesFromRequest protected function Adds xdebug cookies, from request setup.