- <?php
- * @file
- * Simpletest case for email_example module.
- *
- * Verify example module functionality.
- */
-
- * Functionality tests for email example module.
- *
- * @ingroup email_example
- */
- class EmailExampleTestCase extends BackdropWebTestCase {
-
-
- * {@inheritdoc}
- */
- public function setUp() {
-
- parent::setUp('email_example');
- }
-
-
- * Verify the functionality of the example module.
- */
- public function testContactForm() {
-
- $account = $this->backdropCreateUser();
- $this->backdropLogin($account);
-
-
- $t_options = array(
- 'langcode' => language_default()->langcode,
- );
-
-
- $email_options = array(
- 'email' => $this->randomName(),
- 'message' => $this->randomName(128),
- );
- $result = $this->backdropPost('example/email_example', $email_options, t('Submit'));
-
-
- $this->assertText(t('That e-mail address is not valid.'), 'Options were validated and form submitted.');
- $this->assertTrue(!count($this->backdropGetMails()), 'No email was sent.');
-
-
- $email_options['email'] = $this->randomName() . '@' . $this->randomName() . '.backdrop';
- $result = $this->backdropPost('example/email_example', $email_options, t('Submit'));
-
-
- $this->assertTrue(count($this->backdropGetMails()), 'An email has been sent.');
-
-
- $email = $this->backdropGetMails();
-
- $email = $email[0];
-
-
- $this->assertEqual(
- $email['to'],
- $email_options['email'],
- 'Email recipient successfully verified.'
- );
-
-
- $this->assertEqual(
- $email['subject'],
- t('E-mail sent from @site-name', array('@site-name' => config_get('system.core', 'site_name')), $t_options),
- 'Email subject successfully verified.'
- );
-
-
- $this->assertTrue(
- strstr(
- $email['body'],
- t('@name sent you the following message:', array('@name' => $account->name), $t_options)
- ),
- 'Email body successfully verified.'
- );
-
-
- $this->assertTrue(
- strstr(
- $email['body'],
- t("--\nMail altered by email_example module.", array(), $t_options)
- ),
- 'Email signature successfully verified.'
- );
- }
- }