devel.test 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. public static function getInfo() {
  12. return array(
  13. 'name' => 'Devel Mail interface',
  14. 'description' => 'Test sending mails with debug interface',
  15. 'group' => 'Devel',
  16. );
  17. }
  18. function setUp() {
  19. parent::setUp();
  20. }
  21. /**
  22. * Test mail logging functionality.
  23. */
  24. function testMail() {
  25. require_once ('devel.mail.inc');
  26. $message = array();
  27. $message['to'] = 'drupal@example.com';
  28. $message['subject'] = 'Test mail';
  29. $message['headers'] = array(
  30. 'From' => 'postmaster@example.com',
  31. 'X-stupid' => 'dumb',
  32. );
  33. $message['body'] = "I am the body of this message";
  34. $d = new DevelMailLog();
  35. $filename = $d->getFileName($message);
  36. $content = $d->composeMessage($message);
  37. $expected_filename = $d->getOutputDirectory() . '/drupal@example.com-Test_mail-' . date('y-m-d_his') . '.mail.txt';
  38. $this->assertEqual($filename, $expected_filename);
  39. $this->assertEqual($content, 'From: postmaster@example.com
  40. X-stupid: dumb
  41. To: drupal@example.com
  42. Test mail
  43. I am the body of this message');
  44. }
  45. }