2
0

SmtpTest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * @category Zend
  36. * @package Zend_Mail
  37. * @subpackage UnitTests
  38. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  39. * @license http://framework.zend.com/license/new-bsd New BSD License
  40. * @group Zend_Mail
  41. */
  42. class Zend_Mail_SmtpTest extends PHPUnit_Framework_TestCase
  43. {
  44. protected $_params;
  45. protected $_transport;
  46. protected $_connection;
  47. public function setUp()
  48. {
  49. $this->_params = array('host' => TESTS_ZEND_MAIL_SMTP_HOST,
  50. 'port' => TESTS_ZEND_MAIL_SMTP_PORT,
  51. 'username' => TESTS_ZEND_MAIL_SMTP_USER,
  52. 'password' => TESTS_ZEND_MAIL_SMTP_PASSWORD,
  53. 'auth' => TESTS_ZEND_MAIL_SMTP_AUTH);
  54. }
  55. public function testTransportSetup()
  56. {
  57. try {
  58. $this->_transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params);
  59. } catch (Exception $e) {
  60. $this->fail('exception raised while creating smtp transport');
  61. }
  62. try {
  63. $this->_connection = new Zend_Mail_Protocol_Smtp($this->_params['host'], $this->_params['port']);
  64. $this->_transport->setConnection($this->_connection);
  65. } catch (Exception $e) {
  66. $this->fail('exception raised while setting smtp transport connection');
  67. }
  68. $this->_connection = $this->_transport->getConnection();
  69. if (!($this->_connection instanceof Zend_Mail_Protocol_Abstract)) {
  70. $this->fail('smtp transport connection is not an instance of protocol abstract');
  71. }
  72. }
  73. }