devel.test 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * @file
  4. * Tests for devel module.
  5. */
  6. /**
  7. * Test devel mail functionality.
  8. */
  9. class DevelMailTest extends DrupalWebTestCase {
  10. protected $profile = 'testing';
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public static function getInfo() {
  15. return array(
  16. 'name' => 'Devel Mail interface',
  17. 'description' => 'Test sending mails with debug interface',
  18. 'group' => 'Devel',
  19. );
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. function setUp() {
  25. parent::setUp();
  26. }
  27. /**
  28. * Test mail logging functionality.
  29. */
  30. function testMail() {
  31. require_once ('devel.mail.inc');
  32. $message = array();
  33. $message['to'] = 'drupal@example.com';
  34. $message['subject'] = 'Test mail';
  35. $message['headers'] = array(
  36. 'From' => 'postmaster@example.com',
  37. 'X-stupid' => 'dumb',
  38. );
  39. $message['body'] = "I am the body of this message";
  40. $d = new DevelMailLog();
  41. $filename = $d->getFileName($message);
  42. $content = $d->composeMessage($message);
  43. $expected_filename = $d->getOutputDirectory() . '/drupal@example.com-Test_mail-' . date('y-m-d_his') . '.mail.txt';
  44. $this->assertEqual($filename, $expected_filename);
  45. $this->assertEqual($content, 'From: postmaster@example.com
  46. X-stupid: dumb
  47. To: drupal@example.com
  48. Subject: Test mail
  49. I am the body of this message');
  50. }
  51. }