SmtpTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Mail
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Zend_Mail_Protocol_Smtp
  24. */
  25. require_once 'Zend/Mail/Protocol/Smtp.php';
  26. /**
  27. * Zend_Mail_Transport_Smtp
  28. */
  29. require_once 'Zend/Mail/Transport/Smtp.php';
  30. /**
  31. * PHPUnit test case
  32. */
  33. require_once 'PHPUnit/Framework/TestCase.php';
  34. /**
  35. * Test helper for configuration when run standalone
  36. */
  37. require_once dirname(__FILE__).'/../../TestHelper.php';
  38. /**
  39. * @category Zend
  40. * @package Zend_Mail
  41. * @subpackage UnitTests
  42. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  43. * @license http://framework.zend.com/license/new-bsd New BSD License
  44. * @group Zend_Mail
  45. */
  46. class Zend_Mail_SmtpTest extends PHPUnit_Framework_TestCase
  47. {
  48. protected $_params;
  49. protected $_transport;
  50. protected $_connection;
  51. public function setUp()
  52. {
  53. $this->_params = array('host' => TESTS_ZEND_MAIL_SMTP_HOST,
  54. 'port' => TESTS_ZEND_MAIL_SMTP_PORT,
  55. 'username' => TESTS_ZEND_MAIL_SMTP_USER,
  56. 'password' => TESTS_ZEND_MAIL_SMTP_PASSWORD,
  57. 'auth' => TESTS_ZEND_MAIL_SMTP_AUTH);
  58. }
  59. public function testTransportSetup()
  60. {
  61. try {
  62. $this->_transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params);
  63. } catch (Exception $e) {
  64. $this->fail('exception raised while creating smtp transport');
  65. }
  66. try {
  67. $this->_connection = new Zend_Mail_Protocol_Smtp($this->_params['host'], $this->_params['port']);
  68. $this->_transport->setConnection($this->_connection);
  69. } catch (Exception $e) {
  70. $this->fail('exception raised while setting smtp transport connection');
  71. }
  72. $this->_connection = $this->_transport->getConnection();
  73. if (!($this->_connection instanceof Zend_Mail_Protocol_Abstract)) {
  74. $this->fail('smtp transport connection is not an instance of protocol abstract');
  75. }
  76. }
  77. }