public function SimplenewsSubscribeTest::testSimplenewsSubscriptionBlock in Simplenews 8.2
Same name and namespace in other branches
- 3.x tests/src/Functional/SimplenewsSubscribeTest.php \Drupal\Tests\simplenews\Functional\SimplenewsSubscribeTest::testSimplenewsSubscriptionBlock()
Tests Creation of Simplenews Subscription block.
File
- tests/
src/ Functional/ SimplenewsSubscribeTest.php, line 898
Class
- SimplenewsSubscribeTest
- Un/subscription of anonymous and authenticated users.
Namespace
Drupal\Tests\simplenews\FunctionalCode
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
->drupalPostForm(NULL, $edit, t('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.');
}