Author: Alexandru Stanoi Date: 2007-01-25 10:11:25 +0100 (Thu, 25 Jan 2007) New Revision: 4570
Log: - Implemented feature request #9308: added option classes for transports. Added: trunk/Mail/src/options/ trunk/Mail/src/options/imap_options.php trunk/Mail/src/options/pop3_options.php trunk/Mail/src/options/smtp_options.php trunk/Mail/src/options/transport_options.php trunk/Mail/tests/options/ trunk/Mail/tests/options/imap_options_test.php trunk/Mail/tests/options/pop3_options_test.php trunk/Mail/tests/options/smtp_options_test.php trunk/Mail/tests/options/transport_options_test.php Modified: trunk/Mail/ChangeLog trunk/Mail/src/mail_autoload.php trunk/Mail/src/transports/file/file_set.php trunk/Mail/src/transports/imap/imap_transport.php trunk/Mail/src/transports/mbox/mbox_set.php trunk/Mail/src/transports/mbox/mbox_transport.php trunk/Mail/src/transports/mta/transport_mta.php trunk/Mail/src/transports/pop3/pop3_transport.php trunk/Mail/src/transports/smtp/transport_smtp.php trunk/Mail/src/transports/transport_connection.php trunk/Mail/src/transports/variable/var_set.php trunk/Mail/tests/suite.php Modified: trunk/Mail/ChangeLog =================================================================== --- trunk/Mail/ChangeLog 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/ChangeLog 2007-01-25 09:11:25 UTC (rev 4570) @@ -19,6 +19,7 @@ which is set when parsing a mail. - Implemented feature request #10068: added a list of supported RFCs to the documentation. +- Implemented feature request #9308: added option classes for transports. 1.2.1 - [RELEASEDATE] Modified: trunk/Mail/src/mail_autoload.php =================================================================== --- trunk/Mail/src/mail_autoload.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/mail_autoload.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -71,6 +71,11 @@ 'ezcMailParserShutdownHandler' => 'Mail/parser/shutdown_handler.php', 'ezcMailRfc2231Implementation' => 'Mail/parser/rfc2231_implementation.php', + 'ezcMailTransportOptions' => 'Mail/options/transport_options.php', + 'ezcMailSmtpTransportOptions' => 'Mail/options/smtp_options.php', + 'ezcMailImapTransportOptions' => 'Mail/options/imap_options.php', + 'ezcMailPop3TransportOptions' => 'Mail/options/pop3_options.php', + 'ezcMailCharsetConverter' => 'Mail/internal/charset_convert.php', 'ezcMailHeaderFolder' => 'Mail/internal/header_folder.php' ); Added: trunk/Mail/src/options/imap_options.php =================================================================== --- trunk/Mail/src/options/imap_options.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/options/imap_options.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -0,0 +1,51 @@ +<?php +/** + * File containing the ezcMailImapTransportOptions class + * + * @package Mail + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Class containing the options for IMAP transport. + * + * The options from ezcMailTransportOptions are inherited. + * + * @package Mail + * @version //autogen// + */ +class ezcMailImapTransportOptions extends ezcMailTransportOptions +{ + /** + * Constructs an object with the specified values. + * + * @param array(string=>mixed) $options + */ + public function __construct( array $options = array() ) + { + parent::__construct( $options ); + } + + /** + * Sets the option $name to $value. + * + * @throws ezcBaseValueException + * if $value is not correct for the property $name + * @throws ezcBasePropertyNotFoundException + * if the propery $name is not defined + * @param string $name + * @param mixed $value + * @ignore + */ + public function __set( $name, $value ) + { + switch ( $name ) + { + default: + parent::__set( $name, $value ); + } + } +} +?> Property changes on: trunk/Mail/src/options/imap_options.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/src/options/pop3_options.php =================================================================== --- trunk/Mail/src/options/pop3_options.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/options/pop3_options.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -0,0 +1,67 @@ +<?php +/** + * File containing the ezcMailPop3TransportOptions class + * + * @package Mail + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Class containing the options for POP3 transport. + * + * The options from ezcMailTransportOptions are inherited. + * + * @property int $authenticationMethod + * Specifies the method to connect to the POP3 transport. The methods + * supported are [EMAIL PROTECTED] ezcMailPop3Transport::AUTH_PLAIN_TEXT} and + * [EMAIL PROTECTED] ezcMailPop3Transport::AUTH_APOP}. + * + * @package Mail + * @version //autogen// + */ +class ezcMailPop3TransportOptions extends ezcMailTransportOptions +{ + /** + * Constructs an object with the specified values. + * + * @param array(string=>mixed) $options + */ + public function __construct( array $options = array() ) + { + // default authentication method is PLAIN + $this->authenticationMethod = ezcMailPop3Transport::AUTH_PLAIN_TEXT; + + parent::__construct( $options ); + } + + /** + * Sets the option $name to $value. + * + * @throws ezcBaseValueException + * if $value is not correct for the property $name + * @throws ezcBasePropertyNotFoundException + * if the propery $name is not defined + * @param string $name + * @param mixed $value + * @ignore + */ + public function __set( $name, $value ) + { + switch ( $name ) + { + case 'authenticationMethod': + if ( !is_numeric( $value ) ) + { + throw new ezcBaseValueException( $name, $value, 'int' ); + } + $this->properties[$name] = (int) $value; + break; + + default: + parent::__set( $name, $value ); + } + } +} +?> Property changes on: trunk/Mail/src/options/pop3_options.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/src/options/smtp_options.php =================================================================== --- trunk/Mail/src/options/smtp_options.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/options/smtp_options.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -0,0 +1,51 @@ +<?php +/** + * File containing the ezcMailSmtpTransportOptions class + * + * @package Mail + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Class containing the options for SMTP transport. + * + * The options from ezcMailTransportOptions are inherited. + * + * @package Mail + * @version //autogen// + */ +class ezcMailSmtpTransportOptions extends ezcMailTransportOptions +{ + /** + * Constructs an object with the specified values. + * + * @param array(string=>mixed) $options + */ + public function __construct( array $options = array() ) + { + parent::__construct( $options ); + } + + /** + * Sets the option $name to $value. + * + * @throws ezcBaseValueException + * if $value is not correct for the property $name + * @throws ezcBasePropertyNotFoundException + * if the propery $name is not defined + * @param string $name + * @param mixed $value + * @ignore + */ + public function __set( $name, $value ) + { + switch ( $name ) + { + default: + parent::__set( $name, $value ); + } + } +} +?> Property changes on: trunk/Mail/src/options/smtp_options.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/src/options/transport_options.php =================================================================== --- trunk/Mail/src/options/transport_options.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/options/transport_options.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -0,0 +1,63 @@ +<?php +/** + * File containing the ezcMailTransportOption class + * + * @package Mail + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Class containing the basic options for mail transports. + * + * @property int $timeout + * Specifies the time in seconds until the connection is closed if + * there is no activity through the connection. + * + * @package Mail + * @version //autogen// + */ +class ezcMailTransportOptions extends ezcBaseOptions +{ + /** + * Constructs an object with the specified values. + * + * @param array(string=>mixed) $options + */ + public function __construct( array $options = array() ) + { + $this->timeout = 5; // default value for timeout is 5 seconds + + parent::__construct( $options ); + } + + /** + * Sets the option $name to $value. + * + * @throws ezcBaseValueException + * if $value is not correct for the property $name + * @throws ezcBasePropertyNotFoundException + * if the propery $name is not defined + * @param string $name + * @param mixed $value + * @ignore + */ + public function __set( $name, $value ) + { + switch ( $name ) + { + case 'timeout': + if ( !is_numeric( $value ) || ( $value < 1 ) ) + { + throw new ezcBaseValueException( $name, $value, 'int >= 1' ); + } + $this->properties[$name] = (int) $value; + break; + + default: + throw new ezcBasePropertyNotFoundException( $name ); + } + } +} +?> Property changes on: trunk/Mail/src/options/transport_options.php ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/Mail/src/transports/file/file_set.php =================================================================== --- trunk/Mail/src/transports/file/file_set.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/file/file_set.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -27,7 +27,6 @@ * * @package Mail * @version //autogen// - * @mainclass */ class ezcMailFileSet implements ezcMailParserSet { Modified: trunk/Mail/src/transports/imap/imap_transport.php =================================================================== --- trunk/Mail/src/transports/imap/imap_transport.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/imap/imap_transport.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -20,6 +20,7 @@ * @todo // support for signing? * @todo listUniqueIdentifiers(): add UIVALIDITY value to UID (like in POP3). * (if necessary). + * * @package Mail * @version //autogen// * @mainclass @@ -88,32 +89,32 @@ const RESPONSE_FEEDBACK = 5; /** - * Basic flags are used by [EMAIL PROTECTED] setFlag()} and [EMAIL PROTECTED] clearFlag()} - * ANSWERED Message has been answered - * DELETED Message is marked to be deleted by later EXPUNGE - * DRAFT Message has marked as a draft - * FLAGGED Message is "flagged" for urgent/special attention - * SEEN Message has been read - * - * @var array(int=>string) - */ + * Basic flags are used by [EMAIL PROTECTED] setFlag()} and [EMAIL PROTECTED] clearFlag()} + * ANSWERED Message has been answered + * DELETED Message is marked to be deleted by later EXPUNGE + * DRAFT Message has marked as a draft + * FLAGGED Message is "flagged" for urgent/special attention + * SEEN Message has been read + * + * @var array(int=>string) + */ private static $basicFlags = array( 'ANSWERED', 'DELETED', 'DRAFT', 'FLAGGED', 'SEEN' ); /** - * Extended flags are used by [EMAIL PROTECTED] searchByFlag()} - * ANSWERED Message has been answered - * DELETED Message is marked to be deleted by later EXPUNGE - * DRAFT Message has marked as a draft - * FLAGGED Message is "flagged" for urgent/special attention - * RECENT Message is recent (cannot be set) - * SEEN Message has been read - * UNANSWERED, UNDELETED, UNDRAFT, UNFLAGGED, OLD, UNSEEN - * Opposites of the above flags - * NEW Equivalent to RECENT + UNSEEN - * ALL All the messages - * - * @var array(int=>string) - */ + * Extended flags are used by [EMAIL PROTECTED] searchByFlag()} + * ANSWERED Message has been answered + * DELETED Message is marked to be deleted by later EXPUNGE + * DRAFT Message has marked as a draft + * FLAGGED Message is "flagged" for urgent/special attention + * RECENT Message is recent (cannot be set) + * SEEN Message has been read + * UNANSWERED, UNDELETED, UNDRAFT, UNFLAGGED, OLD, UNSEEN + * Opposites of the above flags + * NEW Equivalent to RECENT + UNSEEN + * ALL All the messages + * + * @var array(int=>string) + */ private static $extendedFlags = array( 'ALL', 'ANSWERED', 'DELETED', 'DRAFT', 'FLAGGED', 'NEW', 'OLD', 'RECENT', 'SEEN', 'UNANSWERED', 'UNDELETED', 'UNDRAFT', 'UNFLAGGED', 'UNRECENT', 'UNSEEN' ); /** @@ -150,6 +151,13 @@ private $connection = null; /** + * Options for an IMAP transport connection. + * + * @var ezcMailImapTransportOptions + */ + private $options; + + /** * Creates a new IMAP transport and connects to the $server at $port. * * You can specify the $port if the IMAP server is not on the default port @@ -157,14 +165,18 @@ * the class variables [EMAIL PROTECTED] $this->server} and [EMAIL PROTECTED] $this->port} to * the respective parameters values. * + * @see ezcMailImapTransportOptions for options you can specify for IMAP. + * * @throws ezcMailTransportException - * if it was not possible to connect to the server. + * if it was not possible to connect to the server * @param string $server * @param int $port + * @param array(string=>mixed) $options */ - public function __construct( $server, $port = 143 ) + public function __construct( $server, $port = 143, array $options = array() ) { - $this->connection = new ezcMailTransportConnection( $server, $port ); + $this->options = new ezcMailImapTransportOptions( $options ); + $this->connection = new ezcMailTransportConnection( $server, $port, $options ); // get the server greeting $response = $this->connection->getLine(); if ( strpos( $response, "* OK" ) === false ) Modified: trunk/Mail/src/transports/mbox/mbox_set.php =================================================================== --- trunk/Mail/src/transports/mbox/mbox_set.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/mbox/mbox_set.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -18,7 +18,7 @@ * * @package Mail * @version //autogen// - * @mainclass + * @access private */ class ezcMailMboxSet implements ezcMailParserSet { Modified: trunk/Mail/src/transports/mbox/mbox_transport.php =================================================================== --- trunk/Mail/src/transports/mbox/mbox_transport.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/mbox/mbox_transport.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -89,8 +89,8 @@ do { $data = fgets( $this->fh ); - } - while ( !feof( $this->fh ) && substr( $data, 0, 5 ) !== "From " ); + } while ( !feof( $this->fh ) && substr( $data, 0, 5 ) !== "From " ); + if ( feof( $this->fh ) ) { return false; @@ -121,8 +121,8 @@ { $messages[] = $position; } - } - while ( $position !== false ); + } while ( $position !== false ); + return $messages; } Modified: trunk/Mail/src/transports/mta/transport_mta.php =================================================================== --- trunk/Mail/src/transports/mta/transport_mta.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/mta/transport_mta.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -67,6 +67,7 @@ * This class is deprecated. Use ezcMailMtaTransport instead. * * @package Mail + * @ignore */ class ezcMailTransportMta extends ezcMailMtaTransport { Modified: trunk/Mail/src/transports/pop3/pop3_transport.php =================================================================== --- trunk/Mail/src/transports/pop3/pop3_transport.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/pop3/pop3_transport.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -21,6 +21,7 @@ * @todo ignore messages of a certain size? * @todo // add support for SSL? * @todo // support for signing? + * * @package Mail * @version //autogen// * @mainclass @@ -85,20 +86,30 @@ private $greeting = null; /** + * Options for a POP3 transport connection. + * + * @var ezcMailPop3TransportOptions + */ + private $options; + + /** * Creates a new POP3 transport and connects to the $server at $port. * - * You can specify the $port if the POP3 server is not on the default port - * 110. + * You can specify the $port if the POP3 server is not on the default port 110. * + * @see ezcMailPop3TransportOptions for options you can specify for POP3. + * * @throws ezcMailTransportException * if it was not possible to connect to the server * @param string $server * @param int $port + * @param array(string=>mixed) $options */ - public function __construct( $server, $port = 110 ) + public function __construct( $server, $port = 110, array $options = array() ) { + $this->options = new ezcMailPop3TransportOptions( $options ); // open the connection - $this->connection = new ezcMailTransportConnection( $server, $port ); + $this->connection = new ezcMailTransportConnection( $server, $port, $options ); $this->greeting = $this->connection->getLine(); if ( !$this->isPositiveResponse( $this->greeting ) ) { @@ -143,7 +154,8 @@ * Authenticates the user to the POP3 server with $user and $password. * * You can choose the authentication method with the $method parameter. - * The default is to use plaintext username and password. + * The default is to use plaintext username and password (specified in the + * ezcMailPop3TransportOptions class). * * This method should be called directly after the construction of this * object. @@ -157,13 +169,18 @@ * @param string $password * @param int method */ - public function authenticate( $user, $password, $method = self::AUTH_PLAIN_TEXT ) + public function authenticate( $user, $password, $method = null ) { if ( $this->state != self::STATE_AUTHORIZATION ) { throw new ezcMailTransportException( "Tried to authenticate when there was no connection or when already authenticated." ); } + if ( is_null( $method ) ) + { + $method = $this->options->authenticationMethod; + } + if ( $method == self::AUTH_PLAIN_TEXT ) // normal plain text login { // authenticate ourselves Modified: trunk/Mail/src/transports/smtp/transport_smtp.php =================================================================== --- trunk/Mail/src/transports/smtp/transport_smtp.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/smtp/transport_smtp.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -26,10 +26,10 @@ * @property string $password * The password used for authentication. * @property int $timeout - * The timeout value of the connection in seconds. The default is - * five seconds. + * The timeout value of the connection in seconds. The default is + * 5 seconds [EMAIL PROTECTED] ezcMailTransportOptions}. * @property string $senderHost - * The hostname of the computer that sends the mail. the default is + * The hostname of the computer that sends the mail. The default is * 'localhost'. * * @package Mail @@ -101,8 +101,15 @@ private $properties = array(); /** - * Constructs a new ezcMailTransportSmtp. + * Holds the options of this class. * + * @var ezcMailSmtpTransportOptions + */ + private $options; + + /** + * Constructs a new ezcMailSmtpTransport. + * * The constructor expects, at least, the hostname $host of the SMTP * server. * @@ -116,12 +123,15 @@ * The portnumber $port, default the SMTP standard port, to which will * be connected. * + * @see ezcMailSmtpTransportOptions for options you can specify for SMTP. + * * @param string $host * @param string $user * @param string $password * @param int $port + * @param array(string=>mixed) $options */ - public function __construct( $host, $user = '', $password = '', $port = 25 ) + public function __construct( $host, $user = '', $password = '', $port = 25, array $options = array() ) { $this->serverHost = $host; $this->user = $user; @@ -130,8 +140,9 @@ $this->doAuthenticate = $user != '' ? true : false; $this->status = self::STATUS_NOT_CONNECTED; - $this->timeout = 5; $this->senderHost = 'localhost'; + $this->options = new ezcMailSmtpTransportOptions( $options ); + $this->timeout = $this->options->timeout; } /** @@ -411,7 +422,7 @@ /** * Sends the QUIT command to the server and breaks the connection. * - * @throws ezcMailTransportException + * @throws ezcMailTransportSmtpException * if the QUIT command failed. */ public function disconnect() @@ -453,7 +464,7 @@ * * The sender's mail address $from may be enclosed in angle brackets. * - * @throws ezcMailTransportException + * @throws ezcMailTransportSmtpException * if there is no valid connection * or if the MAIL FROM command failed. * @param string $from @@ -480,7 +491,7 @@ * * The recipient mail address $email may be enclosed in angle brackets. * - * @throws ezcMailTransportException + * @throws ezcMailTransportSmtpException * if there is no valid connection * or if the RCPT TO command failed. * @param string $to @@ -500,7 +511,7 @@ /** * Send the DATA command to the SMTP server. * - * @throws ezcMailTransportException + * @throws ezcMailTransportSmtpException * if there is no valid connection * or if the DATA command failed. */ @@ -540,7 +551,7 @@ /** * Returns data received from the connection stream. * - * @throws ezcMailTransportSmtpConnection + * @throws ezcMailTransportSmtpException * if there is no valid connection. * @return string */ @@ -585,6 +596,7 @@ * This class is deprecated. Use ezcMailSmtpTransport instead. * * @package Mail + * @ignore */ class ezcMailTransportSmtp extends ezcMailSmtpTransport { Modified: trunk/Mail/src/transports/transport_connection.php =================================================================== --- trunk/Mail/src/transports/transport_connection.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/transport_connection.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -20,6 +20,11 @@ class ezcMailTransportConnection { /** + * The line-break characters to send to the server. + */ + const CRLF = "\r\n"; + + /** * The connection to the server or null if there is none. * * @var resource @@ -27,30 +32,38 @@ private $connection = null; /** - * The line-break characters to send to the server. + * Options for a transport connection. + * + * @var ezcMailTransportOptions */ - const CRLF = "\r\n"; + private $options; /** * Constructs a new connection to the $server using the port $port. * - * $timeout controls the amount of seconds before the connection times out. + * @see ezcMailTransportOptions for options you can specify for a transport connection. * + * @todo The @ should be removed when PHP doesn't throw warnings for connect problems. + * @todo Implement SSL support + * * @throws ezcMailTransportException - * if a connection to the server could not be made. + * if a connection to the server could not be made + * @param string $server + * @param int $port + * @param array(string=>mixed) $options */ - public function __construct( $server, $port, $timeout = 5 ) + public function __construct( $server, $port, array $options = array() ) { $errno = null; $errstr = null; + $this->options = new ezcMailTransportOptions( $options ); - // FIXME: The @ should be removed when PHP doesn't throw warnings for connect problems $this->connection = @stream_socket_client( "tcp://{$server}:{$port}", - $errno, $errstr, $timeout ); + $errno, $errstr, $this->options->timeout ); if ( is_resource( $this->connection ) ) { - stream_set_timeout( $this->connection, $timeout ); + stream_set_timeout( $this->connection, $this->options->timeout ); } else { @@ -82,11 +95,11 @@ /** * Returns one line of data from the stream. * - * The returned lined will have linebreaks removed if the $trim option is set. + * The returned line will have linebreaks removed if the $trim option is set. * + * @throws ezcMailTransportConnection + * if there is no valid connection * @param bool $trim - * @throws ezcMailTransportConnection - * if there is no valid connection. * @return string */ public function getLine( $trim = false ) @@ -128,5 +141,4 @@ } } } - ?> Modified: trunk/Mail/src/transports/variable/var_set.php =================================================================== --- trunk/Mail/src/transports/variable/var_set.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/src/transports/variable/var_set.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -6,13 +6,13 @@ * * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. * @license http://ez.no/licenses/new_bsd New BSD License - * @version //autogentag// + * @version //autogen// * @package Mail */ /** * ezcMailVariableSet is an internal class that can be used to parse mail directly from - * a variable in your script. + * a string variable in your script. * * The variable should contain the complete mail message in RFC822 format. * @@ -27,7 +27,6 @@ * * @package Mail * @version //autogen// - * @mainclass */ class ezcMailVariableSet implements ezcMailParserSet { Added: trunk/Mail/tests/options/imap_options_test.php =================================================================== --- trunk/Mail/tests/options/imap_options_test.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/tests/options/imap_options_test.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -0,0 +1,60 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogen// + * @filesource + * @package Mail + * @subpackage Tests + */ + +/** + * @package Mail + * @subpackage Tests + */ +class ezcMailImapTransportOptionsTest extends ezcTestCase +{ +/* // wait until IMAP has options to test + public function testTransportOptionsDefault() + { + $options = new ezcMailImapTransportOptions(); + // ... + } + + public function testTransportOptionsSet() + { + $options = new ezcMailImapTransportOptions(); + // ... + } + public function testTransportOptionsSetInvalid() + { + $options = new ezcMailImapTransportOptions(); + try + { + // ... + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBaseValueException $e ) + { + } + } +*/ + public function testTransportOptionsSetNotExistent() + { + $options = new ezcMailImapTransportOptions(); + try + { + $options->no_such_option = 'xxx'; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBasePropertyNotFoundException $e ) + { + } + } + + public static function suite() + { + return new PHPUnit_Framework_TestSuite( "ezcMailImapTransportOptionsTest" ); + } +} +?> Property changes on: trunk/Mail/tests/options/imap_options_test.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/tests/options/pop3_options_test.php =================================================================== --- trunk/Mail/tests/options/pop3_options_test.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/tests/options/pop3_options_test.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -0,0 +1,61 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogen// + * @filesource + * @package Mail + * @subpackage Tests + */ + +/** + * @package Mail + * @subpackage Tests + */ +class ezcMailPop3TransportOptionsTest extends ezcTestCase +{ + public function testTransportOptionsDefault() + { + $options = new ezcMailPop3TransportOptions(); + $this->assertEquals( ezcMailPop3Transport::AUTH_PLAIN_TEXT, $options->authenticationMethod ); + } + + public function testTransportOptionsSet() + { + $options = new ezcMailPop3TransportOptions(); + $options->authenticationMethod = ezcMailPop3Transport::AUTH_APOP; + $this->assertEquals( ezcMailPop3Transport::AUTH_APOP, $options->authenticationMethod ); + } + + public function testTransportOptionsSetInvalid() + { + $options = new ezcMailPop3TransportOptions(); + try + { + $options->authenticationMethod = 'xxx'; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBaseValueException $e ) + { + } + } + + public function testTransportOptionsSetNotExistent() + { + $options = new ezcMailPop3TransportOptions(); + try + { + $options->no_such_option = 'xxx'; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBasePropertyNotFoundException $e ) + { + } + } + + public static function suite() + { + return new PHPUnit_Framework_TestSuite( "ezcMailPop3TransportOptionsTest" ); + } +} +?> Property changes on: trunk/Mail/tests/options/pop3_options_test.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/tests/options/smtp_options_test.php =================================================================== --- trunk/Mail/tests/options/smtp_options_test.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/tests/options/smtp_options_test.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -0,0 +1,60 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogen// + * @filesource + * @package Mail + * @subpackage Tests + */ + +/** + * @package Mail + * @subpackage Tests + */ +class ezcMailSmtpTransportOptionsTest extends ezcTestCase +{ +/* // wait until SMTP has options to test + public function testTransportOptionsDefault() + { + $options = new ezcMailSmtpTransportOptions(); + // ... + } + + public function testTransportOptionsSet() + { + $options = new ezcMailSmtpTransportOptions(); + // ... + } + public function testTransportOptionsSetInvalid() + { + $options = new ezcMailSmtpTransportOptions(); + try + { + // ... + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBaseValueException $e ) + { + } + } +*/ + public function testTransportOptionsSetNotExistent() + { + $options = new ezcMailSmtpTransportOptions(); + try + { + $options->no_such_option = 'xxx'; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBasePropertyNotFoundException $e ) + { + } + } + + public static function suite() + { + return new PHPUnit_Framework_TestSuite( "ezcMailSmtpTransportOptionsTest" ); + } +} +?> Property changes on: trunk/Mail/tests/options/smtp_options_test.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/tests/options/transport_options_test.php =================================================================== --- trunk/Mail/tests/options/transport_options_test.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/tests/options/transport_options_test.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -0,0 +1,70 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogen// + * @filesource + * @package Mail + * @subpackage Tests + */ + +/** + * @package Mail + * @subpackage Tests + */ +class ezcMailTransportOptionsTest extends ezcTestCase +{ + public function testTransportOptionsDefault() + { + $options = new ezcMailTransportOptions(); + $this->assertEquals( 5, $options->timeout ); + } + + public function testTransportOptionsSet() + { + $options = new ezcMailTransportOptions(); + $options->timeout = 10; + $this->assertEquals( 10, $options->timeout ); + } + + public function testTransportOptionsSetInvalid() + { + $options = new ezcMailTransportOptions(); + try + { + $options->timeout = 0; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBaseValueException $e ) + { + } + + try + { + $options->timeout = 'xxx'; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBaseValueException $e ) + { + } + } + + public function testTransportOptionsSetNotExistent() + { + $options = new ezcMailTransportOptions(); + try + { + $options->no_such_option = 'xxx'; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBasePropertyNotFoundException $e ) + { + } + } + + public static function suite() + { + return new PHPUnit_Framework_TestSuite( "ezcMailTransportOptionsTest" ); + } +} +?> Property changes on: trunk/Mail/tests/options/transport_options_test.php ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/Mail/tests/suite.php =================================================================== --- trunk/Mail/tests/suite.php 2007-01-25 09:08:41 UTC (rev 4569) +++ trunk/Mail/tests/suite.php 2007-01-25 09:11:25 UTC (rev 4570) @@ -14,6 +14,10 @@ require_once( "mail_test.php" ); require_once( "composer_test.php" ); require_once( "interfaces/part_test.php" ); +require_once( "options/transport_options_test.php" ); +require_once( "options/imap_options_test.php" ); +require_once( "options/pop3_options_test.php" ); +require_once( "options/smtp_options_test.php" ); require_once( "parts/text_part_test.php" ); require_once( "parts/multipart_test.php" ); require_once( "parts/file_part_test.php" ); @@ -50,6 +54,10 @@ $this->addTest( ezcMailTest::suite() ); $this->addTest( ezcMailComposerTest::suite() ); $this->addTest( ezcMailPartTest::suite() ); + $this->addTest( ezcMailTransportOptionsTest::suite() ); + $this->addTest( ezcMailImapTransportOptionsTest::suite() ); + $this->addTest( ezcMailPop3TransportOptionsTest::suite() ); + $this->addTest( ezcMailSmtpTransportOptionsTest::suite() ); $this->addTest( ezcMailTextTest::suite() ); $this->addTest( ezcMailMultiPartTest::suite() ); $this->addTest( ezcMailFileTest::suite() ); -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components