You are here

public function WebformBlockContextTest::testBlockContext in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Functional/Block/WebformBlockContextTest.php \Drupal\Tests\webform\Functional\Block\WebformBlockContextTest::testBlockContext()

Tests webform block context.

File

tests/src/Functional/Block/WebformBlockContextTest.php, line 59

Class

WebformBlockContextTest
Tests for webform block context.

Namespace

Drupal\Tests\webform\Functional\Block

Code

public function testBlockContext() {
  $this
    ->drupalLogin($this->rootUser);
  $webform = Webform::load('contact');

  // Check webform context.
  $this
    ->drupalGet('/webform/contact');
  $this
    ->assertRaw('{all contexts}');
  $this
    ->assertRaw('{webform context}');

  // Check webform submission context.
  $sid = $this
    ->postSubmissionTest($webform);
  $this
    ->drupalGet("/admin/structure/webform/manage/contact/submission/{$sid}");
  $this
    ->assertRaw('{all contexts}');
  $this
    ->assertRaw('{webform_submission context}');

  // Check webform node context.
  $node = $this
    ->drupalCreateNode([
    'type' => 'webform',
  ]);
  $node->webform->target_id = 'contact';
  $node->webform->status = 1;
  $node
    ->save();
  $this
    ->drupalGet('/node/' . $node
    ->id());
  $this
    ->assertRaw('{all contexts}');
  $this
    ->assertRaw('{node context}');
}