Author: Frederik Holljen Date: 2007-02-02 08:17:00 +0100 (Fri, 02 Feb 2007) New Revision: 4618
Log: - Fixed bug #010138: Doc of ezcMailMultipartDigest->__construct() incorrect (The documentation was correct, the implementation was wrong.) Added: trunk/Mail/tests/parts/data/ezcMailMultipartDigestTest_multiple_digest.data trunk/Mail/tests/parts/data/ezcMailMultipartDigestTest_singleMail.data trunk/Mail/tests/parts/multipart_digest_test.php Modified: trunk/Mail/ChangeLog trunk/Mail/src/parts/multiparts/multipart_digest.php trunk/Mail/src/transports/imap/imap_transport.php trunk/Mail/tests/suite.php Modified: trunk/Mail/ChangeLog =================================================================== --- trunk/Mail/ChangeLog 2007-02-02 02:00:17 UTC (rev 4617) +++ trunk/Mail/ChangeLog 2007-02-02 07:17:00 UTC (rev 4618) @@ -26,8 +26,10 @@ Based on a patch from Mikko Koppanen. - Implemented feature request #10091: added SSL/TLS support for the SMTP transport. Based on a patch from Christian Michel. +- Fixed bug #010138: Doc of ezcMailMultipartDigest->__construct() incorrect + (The documentation was correct, the implementation was wrong.) - + 1.2.1 - [RELEASEDATE] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: trunk/Mail/src/parts/multiparts/multipart_digest.php =================================================================== --- trunk/Mail/src/parts/multiparts/multipart_digest.php 2007-02-02 02:00:17 UTC (rev 4617) +++ trunk/Mail/src/parts/multiparts/multipart_digest.php 2007-02-02 07:17:00 UTC (rev 4618) @@ -24,11 +24,15 @@ /** * Constructs a new ezcMailMultipartDigest * - * The constructor accepts an arbitrary number of ezcMail or arrays with ezcMail objects. + * The constructor accepts an arbitrary number of ezcMail/ezcMailRfc822Digest objects + * or arrays with objects of these types. + * + * Objects of the type ezcMail are wrapped into an ezcMailRfc822Digest object. + * * Parts are added in the order provided. Parameters of the wrong * type are ignored. * - * @param ezcMail|array(ezcMail) + * @param ezcMailRfc822Digest|array(ezcMailRfc822Digest) */ public function __construct() { @@ -36,18 +40,26 @@ parent::__construct( array() ); foreach ( $args as $part ) { - if ( $part instanceof ezcMailPart ) + if ( $part instanceof ezcMail ) { + $this->parts[] = new ezcMailRfc822Digest( $part ); + } + else if( $part instanceof ezcMailRfc822Digest ) + { $this->parts[] = $part; } - elseif( is_array( $part ) ) // add each and everyone of the parts in the array + else if ( is_array( $part ) ) // add each and everyone of the parts in the array { foreach ( $part as $array_part ) { - if ( $array_part instanceof ezcMailRfc822Digest ) + if ( $array_part instanceof ezcMail ) { - $this->parts[] = $array_part;; + $this->parts[] = new ezcMailRfc822Digest( $array_part ); } + else if ( $array_part instanceof ezcMailRfc822Digest ) + { + $this->parts[] = $array_part; + } } } } Modified: trunk/Mail/src/transports/imap/imap_transport.php =================================================================== --- trunk/Mail/src/transports/imap/imap_transport.php 2007-02-02 02:00:17 UTC (rev 4617) +++ trunk/Mail/src/transports/imap/imap_transport.php 2007-02-02 07:17:00 UTC (rev 4618) @@ -436,7 +436,7 @@ * from the server), $state revert to STATE_AUTHENTICATED. * After successfully selecting a mailbox, $state will be STATE_SELECTED * or STATE_SELECTED_READONLY. - * Inbox is a special mailbox and can be specified in whatever-case. + * Inbox is a special mailbox and can always be specified. * * @throws ezcMailMailTransportException * if $state is not accepted Added: trunk/Mail/tests/parts/data/ezcMailMultipartDigestTest_multiple_digest.data =================================================================== --- trunk/Mail/tests/parts/data/ezcMailMultipartDigestTest_multiple_digest.data 2007-02-02 02:00:17 UTC (rev 4617) +++ trunk/Mail/tests/parts/data/ezcMailMultipartDigestTest_multiple_digest.data 2007-02-02 07:17:00 UTC (rev 4618) @@ -0,0 +1,30 @@ +Content-Type: multipart/digest; boundary="boundaryString" + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--boundaryString +Content-Type: message/rfc822 +Content-Disposition: inline + +headers-1 +body-1 +--boundaryString +Content-Type: message/rfc822 +Content-Disposition: inline + +headers-2 +body-2 +--boundaryString +Content-Type: message/rfc822 +Content-Disposition: inline + +headers-3 +body-3 +--boundaryString +Content-Type: message/rfc822 +Content-Disposition: inline + +headers-4 +body-4 +--boundaryString-- \ No newline at end of file Added: trunk/Mail/tests/parts/data/ezcMailMultipartDigestTest_singleMail.data =================================================================== --- trunk/Mail/tests/parts/data/ezcMailMultipartDigestTest_singleMail.data 2007-02-02 02:00:17 UTC (rev 4617) +++ trunk/Mail/tests/parts/data/ezcMailMultipartDigestTest_singleMail.data 2007-02-02 07:17:00 UTC (rev 4618) @@ -0,0 +1,12 @@ +Content-Type: multipart/digest; boundary="boundaryString" + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--boundaryString +Content-Type: message/rfc822 +Content-Disposition: inline + +headers-1 +body-1 +--boundaryString-- \ No newline at end of file Added: trunk/Mail/tests/parts/multipart_digest_test.php =================================================================== --- trunk/Mail/tests/parts/multipart_digest_test.php 2007-02-02 02:00:17 UTC (rev 4617) +++ trunk/Mail/tests/parts/multipart_digest_test.php 2007-02-02 07:17:00 UTC (rev 4618) @@ -0,0 +1,82 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Mail + * @subpackage Tests + */ + +// Needed for static boundary string... +class MultipartDigestTestClass extends ezcMailMultipartDigest +{ + protected static function generateBoundary() + { + return "boundaryString"; + } +} + +// special mail class which generates to "headers" and "body" only. +class MultipartDigestTestMail extends ezcMail +{ + private $num; + + public function __construct( $num ) + { + $this->num = $num; + } + + public function generateHeaders() + { + return "headers-{$this->num}"; + } + + public function generateBody() + { + return "body-{$this->num}"; + } +} + +/** + * @package Mail + * @subpackage Tests + */ +class ezcMailMultipartDigestTest extends ezcTestCase +{ + // single ezcMail + public function testSingleEzcMail() + { + $digest = new MultipartDigestTestMail( 1 ); + $multipart = new MultipartDigestTestClass( $digest ); + $this->assertEquals( file_get_contents( dirname( __FILE__ ) . "/data/ezcMailMultipartDigestTest_singleMail.data" ), + $multipart->generate() ); + } + + // single ezcMailRfc822Digest + public function testSingleEzcRfc822DigestMail() + { + $digest = new ezcMailRfc822Digest( new MultipartDigestTestMail( 1 ) ); + $multipart = new MultipartDigestTestClass( $digest ); + $this->assertEquals( file_get_contents( dirname( __FILE__ ) . "/data/ezcMailMultipartDigestTest_singleMail.data" ), + $multipart->generate() ); + } + + // multiple array ezcMail and ezcMailRfc822Digest objects + public function testMultipleDigestObjects() + { + $mail1 = new MultipartDigestTestMail( 1 ); + $mail2 = new ezcMailRfc822Digest( new MultipartDigestTestMail( 2 ) ); + $mail34 = array( new ezcMailRfc822Digest( new MultipartDigestTestMail( 3 ) ), new MultipartDigestTestMail( 4 ) ); + $multipart = new MultipartDigestTestClass( $mail1, $mail2, $mail34 ); +// file_put_contents( dirname( __FILE__ ) . "/data/ezcMailMultipartDigestTest_multiple_digest.data", $multipart->generate() ); + $this->assertEquals( file_get_contents( dirname( __FILE__ ) . "/data/ezcMailMultipartDigestTest_multiple_digest.data" ), + $multipart->generate() ); + } + + public static function suite() + { + return new PHPUnit_Framework_TestSuite( "ezcMailMultipartDigestTest" ); + } +} +?> Property changes on: trunk/Mail/tests/parts/multipart_digest_test.php ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/Mail/tests/suite.php =================================================================== --- trunk/Mail/tests/suite.php 2007-02-02 02:00:17 UTC (rev 4617) +++ trunk/Mail/tests/suite.php 2007-02-02 07:17:00 UTC (rev 4618) @@ -21,6 +21,7 @@ require_once( "options/parser_options_test.php" ); require_once( "parts/text_part_test.php" ); require_once( "parts/multipart_test.php" ); +require_once( "parts/multipart_digest_test.php" ); require_once( "parts/file_part_test.php" ); require_once( "parts/virtual_file_part_test.php" ); require_once( "parts/stream_file_part_test.php" ); @@ -66,6 +67,7 @@ $this->addTest( ezcMailVirtualFileTest::suite() ); $this->addTest( ezcMailStreamFileTest::suite() ); $this->addTest( ezcMailRfc822DigestTest::suite() ); + $this->addTest( ezcMailMultipartDigestTest::suite() ); $this->addTest( ezcMailToolsTest::suite() ); $this->addTest( ezcMailTransportMtaTest::suite() ); $this->addTest( ezcMailTransportSmtpTest::suite() ); -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components