You are here

function SimplenewsSourceTest::setUp in Simplenews 8

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides SimplenewsTestBase::setUp

File

src/Tests/SimplenewsSourceTest.php, line 26
Simplenews source test functions.

Class

SimplenewsSourceTest
Test cases for creating and sending newsletters.

Namespace

Drupal\simplenews\Tests

Code

function setUp() {
  parent::setUp();

  // Create the filtered_html text format.
  $filtered_html_format = \Drupal::entityTypeManager()
    ->getStorage('filter_format')
    ->create(array(
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'weight' => 0,
    'filters' => array(
      // URL filter.
      'filter_url' => array(
        'weight' => 0,
        'status' => 1,
      ),
      // HTML filter.
      'filter_html' => array(
        'weight' => 1,
        'status' => 1,
        'allowed-values',
      ),
      // Line break filter.
      'filter_autop' => array(
        'weight' => 2,
        'status' => 1,
      ),
      // HTML corrector filter.
      'filter_htmlcorrector' => array(
        'weight' => 10,
        'status' => 1,
      ),
    ),
  ));
  $filtered_html_format
    ->save();
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer newsletters',
    'send newsletter',
    'administer nodes',
    'administer simplenews subscriptions',
    'create simplenews_issue content',
    'edit any simplenews_issue content',
    'view own unpublished content',
    'delete any simplenews_issue content',
    'administer simplenews settings',
    $filtered_html_format
      ->getPermissionName(),
  ));
  $this
    ->drupalLogin($admin_user);
}