SmtpTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @category Zend
  4. * @package Zend_Mail
  5. * @subpackage UnitTests
  6. */
  7. /**
  8. * Zend_Mail_Protocol_Smtp
  9. */
  10. require_once 'Zend/Mail/Protocol/Smtp.php';
  11. /**
  12. * Zend_Mail_Transport_Smtp
  13. */
  14. require_once 'Zend/Mail/Transport/Smtp.php';
  15. /**
  16. * PHPUnit test case
  17. */
  18. require_once 'PHPUnit/Framework/TestCase.php';
  19. /**
  20. * @category Zend
  21. * @package Zend_Mail
  22. * @subpackage UnitTests
  23. */
  24. class Zend_Mail_SmtpTest extends PHPUnit_Framework_TestCase
  25. {
  26. protected $_params;
  27. protected $_transport;
  28. protected $_connection;
  29. public function setUp()
  30. {
  31. $this->_params = array('host' => TESTS_ZEND_MAIL_SMTP_HOST,
  32. 'port' => TESTS_ZEND_MAIL_SMTP_PORT,
  33. 'username' => TESTS_ZEND_MAIL_SMTP_USER,
  34. 'password' => TESTS_ZEND_MAIL_SMTP_PASSWORD,
  35. 'auth' => TESTS_ZEND_MAIL_SMTP_AUTH);
  36. }
  37. public function testTransportSetup()
  38. {
  39. try {
  40. $this->_transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params);
  41. } catch (Exception $e) {
  42. $this->fail('exception raised while creating smtp transport');
  43. }
  44. try {
  45. $this->_connection = new Zend_Mail_Protocol_Smtp($this->_params['host'], $this->_params['port']);
  46. $this->_transport->setConnection($this->_connection);
  47. } catch (Exception $e) {
  48. $this->fail('exception raised while setting smtp transport connection');
  49. }
  50. $this->_connection = $this->_transport->getConnection();
  51. if (!($this->_connection instanceof Zend_Mail_Protocol_Abstract)) {
  52. $this->fail('smtp transport connection is not an instance of protocol abstract');
  53. }
  54. }
  55. }