3915fb64e4692893f464115230194e6ababc1262
[Packages/TYPO3.CMS.git] / tests / Unit / t3lib / mail / class.t3lib_mail_swiftmaileradapterTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2011 Ernesto Baschny (ernst@cron-it.de)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Testcase for the t3lib_mail_SwiftMailerAdapter class.
27 *
28 * @package TYPO3
29 * @subpackage t3lib
30 *
31 * @author Ernesto Baschny <ernst@cron-it.de>
32 */
33 class t3lib_mail_SwiftMailerAdapterTest extends tx_phpunit_testcase {
34
35 public function setUp() {
36 if (!class_exists('t3lib_mail_SwiftMailerAdapterExposed')) {
37 // Make protected methods accessible so that they can be tested:
38 eval('class t3lib_mail_SwiftMailerAdapterExposed extends t3lib_mail_SwiftMailerAdapter {
39 public function parseAddressesExposed($args) {
40 return $this->parseAddresses($args);
41 }
42 }');
43 }
44 $this->fixture = new t3lib_mail_SwiftMailerAdapterExposed();
45 }
46
47 public function tearDown() {
48 }
49
50 //////////////////////////
51 // Tests concerning mail
52 //////////////////////////
53
54 /**
55 * Data provider for parseAddressesTest
56 *
57 * @return array Data sets
58 */
59 public static function parseAddressesProvider() {
60 return array(
61 'name &ltemail&gt;' => array('name <email@example.org>', array('email@example.org' => 'name')),
62 '&lt;email&gt;' => array('<email@example.org>', array('email@example.org')),
63 'email' => array('email@example.org', array('email@example.org')),
64 'email1,email2' => array('email1@example.org,email2@example.com', array('email1@example.org', 'email2@example.com')),
65 'name &ltemail&gt;,email2' => array('name <email1@example.org>,email2@example.com', array('email1@example.org' => 'name', 'email2@example.com')),
66 '"last, first" &lt;name@example.org&gt;' => array('"last, first" <email@example.org>', array('email@example.org' => '"last, first"')),
67 'email,name &ltemail&gt;,"last, first" &lt;name@example.org&gt;' =>
68 array(
69 'email1@example.org, name <email2@example.org>, "last, first" <email3@example.org>',
70 array(
71 'email1@example.org',
72 'email2@example.org' => 'name',
73 'email3@example.org' => '"last, first"',
74 )
75 ),
76 );
77 }
78
79 /**
80 * @test
81 * @dataProvider parseAddressesProvider
82 */
83 public function parseAddressesTest($source, $addressList) {
84 $this->assertEquals(
85 $addressList,
86 $this->fixture->parseAddressesExposed($source)
87 );
88 }
89 }
90 ?>