2018-04-03 13:21:47 +02:00
|
|
|
<?php
|
|
|
|
namespace Framadate\Services;
|
|
|
|
|
|
|
|
use Framadate\FramaTestCase;
|
|
|
|
|
2018-04-03 14:09:18 +02:00
|
|
|
class InputServiceUnitTest extends FramaTestCase
|
|
|
|
{
|
2018-04-06 09:46:30 +02:00
|
|
|
public function liste_emails() {
|
|
|
|
return [
|
|
|
|
// valids addresses
|
|
|
|
"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"],
|
|
|
|
// invalids addresses
|
|
|
|
"without domain" => ["without-domain", FALSE],
|
|
|
|
"space inside" => ["example example@example.com", FALSE],
|
|
|
|
"forbidden chars" => ["special_chars.@example.com", FALSE],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-04-03 20:07:49 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider liste_emails
|
|
|
|
*/
|
2018-04-06 09:46:30 +02:00
|
|
|
public function test_filterMail($email, $expected) {
|
2018-04-03 20:07:49 +02:00
|
|
|
$inputService = new InputService();
|
|
|
|
$filtered = $inputService->filterMail($email);
|
2018-04-06 09:46:30 +02:00
|
|
|
|
2018-04-03 20:07:49 +02:00
|
|
|
$this->assertSame($expected, $filtered);
|
|
|
|
}
|
2018-04-03 13:21:47 +02:00
|
|
|
}
|