You are here

public function MessageSubscribeEmailTest::setUp in Message Subscribe 8

Overrides BrowserTestBase::setUp

File

message_subscribe_email/tests/src/FunctionalJavascript/MessageSubscribeEmailTest.php, line 43

Class

MessageSubscribeEmailTest
Javascript tests for message subscribe email.

Namespace

Drupal\Tests\message_subscribe_email\FunctionalJavascript

Code

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

  // Add some nodes.
  $type = $this
    ->createContentType();
  foreach (range(1, 3) as $i) {
    $this->nodes[$i] = $this
      ->drupalCreateNode([
      'type' => $type
        ->id(),
    ]);
  }

  // Add some users.
  $permissions = [
    'flag subscribe_node',
    'unflag subscribe_node',
    'flag email_node',
    'unflag email_node',
  ];
  $this->users[1] = $this
    ->createUser($permissions);
  $this->users[2] = $this
    ->createUser($permissions);
  $this->users[3] = $this
    ->createUser($permissions);
  $this->flagService = $this->container
    ->get('flag');

  // Enable node flags.
  $flags = $this->flagService
    ->getAllFlags('node');
  $flags['subscribe_node']
    ->enable();
  $flags['subscribe_node']
    ->save();
  $flags['email_node']
    ->enable();
  $flags['email_node']
    ->save();
}