TYPO3 API  SVNRelease
t3lib_mail_swiftmaileradapterTest.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 * Copyright notice
00004 *
00005 * (c) 2011 Ernesto Baschny (ernst@cron-it.de)
00006 * All rights reserved
00007 *
00008 * This script is part of the TYPO3 project. The TYPO3 project is
00009 * free software; you can redistribute it and/or modify
00010 * it under the terms of the GNU General Public License as published by
00011 * the Free Software Foundation; either version 2 of the License, or
00012 * (at your option) any later version.
00013 *
00014 * The GNU General Public License can be found at
00015 * http://www.gnu.org/copyleft/gpl.html.
00016 *
00017 * This script is distributed in the hope that it will be useful,
00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 * GNU General Public License for more details.
00021 *
00022 * This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 /**
00026  * Testcase for the t3lib_mail_SwiftMailerAdapter class.
00027  *
00028  * @package TYPO3
00029  * @subpackage t3lib
00030  *
00031  * @author Ernesto Baschny <ernst@cron-it.de>
00032  */
00033 class t3lib_mail_SwiftMailerAdapterTest extends tx_phpunit_testcase {
00034 
00035     public function setUp() {
00036         if (!class_exists('t3lib_mail_SwiftMailerAdapterExposed')) {
00037             // Make protected methods accessible so that they can be tested:
00038             eval('class t3lib_mail_SwiftMailerAdapterExposed extends t3lib_mail_SwiftMailerAdapter {
00039                 public function parseAddressesExposed($args) {
00040                     return $this->parseAddresses($args);
00041                 }
00042             }');
00043         }
00044         $this->fixture = new t3lib_mail_SwiftMailerAdapterExposed();
00045     }
00046 
00047     public function tearDown() {
00048     }
00049 
00050     //////////////////////////
00051     // Tests concerning mail
00052     //////////////////////////
00053 
00054     /**
00055      * Data provider for parseAddressesTest
00056      *
00057      * @return array Data sets
00058      */
00059     public static function parseAddressesProvider() {
00060         return array(
00061             'name &ltemail&gt;' => array('name <email@example.org>', array('email@example.org' => 'name')),
00062             '&lt;email&gt;' => array('<email@example.org>', array('email@example.org')),
00063             'email' => array('email@example.org', array('email@example.org')),
00064             'email1,email2' => array('email1@example.org,email2@example.com', array('email1@example.org', 'email2@example.com')),
00065             'name &ltemail&gt;,email2' => array('name <email1@example.org>,email2@example.com', array('email1@example.org' => 'name', 'email2@example.com')),
00066             '"last, first" &lt;name@example.org&gt;' => array('"last, first" <email@example.org>', array('email@example.org' => '"last, first"')),
00067             'email,name &ltemail&gt;,"last, first" &lt;name@example.org&gt;' =>
00068                 array(
00069                     'email1@example.org, name <email2@example.org>, "last, first" <email3@example.org>',
00070                 array(
00071                     'email1@example.org',
00072                     'email2@example.org' => 'name',
00073                     'email3@example.org' => '"last, first"',
00074                 )
00075             ),
00076         );
00077     }
00078 
00079     /**
00080      * @test
00081      * @dataProvider parseAddressesProvider
00082      */
00083     public function parseAddressesTest($source, $addressList) {
00084         $this->assertEquals(
00085             $addressList,
00086             $this->fixture->parseAddressesExposed($source)
00087         );
00088     }
00089 }
00090 ?>