public function BlockFormInBlockTest::testCachePerPage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/block/tests/src/Functional/BlockFormInBlockTest.php \Drupal\Tests\block\Functional\BlockFormInBlockTest::testCachePerPage()
Tests to see if form in block's redirect isn't cached.
File
- core/
modules/ block/ tests/ src/ Functional/ BlockFormInBlockTest.php, line 40
Class
- BlockFormInBlockTest
- Tests form in block caching.
Namespace
Drupal\Tests\block\FunctionalCode
public function testCachePerPage() {
$form_values = [
'email' => 'test@example.com',
];
// Go to "test-page" and test if the block is enabled.
$this
->drupalGet('test-page');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('Your .com email address.');
// Make sure that we're currently still on /test-page after submitting the
// form.
$this
->submitForm($form_values, 'Submit');
$this
->assertSession()
->addressEquals('test-page');
$this
->assertSession()
->pageTextContains('Your email address is test@example.com');
// Go to a different page and see if the block is enabled there as well.
$this
->drupalGet('test-render-title');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('Your .com email address.');
// 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
->submitForm($form_values, 'Submit');
$this
->assertSession()
->addressEquals('test-render-title');
$this
->assertSession()
->pageTextContains('Your email address is test@example.com');
}