X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fblock%2Ftests%2Fsrc%2FFunctional%2FBlockFormInBlockTest.php;fp=web%2Fcore%2Fmodules%2Fblock%2Ftests%2Fsrc%2FFunctional%2FBlockFormInBlockTest.php;h=c0e7f589267ef567b68c8456b0734ad2e48d9041;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php b/web/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php new file mode 100644 index 000000000..c0e7f5892 --- /dev/null +++ b/web/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php @@ -0,0 +1,72 @@ +drupalPlaceBlock('test_form_in_block'); + } + + /** + * Test to see if form in block's redirect isn't cached. + */ + 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->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'])); + } + + /** + * Test the actual placeholders + */ + 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.'); + } + +}