BlockFormInBlockTest.php in Drupal 9
File
core/modules/block/tests/src/Functional/BlockFormInBlockTest.php
View source
<?php
namespace Drupal\Tests\block\Functional;
use Drupal\Component\Utility\Crypt;
use Drupal\Tests\BrowserTestBase;
class BlockFormInBlockTest extends BrowserTestBase {
protected static $modules = [
'block',
'block_test',
'test_page_test',
];
protected $defaultTheme = 'classy';
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('test_form_in_block');
}
public function testCachePerPage() {
$form_values = [
'email' => 'test@example.com',
];
$this
->drupalGet('test-page');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('Your .com email address.');
$this
->submitForm($form_values, 'Submit');
$this
->assertSession()
->addressEquals('test-page');
$this
->assertSession()
->pageTextContains('Your email address is test@example.com');
$this
->drupalGet('test-render-title');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('Your .com email address.');
$this
->submitForm($form_values, 'Submit');
$this
->assertSession()
->addressEquals('test-render-title');
$this
->assertSession()
->pageTextContains('Your email address is test@example.com');
}
public function testPlaceholders() {
$this
->drupalGet('test-multiple-forms');
$placeholder = 'form_action_' . Crypt::hashBase64('Drupal\\Core\\Form\\FormBuilder::prepareForm');
$this
->assertSession()
->pageTextContains('Form action: ' . $placeholder);
}
}