public function WebformBrowserTestBaseTest::testWebformBase in Webform 8.5
Same name and namespace in other branches
- 6.x tests/src/Functional/WebformBrowserTestBaseTest.php \Drupal\Tests\webform\Functional\WebformBrowserTestBaseTest::testWebformBase()
Test base helper methods.
File
- tests/
src/ Functional/ WebformBrowserTestBaseTest.php, line 38
Class
- WebformBrowserTestBaseTest
- Test the webform test base class.
Namespace
Drupal\Tests\webform\FunctionalCode
public function testWebformBase() {
// Check that test webform is installed.
$this
->assertNotNull(Webform::load('test_ajax'));
// Check create webform.
$test_webform = $this
->createWebform();
$this
->assertNotNull($test_webform);
$webform = Webform::load('contact');
// Check post submission return NULL if post fails.
$sid = $this
->postSubmission($webform);
$this
->assertFalse($sid);
// Login root user.
$this
->drupalLogin($this->rootUser);
// Check post test submission returns an sid.
$sid = $this
->postSubmissionTest($webform);
$this
->assertNotNull($sid);
// Check submission load not from cache.
$webform_submission = $this
->loadSubmission($sid);
$this
->assertNotNull($webform_submission);
$this
->assertEquals('contact', $webform_submission
->getWebform()
->id());
// Check submission email.
$last_email = $this
->getLastEmail();
$this
->assertEquals('webform_contact_email_notification', $last_email['id']);
// Check purge submission deletes the submission.
$this
->purgeSubmissions();
$webform_submission = $this
->loadSubmission($sid);
$this
->assertNull($webform_submission);
// Check place blocks.
$this
->placeBlocks();
$this
->drupalGet('/webform/contact');
$this
->assertRaw('<h1>Contact</h1>');
$this
->assertRaw('<h2 id="system-breadcrumb" class="visually-hidden">Breadcrumb</h2>');
$this
->assertRaw('<h2 class="visually-hidden">Primary tabs</h2>');
}