1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2014-2016 Ryan Parman. |
4
|
|
|
* |
5
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
6
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
7
|
|
|
* in the Software without restriction, including without limitation the rights |
8
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
10
|
|
|
* furnished to do so, subject to the following conditions: |
11
|
|
|
* |
12
|
|
|
* The above copyright notice and this permission notice shall be included in |
13
|
|
|
* all copies or substantial portions of the Software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21
|
|
|
* THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
* http://opensource.org/licenses/MIT |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
namespace Skyzyx\Tests\StrongTypes\StringType; |
27
|
|
|
|
28
|
|
|
use Skyzyx\StrongTypes\StringType\Email; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @see http://codefool.tumblr.com/post/15288874550/list-of-valid-and-invalid-email-addresses |
32
|
|
|
* @see https://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/EmailTest.java?view=markup |
|
|
|
|
33
|
|
|
*/ |
34
|
|
|
class EmailValidTest extends \PHPUnit_Framework_TestCase |
35
|
|
|
{ |
36
|
|
|
public function listEmails() |
37
|
|
|
{ |
38
|
|
|
return [ |
39
|
|
|
["*@example.net"], |
|
|
|
|
40
|
|
|
["[email protected]"], |
|
|
|
|
41
|
|
|
["[email protected]"], |
|
|
|
|
42
|
|
|
["[email protected]"], |
|
|
|
|
43
|
|
|
["[email protected]"], |
|
|
|
|
44
|
|
|
["[email protected]"], |
|
|
|
|
45
|
|
|
["andy.o'[email protected]"], |
46
|
|
|
["[email protected]"], |
|
|
|
|
47
|
|
|
["[email protected]"], |
|
|
|
|
48
|
|
|
["fred&[email protected]"], |
|
|
|
|
49
|
|
|
["[email protected]"], |
|
|
|
|
50
|
|
|
["joe%[email protected]"], |
|
|
|
|
51
|
|
|
["joe&@apache.org"], |
|
|
|
|
52
|
|
|
["joe'@apache.org"], |
53
|
|
|
["joe*@apache.org"], |
|
|
|
|
54
|
|
|
["[email protected]"], |
|
|
|
|
55
|
|
|
["[email protected]"], |
|
|
|
|
56
|
|
|
["[email protected]"], |
|
|
|
|
57
|
|
|
["joe\[email protected]"], |
|
|
|
|
58
|
|
|
["[email protected]"], |
|
|
|
|
59
|
|
|
["[email protected]"], |
|
|
|
|
60
|
|
|
["[email protected]"], |
|
|
|
|
61
|
|
|
["[email protected]"], |
|
|
|
|
62
|
|
|
["[email protected]"], |
|
|
|
|
63
|
|
|
["[email protected]"], |
|
|
|
|
64
|
|
|
["[email protected]"], |
|
|
|
|
65
|
|
|
["[email protected]"], |
|
|
|
|
66
|
|
|
["[email protected]"], |
|
|
|
|
67
|
|
|
["[email protected]"], |
|
|
|
|
68
|
|
|
['!def!xyz%[email protected]'], |
69
|
|
|
['!def!xyz%[email protected]'], |
70
|
|
|
['[email protected]'], |
71
|
|
|
['[email protected]'], |
72
|
|
|
['[email protected]'], |
73
|
|
|
['[email protected]'], |
74
|
|
|
['[email protected]'], |
75
|
|
|
['[email protected]'], |
76
|
|
|
['[email protected]'], |
77
|
|
|
['[email protected]'], |
78
|
|
|
['[email protected]'], |
79
|
|
|
['[email protected]'], |
80
|
|
|
['[email protected]'], |
81
|
|
|
['[email protected]'], |
82
|
|
|
['[email protected]'], |
83
|
|
|
['[email protected]'], |
84
|
|
|
['[email protected]'], |
85
|
|
|
['customer/[email protected]'], |
86
|
|
|
['customer/[email protected]'], |
87
|
|
|
['[email protected]'], |
88
|
|
|
['[email protected]'], |
89
|
|
|
['[email protected]'], |
90
|
|
|
['[email protected]'], |
91
|
|
|
['[email protected]'], |
92
|
|
|
['[email protected]'], |
93
|
|
|
['[email protected]'], |
94
|
|
|
['[email protected]'], |
95
|
|
|
['[email protected]'], |
96
|
|
|
['[email protected]'], |
97
|
|
|
['[email protected]'], |
98
|
|
|
['[email protected]'], |
99
|
|
|
['[email protected]'], |
100
|
|
|
['[email protected]'], |
101
|
|
|
['[email protected]'], |
102
|
|
|
['[email protected]'], |
103
|
|
|
['[email protected]'], |
104
|
|
|
['[email protected]'], |
105
|
|
|
['[email protected]'], |
106
|
|
|
['t*[email protected]'], |
107
|
|
|
['[email protected]'], |
108
|
|
|
['[email protected]'], |
109
|
|
|
['[email protected]'], |
110
|
|
|
['[email protected]'], |
111
|
|
|
['test@Bücher.ch'], |
112
|
|
|
['[email protected]'], |
113
|
|
|
['[email protected]'], |
114
|
|
|
['[email protected]'], |
115
|
|
|
['[email protected]'], |
116
|
|
|
['[email protected]'], |
117
|
|
|
['[email protected]'], |
118
|
|
|
['user%[email protected]'], |
119
|
|
|
['[email protected]'], |
120
|
|
|
['[email protected]'], |
121
|
|
|
['x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x2'], |
|
|
|
|
122
|
|
|
['{_test_}@iana.org'], |
123
|
|
|
['[email protected]'], |
124
|
|
|
['[email protected]'], |
125
|
|
|
['あいうえお@example.com'], |
126
|
|
|
]; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @dataProvider listEmails |
131
|
|
|
*/ |
132
|
|
|
public function testValidate($email) |
133
|
|
|
{ |
134
|
|
|
$this->assertTrue(true); |
135
|
|
|
new Email($email); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.