BlockFormInBlockTest.php in Drupal 8
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 {
public static $modules = [
'block',
'block_test',
'test_page_test',
];
protected $defaultTheme = 'classy';
protected function setUp() {
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
->assertText('Your .com email address.', 'form found');
$this
->drupalPostForm(NULL, $form_values, t('Submit'));
$this
->assertUrl('test-page');
$this
->assertText(t('Your email address is @email', [
'@email' => 'test@example.com',
]));
$this
->drupalGet('test-render-title');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertText('Your .com email address.', 'form found');
$this
->drupalPostForm(NULL, $form_values, t('Submit'));
$this
->assertUrl('test-render-title');
$this
->assertText(t('Your email address is @email', [
'@email' => 'test@example.com',
]));
}
public function testPlaceholders() {
$this
->drupalGet('test-multiple-forms');
$placeholder = 'form_action_' . Crypt::hashBase64('Drupal\\Core\\Form\\FormBuilder::prepareForm');
$this
->assertText('Form action: ' . $placeholder, 'placeholder found.');
}
}