Author: as
Date: Thu Jul  5 17:23:16 2007
New Revision: 5704

Log:
- Added some tests for SMTP AUTH LOGIN.

Modified:
    trunk/Mail/tests/transports/transport_smtp_test.php

Modified: trunk/Mail/tests/transports/transport_smtp_test.php
==============================================================================
--- trunk/Mail/tests/transports/transport_smtp_test.php [iso-8859-1] (original)
+++ trunk/Mail/tests/transports/transport_smtp_test.php [iso-8859-1] Thu Jul  5 
17:23:16 2007
@@ -25,6 +25,11 @@
     const HOST_SSL = 'ezctest.ez.no';
     const PORT_SSL = 465;
 
+    const HOST_MTA = 'mta1.ez.no';
+    const PORT_MTA = 25;
+    const USER_MTA = '[EMAIL PROTECTED]';
+    const PASS_MTA = 'ezcomponents';
+
     protected function setUp()
     {
         if ( @fsockopen( self::HOST, self::PORT, $errno, $errstr, 1 ) === 
false )
@@ -40,7 +45,6 @@
         $this->mail->body = new ezcMailText( "It doesn't look as if it's ever 
used." );
     }
 
-    
     public function testWrapperMockLoginAuthenticateFail250()
     {
         $smtp = $this->getMock( 'ezcMailSmtpTransportWrapper', array( 
'getReplyCode', 'sendData' ), array( self::HOST, 'user', 'password', self::PORT 
) );
@@ -644,6 +648,63 @@
         }
     }
 
+    public function testAuthLogin()
+    {
+        try
+        {
+            $smtp = new ezcMailSmtpTransport( self::HOST_MTA, self::USER_MTA, 
self::PASS_MTA, self::PORT_MTA, array( 'connectionType' => 
ezcMailSmtpTransport::CONNECTION_PLAIN ) );
+            $mail = new ezcMail();
+            $mail->from = new ezcMailAddress( '[EMAIL PROTECTED]', 'From' );
+            $mail->addTo( new ezcMailAddress( '[EMAIL PROTECTED]', 'To' ) );
+            $mail->subject = "SMTP plain test";
+            $mail->body = new ezcMailText( "It doesn't look as if it's ever 
used." );
+            $mail->generate();
+            $smtp->send( $mail );
+        }
+        catch ( ezcMailTransportException $e )
+        {
+            $this->fail( $e->getMessage() );
+        }
+    }
+
+    public function testAuthLoginWrongUsername()
+    {
+        try
+        {
+            $smtp = new ezcMailSmtpTransport( self::HOST_MTA, 'this user could 
not possible exist', self::PASS_MTA, self::PORT_MTA, array( 'connectionType' => 
ezcMailSmtpTransport::CONNECTION_PLAIN ) );
+            $mail = new ezcMail();
+            $mail->from = new ezcMailAddress( '[EMAIL PROTECTED]', 'From' );
+            $mail->addTo( new ezcMailAddress( '[EMAIL PROTECTED]', 'To' ) );
+            $mail->subject = "SMTP plain test";
+            $mail->body = new ezcMailText( "It doesn't look as if it's ever 
used." );
+            $mail->generate();
+            $smtp->send( $mail );
+            $this->fail( 'Expected message was not thrown.' );
+        }
+        catch ( ezcMailTransportException $e )
+        {
+        }
+    }
+
+    public function testAuthLoginWrongPassword()
+    {
+        try
+        {
+            $smtp = new ezcMailSmtpTransport( self::HOST_MTA, self::USER_MTA, 
'wrong password', self::PORT_MTA, array( 'connectionType' => 
ezcMailSmtpTransport::CONNECTION_PLAIN ) );
+            $mail = new ezcMail();
+            $mail->from = new ezcMailAddress( '[EMAIL PROTECTED]', 'From' );
+            $mail->addTo( new ezcMailAddress( '[EMAIL PROTECTED]', 'To' ) );
+            $mail->subject = "SMTP plain test";
+            $mail->body = new ezcMailText( "It doesn't look as if it's ever 
used." );
+            $mail->generate();
+            $smtp->send( $mail );
+            $this->fail( 'Expected message was not thrown.' );
+        }
+        catch ( ezcMailTransportException $e )
+        {
+        }
+    }
+
     public function testConstructorPort()
     {
         $smtp = new ezcMailSmtpTransport( self::HOST_SSL, '', '', null, array( 
'connectionType' => ezcMailSmtpTransport::CONNECTION_PLAIN ) );


-- 
svn-components mailing list
[EMAIL PROTECTED]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to