-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathIssue159Test.php
78 lines (72 loc) · 4.43 KB
/
Issue159Test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace Swaggest\JsonSchema\Tests\PHPUnit\Suite;
use Swaggest\JsonSchema\Exception\StringException;
use Swaggest\JsonSchema\InvalidValue;
use Swaggest\JsonSchema\Schema;
class Issue159Test extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider emailsProvider
*/
public function testIssue($expected, $email)
{
$schemaData = json_decode('{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Root",
"type": "string",
"format": "email"
}');
$schema = Schema::import($schemaData);
try {
$schema->in($email);
$this->assertTrue(true);
} catch (InvalidValue $e) {
$this->assertEquals('Invalid email', $e->getMessage());
$this->assertFalse($expected);
}
}
private function emailsProvider()
{
return [
[true, '[email protected]'],
[true, '[email protected]'],
[true, 'ser+mailbox/[email protected]'],
[true, '#$%&\'*+-/=?^_`.{|}[email protected]'],
[true, '"Abc@def"@example.com'],
[true, '"Fred\ Bloggs"@example.com'],
[true, '"Joe.\\Blow"@example.com'],
[false, 'коля@пример.рф'], // valid but FILTER_FLAG_EMAIL_UNICODE supports only unicode in the email address local part. See https://www.php.net/manual/en/filter.constants.php#constant.filter-flag-email-unicode
[false, '用户@例子.广告'], // valid but FILTER_FLAG_EMAIL_UNICODE supports only unicode in the email address local part. See https://www.php.net/manual/en/filter.constants.php#constant.filter-flag-email-unicode
[false, 'ಬೆಂಬಲ@ಡೇಟಾಮೇಲ್.ಭಾರತ'], // valid but FILTER_FLAG_EMAIL_UNICODE supports only unicode in the email address local part. See https://www.php.net/manual/en/filter.constants.php#constant.filter-flag-email-unicode
[false, 'अजय@डाटा.भारत'], // valid but FILTER_FLAG_EMAIL_UNICODE supports only unicode in the email address local part. See https://www.php.net/manual/en/filter.constants.php#constant.filter-flag-email-unicode
[false, 'квіточка@пошта.укр'], // valid but FILTER_FLAG_EMAIL_UNICODE supports only unicode in the email address local part. See https://www.php.net/manual/en/filter.constants.php#constant.filter-flag-email-unicode
[false, 'χρήστης@παράδειγμα.ελ'], // valid but FILTER_FLAG_EMAIL_UNICODE supports only unicode in the email address local part. See https://www.php.net/manual/en/filter.constants.php#constant.filter-flag-email-unicode
[false, 'Dörte@Sörensen.example.com'], // valid but FILTER_FLAG_EMAIL_UNICODE supports only unicode in the email address local part. See https://www.php.net/manual/en/filter.constants.php#constant.filter-flag-email-unicode
[true, 'коля@example.com'],
[true, '用户@example.com'],
[false, 'ಬೆಂಬಲ@example.com'], // valid and should be supported but it's not.
[true, 'अजय@example.com'],
[true, 'квіточка@example.com'],
[true, 'χρήστης@example.com'],
[true, 'Dö[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, 'name/[email protected]'],
[false, 'admin@example'], // local domain name with no TLD, although ICANN highly discourages dotless email addresses. See https://en.wikipedia.org/wiki/Email_address#cite_note-29)
[true, '[email protected]'],
[false, '" "@example.org'], // valid. See https://en.wikipedia.org/wiki/Email_address#Internationalization
[true, '"john..doe"@example.org'],
[true, '[email protected]'],
[true, '"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com'],
[true, 'user%[email protected]'],
[true, '[email protected]'],
[true, 'postmaster@[123.123.123.123]'],
[true, 'postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]'],
[true, '_test@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]'],
];
}
}