You are here

function BlockFormInBlockTest::testCachePerPage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block/src/Tests/BlockFormInBlockTest.php \Drupal\block\Tests\BlockFormInBlockTest::testCachePerPage()

Test to see if form in block's redirect isn't cached.

File

core/modules/block/src/Tests/BlockFormInBlockTest.php, line 39
Contains \Drupal\block\Tests\BlockFormInBlockTest.

Class

BlockFormInBlockTest
Tests form in block caching.

Namespace

Drupal\block\Tests

Code

function testCachePerPage() {
  $form_values = [
    'email' => 'test@example.com',
  ];

  // Go to "test-page" and test if the block is enabled.
  $this
    ->drupalGet('test-page');
  $this
    ->assertResponse(200);
  $this
    ->assertText('Your .com email address.', 'form found');

  // Make sure that we're currently still on /test-page after submitting the
  // form.
  $this
    ->drupalPostForm(NULL, $form_values, t('Submit'));
  $this
    ->assertUrl('test-page');
  $this
    ->assertText(t('Your email address is @email', [
    '@email' => 'test@example.com',
  ]));

  // Go to a different page and see if the block is enabled there as well.
  $this
    ->drupalGet('test-render-title');
  $this
    ->assertResponse(200);
  $this
    ->assertText('Your .com email address.', 'form found');

  // Make sure that submitting the form didn't redirect us to the first page
  // we submitted the form from after submitting the form from
  // /test-render-title.
  $this
    ->drupalPostForm(NULL, $form_values, t('Submit'));
  $this
    ->assertUrl('test-render-title');
  $this
    ->assertText(t('Your email address is @email', [
    '@email' => 'test@example.com',
  ]));
}