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