You are here

public function SimplenewsSubscribeTest::testSimplenewsSubscriptionBlock in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/SimplenewsSubscribeTest.php \Drupal\Tests\simplenews\Functional\SimplenewsSubscribeTest::testSimplenewsSubscriptionBlock()

Tests Creation of Simplenews Subscription block.

File

tests/src/Functional/SimplenewsSubscribeTest.php, line 625

Class

SimplenewsSubscribeTest
Un/subscription of anonymous and authenticated users.

Namespace

Drupal\Tests\simplenews\Functional

Code

public function testSimplenewsSubscriptionBlock() {
  $admin_user = $this
    ->drupalCreateUser([
    'administer blocks',
  ]);
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalGet('/admin/structure/block/add/simplenews_subscription_block/classy');

  // Check for Unique ID field.
  $this
    ->assertText('Unique ID');
  $edit = [
    'settings[unique_id]' => 'test_simplenews_123',
    'settings[newsletters][default]' => TRUE,
    'region' => 'header',
  ];
  $this
    ->submitForm($edit, 'Save block');
  $this
    ->drupalGet('');

  // Provided Unique ID is used as form_id.
  $this
    ->assertFieldByXPath("//*[@id=\"simplenews-subscriptions-block-test-simplenews-123\"]", NULL, 'Form ID found and contains expected value.');
}