TYPO3 CMS  TYPO3_7-6
MailPostProcessorTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $mailPostProcessor;
26 
32  protected function setUp()
33  {
34  parent::setUp();
35  $this->mailPostProcessor = $this->getAccessibleMock(
36  \TYPO3\CMS\Form\PostProcess\MailPostProcessor::class,
37  ['__none'],
38  [],
39  '',
40  false
41  );
42  }
43 
50  public function filterValidEmailsProvider()
51  {
52  return [
53  'empty string' => [
54  '',
55  [],
56  ],
57  'string not representing an email' => [
58  'notAnAddress',
59  [],
60  ],
61  'simple single valid address' => [
62  'someone@example.com',
63  [
64  'someone@example.com',
65  ],
66  ],
67  'multiple valid simple addresses' => [
68  'someone@example.com, foo@bar.com',
69  [
70  'someone@example.com',
71  'foo@bar.com',
72  ],
73  ],
74  'multiple addresses with personal part' => [
75  'Foo <foo@example.com>, <bar@example.com>, "Foo, bar" <foo.bar@example.com>',
76  [
77  'bar@example.com',
78  'foo@example.com' => 'Foo',
79  'foo.bar@example.com' => '"Foo, bar"',
80  ],
81  ],
82  'list with invalid addresses is filtered' => [
83  'invalid, @invalid, someone@example.com',
84  [
85  'someone@example.com',
86  ],
87  ],
88  ];
89  }
90 
95  public function filterValidEmailsReturnsOnlyValidAddresses($input, $expected)
96  {
97  $actualResult = $this->mailPostProcessor->_call('filterValidEmails', $input);
98  $this->assertEquals($expected, $actualResult);
99  }
100 }
filterValidEmailsReturnsOnlyValidAddresses($input, $expected)
$mailPostProcessor
filterValidEmailsProvider()
setUp()
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)