You are here

public function EasyEmailTemplateCreateTest::testCreateDefaultsTemplate in Easy Email 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/EasyEmailTemplateCreateTest.php \Drupal\Tests\easy_email\Functional\EasyEmailTemplateCreateTest::testCreateDefaultsTemplate()

Tests template create/edit form with default fields

Throws

\Behat\Mink\Exception\ExpectationException

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Functional/EasyEmailTemplateCreateTest.php, line 21

Class

EasyEmailTemplateCreateTest
Class EasyEmailTemplateCreateTest

Namespace

Drupal\Tests\easy_email\Functional

Code

public function testCreateDefaultsTemplate() {
  $template = $this
    ->createTemplate([
    'id' => 'test_defaults',
    'label' => 'Test: Defaults',
  ]);
  $this
    ->drupalGet('admin/structure/email-templates/templates');
  $this
    ->assertSession()
    ->pageTextContains('test_defaults');
  $this
    ->assertSession()
    ->pageTextContains('Test: Defaults');
  $this
    ->drupalGet('admin/structure/email-templates/templates/' . $template
    ->id() . '/edit');
  $this
    ->assertSession()
    ->fieldValueEquals('Label', 'Test: Defaults');
  $this
    ->assertSession()
    ->fieldValueEquals('Unique Key Pattern', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('Unique Key Pattern', '[easy_email:recipient_address:0:value]:test_defaults');
  $this
    ->assertSession()
    ->fieldValueEquals('recipient', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('To', 'recipient@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-cc', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('edit-cc', 'cc@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-bcc', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('edit-bcc', 'bcc@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('From Name', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('From Name', 'Testing Easy Email');
  $this
    ->assertSession()
    ->fieldValueEquals('From Address', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('From Address', 'from@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('Reply To Address', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('Reply To Address', 'replyto@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('Subject', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('Subject', 'This is the subject');
  $this
    ->assertSession()
    ->elementExists('css', 'details[data-drupal-selector="edit-body-html"]');
  $this
    ->assertSession()
    ->fieldValueEquals('HTML Body', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('HTML Body', '<p>This is the HTML body.</p>');
  $this
    ->assertSession()
    ->fieldValueEquals('Inbox Preview', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('Inbox Preview', 'This is the inbox preview.');
  $this
    ->assertSession()
    ->elementExists('css', 'details[data-drupal-selector="edit-body-plain"]');
  $this
    ->assertSession()
    ->fieldValueEquals('Plain Text Body', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('Plain Text Body', 'This is the plain text body.');
  $this
    ->assertSession()
    ->fieldValueEquals('generateBodyPlain', FALSE);
  $this
    ->assertSession()
    ->fieldValueEquals('Dynamic Attachments', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('Dynamic Attachments', 'web/core/misc/drupalicon.png');
  $this
    ->assertSession()
    ->fieldValueEquals('saveAttachment', FALSE);
  $this
    ->assertSession()
    ->fieldValueEquals('attachmentScheme', 'private');
  $this
    ->assertSession()
    ->fieldValueEquals('File Directory', '');
  $this
    ->getSession()
    ->getPage()
    ->fillField('File Directory', 'email-attachments');
  $this
    ->assertSession()
    ->linkExists('Browse available tokens.');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Save');
  $this
    ->assertSession()
    ->pageTextContains('Saved the Test: Defaults Email type');
  $this
    ->drupalGet('admin/structure/email-templates/templates/' . $template
    ->id() . '/edit');
  $this
    ->assertSession()
    ->fieldValueEquals('Label', 'Test: Defaults');
  $this
    ->assertSession()
    ->fieldValueEquals('Unique Key Pattern', '[easy_email:recipient_address:0:value]:test_defaults');
  $this
    ->assertSession()
    ->fieldValueEquals('To', 'recipient@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-cc', 'cc@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-bcc', 'bcc@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('From Name', 'Testing Easy Email');
  $this
    ->assertSession()
    ->fieldValueEquals('From Address', 'from@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('Reply To Address', 'replyto@example.com');
  $this
    ->assertSession()
    ->fieldValueEquals('Subject', 'This is the subject');
  $this
    ->assertSession()
    ->fieldValueEquals('HTML Body', '<p>This is the HTML body.</p>');
  $this
    ->assertSession()
    ->fieldValueEquals('Inbox Preview', 'This is the inbox preview.');
  $this
    ->assertSession()
    ->fieldValueEquals('Plain Text Body', 'This is the plain text body.');
  $this
    ->assertSession()
    ->fieldValueEquals('generateBodyPlain', FALSE);
  $this
    ->assertSession()
    ->fieldValueEquals('Dynamic Attachments', 'web/core/misc/drupalicon.png');
  $this
    ->assertSession()
    ->fieldValueEquals('saveAttachment', FALSE);
  $this
    ->assertSession()
    ->fieldValueEquals('attachmentScheme', 'private');
  $this
    ->assertSession()
    ->fieldValueEquals('File Directory', 'email-attachments');
  $this
    ->assertSession()
    ->linkExists('Browse available tokens.');
}