2018-04-03 13:21:47 +02:00
|
|
|
<?php
|
2018-04-18 16:16:22 +02:00
|
|
|
|
2018-04-03 13:21:47 +02:00
|
|
|
namespace Framadate\Services;
|
|
|
|
|
|
|
|
use Framadate\FramaTestCase;
|
|
|
|
|
2018-04-03 14:09:18 +02:00
|
|
|
class InputServiceUnitTest extends FramaTestCase
|
|
|
|
{
|
2018-04-18 16:16:22 +02:00
|
|
|
public function liste_emails()
|
|
|
|
{
|
2018-04-06 09:46:30 +02:00
|
|
|
return [
|
|
|
|
// valids addresses
|
2018-04-18 16:16:22 +02:00
|
|
|
"valid address" => ["example@example.com", "example@example.com"],
|
|
|
|
"local address" => ["test@localhost", "test@localhost"],
|
|
|
|
"IP address" => ["ip.email@127.0.0.1", "ip.email@127.0.0.1"],
|
|
|
|
"with spaces arround" => [" with@spaces ", "with@spaces"],
|
|
|
|
"unicode caracters" => ["unicode.éà@idn-œ.com", "unicode.éà@idn-œ.com"],
|
2018-04-06 09:46:30 +02:00
|
|
|
// invalids addresses
|
2018-04-18 16:16:22 +02:00
|
|
|
"without domain" => ["without-domain", FALSE],
|
|
|
|
"space inside" => ["example example@example.com", FALSE],
|
|
|
|
"forbidden chars" => ["special_chars.@example.com", FALSE],
|
2018-04-06 09:46:30 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider liste_emails
|
|
|
|
*/
|
|
|
|
public function test_filterMail($email, $expected)
|
|
|
|
{
|
|
|
|
$inputService = new InputService();
|
|
|
|
$filtered = $inputService->filterMail($email);
|
2018-04-06 09:46:30 +02:00
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
$this->assertSame($expected, $filtered);
|
|
|
|
}
|
2018-04-03 13:21:47 +02:00
|
|
|
}
|