Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
45d92f1c
Commit
45d92f1c
authored
Nov 20, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored emailvalidator test
parent
7b5b93ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
24 deletions
+13
-24
EmailValidatorTest.php
tests/unit/framework/validators/EmailValidatorTest.php
+13
-24
No files found.
tests/unit/framework/validators/EmailValidatorTest.php
View file @
45d92f1c
...
@@ -41,17 +41,23 @@ class EmailValidatorTest extends TestCase
...
@@ -41,17 +41,23 @@ class EmailValidatorTest extends TestCase
$this
->
assertFalse
(
$validator
->
validateValue
(
'info@örtliches.de'
));
$this
->
assertFalse
(
$validator
->
validateValue
(
'info@örtliches.de'
));
$this
->
assertFalse
(
$validator
->
validateValue
(
'sam@рмкреатиф.ru'
));
$this
->
assertFalse
(
$validator
->
validateValue
(
'sam@рмкреатиф.ru'
));
$this
->
assertFalse
(
$validator
->
validateValue
(
'Informtation info@oertliches.de'
));
$this
->
assertFalse
(
$validator
->
validateValue
(
'Informtation info@oertliches.de'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'test@example.com'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'John Smith <john.smith@example.com>'
));
$this
->
assertFalse
(
$validator
->
validateValue
(
'John Smith <example.com>'
));
}
}
public
function
testValidate
IdnValue
()
public
function
testValidate
ValueIdn
()
{
{
if
(
!
extension_loaded
(
"intl"
))
{
if
(
!
function_exists
(
'idn_to_ascii'
))
{
$this
->
markTestSkipped
(
"intl not installed. Skipping."
);
$this
->
markTestSkipped
(
'Intl extension required'
);
return
;
}
}
$validator
=
new
EmailValidator
();
$validator
=
new
EmailValidator
();
$validator
->
enableIDN
=
true
;
$validator
->
enableIDN
=
true
;
$this
->
assertTrue
(
$validator
->
validateValue
(
'5011@example.com'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'example@äüößìà.de'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'example@xn--zcack7ayc9a.de'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'info@örtliches.de'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'info@örtliches.de'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'sam@рмкреатиф.ru'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'sam@рмкреатиф.ru'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'sam@rmcreative.ru'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'sam@rmcreative.ru'
));
...
@@ -73,6 +79,9 @@ class EmailValidatorTest extends TestCase
...
@@ -73,6 +79,9 @@ class EmailValidatorTest extends TestCase
$this
->
assertTrue
(
$validator
->
validateValue
(
'Carsten Brandt <mail@cebe.cc>'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'Carsten Brandt <mail@cebe.cc>'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'"Carsten Brandt" <mail@cebe.cc>'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'"Carsten Brandt" <mail@cebe.cc>'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'<mail@cebe.cc>'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'<mail@cebe.cc>'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'test@example.com'
));
$this
->
assertTrue
(
$validator
->
validateValue
(
'John Smith <john.smith@example.com>'
));
$this
->
assertFalse
(
$validator
->
validateValue
(
'John Smith <example.com>'
));
}
}
public
function
testValidateValueMx
()
public
function
testValidateValueMx
()
...
@@ -96,24 +105,4 @@ class EmailValidatorTest extends TestCase
...
@@ -96,24 +105,4 @@ class EmailValidatorTest extends TestCase
$val
->
validateAttribute
(
$model
,
'attr_email'
);
$val
->
validateAttribute
(
$model
,
'attr_email'
);
$this
->
assertFalse
(
$model
->
hasErrors
(
'attr_email'
));
$this
->
assertFalse
(
$model
->
hasErrors
(
'attr_email'
));
}
}
public
function
testValidateValueIdn
()
{
if
(
!
function_exists
(
'idn_to_ascii'
))
{
$this
->
markTestSkipped
(
'Intl extension required'
);
return
;
}
$val
=
new
EmailValidator
([
'enableIDN'
=>
true
]);
$this
->
assertTrue
(
$val
->
validateValue
(
'5011@example.com'
));
$this
->
assertTrue
(
$val
->
validateValue
(
'example@äüößìà.de'
));
$this
->
assertTrue
(
$val
->
validateValue
(
'example@xn--zcack7ayc9a.de'
));
}
public
function
testValidateValueWithName
()
{
$val
=
new
EmailValidator
([
'allowName'
=>
true
]);
$this
->
assertTrue
(
$val
->
validateValue
(
'test@example.com'
));
$this
->
assertTrue
(
$val
->
validateValue
(
'John Smith <john.smith@example.com>'
));
$this
->
assertFalse
(
$val
->
validateValue
(
'John Smith <example.com>'
));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment