Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2485301
ExternalEmailTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ExternalEmailTest.php
View Options
<?php
namespace
Tests\Unit\Rules
;
use
App\Rules\ExternalEmail
;
use
Illuminate\Support\Facades\Validator
;
use
Tests\TestCase
;
class
ExternalEmailTest
extends
TestCase
{
/**
* List of email address validation cases for testExternalEmail()
*
* @return array Arguments for testExternalEmail()
*/
public
function
dataExternalEmail
():
array
{
return
[
// invalid
[
'example.org'
,
'The specified email address is invalid.'
],
[
'@example.org'
,
'The specified email address is invalid.'
],
[
'test@localhost'
,
'The specified email address is invalid.'
],
// FIXME: empty - valid ??????
[
''
,
null
],
// valid
[
'test@domain.tld'
,
null
],
[
'&@example.org'
,
null
],
];
}
/**
* Test external email validation
*
* @dataProvider dataExternalEmail
*/
public
function
testExternalEmail
(
$email
,
$expected_result
):
void
{
// Instead of doing direct tests, we use validator to make sure
// it works with the framework api
$v
=
Validator
::
make
(
[
'email'
=>
$email
],
[
'email'
=>
[
new
ExternalEmail
()]]
);
$result
=
null
;
if
(
$v
->
fails
())
{
$result
=
$v
->
errors
()->
toArray
()[
'email'
][
0
];
}
$this
->
assertSame
(
$expected_result
,
$result
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 3:35 PM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
387508
Default Alt Text
ExternalEmailTest.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment