mail = new ezcMail(); } public function tearDown() { } public function testProperties() { $this->assertSetPropertyFails( $this->mail, "does_not_exist", array( 42 ) ); $this->assertSetProperty( $this->mail, "to", array( array( 'email' => 'fh@ez.no' ) ) ); } public function testAddAddresses() { $this->mail->addTo( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ) ); $this->mail->addTo( new ezcMailAddress( 'bh@ez.no' ) ); $this->assertEquals( array( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ), new ezcMailAddress( 'bh@ez.no' ) ), $this->mail->to ); $this->mail->addCc( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ) ); $this->mail->addCc( new ezcMailAddress( 'bh@ez.no' ) ); $this->assertEquals( array( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ), new ezcMailAddress( 'bh@ez.no' ) ), $this->mail->cc ); $this->mail->addBcc( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ) ); $this->mail->addBcc( new ezcMailAddress( 'bh@ez.no' ) ); $this->assertEquals( array( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ), new ezcMailAddress( 'bh@ez.no' ) ), $this->mail->bcc ); } public function testAddAddresses2() { $this->mail->from = new ezcMailAddress( 'from@ez.no' ); $this->mail->addTo( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ) ); $this->mail->addTo( new ezcMailAddress( 'bh@ez.no' ) ); $this->mail->addCc( new ezcMailAddress( 'dr@ez.no', 'Derick Rethans' ) ); $this->mail->addBcc( new ezcMailAddress( 'amos@ez.no' ) ); $expected = "From: from@ez.no" . ezcMailTools::lineBreak() . "Reply-To: from@ez.no" . ezcMailTools::lineBreak() . "To: Frederik Holljen , bh@ez.no" . ezcMailTools::lineBreak() . "Cc: Derick Rethans " . ezcMailTools::lineBreak() . "Bcc: amos@ez.no" . ezcMailTools::lineBreak() . "Subject: " . ezcMailTools::lineBreak() . "MIME-Version: 1.0" . ezcMailTools::lineBreak() . "User-Agent: eZ components"; $return = $this->mail->generate(); // cut away the Date and Message-ID headers as there is no way to predict what they will be $return = join( ezcMailTools::lineBreak(), array_slice( explode( ezcMailTools::lineBreak(), $return ), 0, 8 ) ); $this->assertEquals( $expected, $return ); } public function testSubjectWithCharset() { $this->mail->from = new ezcMailAddress( 'from@ez.no' ); $this->mail->addTo( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ) ); $this->mail->subject = "Døtte er en test"; $this->mail->subjectCharset = 'iso-8859-1'; $expected = "From: from@ez.no" . ezcMailTools::lineBreak() . "Reply-To: from@ez.no" . ezcMailTools::lineBreak() . "To: Frederik Holljen " . ezcMailTools::lineBreak() . "Subject: =?ISO-8859-1?B?RPh0dGUgZXIgZW4gdGVzdA==?=" . ezcMailTools::lineBreak() . "MIME-Version: 1.0" . ezcMailTools::lineBreak() . "User-Agent: eZ components"; $return = $this->mail->generate(); // cut away the Date and Message-ID headers as there is no way to predict what they will be $return = join( ezcMailTools::lineBreak(), array_slice( explode( ezcMailTools::lineBreak(), $return ), 0, 6 ) ); $this->assertEquals( $expected, $return ); } public function testHeadersWithCharset() { $this->mail->from = new ezcMailAddress( 'fh@ez.no', 'Fræderik Hølljen', 'iso-8859-1' ); $this->mail->addTo( new ezcMailAddress( 'fh@ez.no', 'Fræderik Hølljen','iso-8859-1' ) ); $this->mail->addCc( new ezcMailAddress( 'fh@ez.no', 'Fræderik Hølljen','iso-8859-1' ) ); $this->mail->addBcc( new ezcMailAddress( 'fh@ez.no', 'Fræderik Hølljen','iso-8859-1' ) ); $this->mail->subject = "Døtte er en test"; $this->mail->subjectCharset = 'iso-8859-1'; $expected = "From: =?ISO-8859-1?B?RnLmZGVyaWsgSPhsbGplbg==?= " . ezcMailTools::lineBreak() . "Reply-To: =?ISO-8859-1?B?RnLmZGVyaWsgSPhsbGplbg==?= " . ezcMailTools::lineBreak() . "To: =?ISO-8859-1?B?RnLmZGVyaWsgSPhsbGplbg==?= " . ezcMailTools::lineBreak() . "Cc: =?ISO-8859-1?B?RnLmZGVyaWsgSPhsbGplbg==?= " . ezcMailTools::lineBreak() . "Bcc: =?ISO-8859-1?B?RnLmZGVyaWsgSPhsbGplbg==?= " . ezcMailTools::lineBreak() . "Subject: =?ISO-8859-1?B?RPh0dGUgZXIgZW4gdGVzdA==?=" . ezcMailTools::lineBreak() . "MIME-Version: 1.0" . ezcMailTools::lineBreak() . "User-Agent: eZ components"; $return = $this->mail->generate(); // cut away the Date and Message-ID headers as there is no way to predict what they will be $return = join( ezcMailTools::lineBreak(), array_slice( explode( ezcMailTools::lineBreak(), $return ), 0, 8 ) ); $this->assertEquals( $expected, $return ); } public function testFullMail() { $this->mail->from = new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ); $this->mail->addTo( new ezcMailAddress( 'fh@ez.no', 'Frederik Holljen' ) ); $this->mail->subject = "æøå"; $this->mail->body = new ezcMailText( "Dette er body ßßæøååå" ); // echo "\n---------------\n"; // echo $this->mail->generate(); // echo "---------------\n"; // let's try to send the thing $transport = new ezcMailTransportMta(); // $transport->send( $this->mail ); } public function testFullMailMultipart() { $this->mail->from = new ezcMailAddress( 'fh@ez.no', 'Fræderik Hølljen', "iso-8859-1" ); $this->mail->addTo( new ezcMailAddress( 'fh@ez.no', 'Fræderik Hølljeñ', "iso-8859-1" ) ); $this->mail->subject = "æøå"; $this->mail->subjectCharset = 'iso-8859-1'; $this->mail->body = new ezcMailMultipartAlternative( new ezcMailText( "Dette er body ßßæøååå", "iso-8859-1" ), $html = new ezcMailText( "Hello" ) ); $html->subType = "html"; // echo "\n---------------\n"; // echo $this->mail->generate(); // echo "---------------\n"; // let's try to send the thing // $transport = new ezcMailTransportSmtp( "smtp.ez.no" ); // $transport->send( $this->mail ); } public static function suite() { return new ezcTestSuite( "ezcMailTest" ); } } ?>