29 lines
1.5 KiB
PHP
29 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace com\fwdekker\deathnotifier\validation;
|
|
|
|
|
|
/**
|
|
* Unit tests for {@see IsEmailRule}.
|
|
*/
|
|
class IsEmailRuleTest extends RuleTestTemplate
|
|
{
|
|
public static function check_provider(): array
|
|
{
|
|
$type = InvalidTypeException::class;
|
|
$value = InvalidValueException::class;
|
|
|
|
return [
|
|
"exception if input is not set" => [new IsEmailRule(), null, $type, "Required input 'key' not set."],
|
|
"exception if input is not a string" => [new IsEmailRule(), 491, $type, "Input 'key' should be string, but is integer."],
|
|
"exception if input starts with space" => [new IsEmailRule(), " valid@example.com", $value, "Remove the spaces at the start."],
|
|
"exception if input ends with space" => [new IsEmailRule(), "valid@example.com ", $value, "Remove the spaces at the end."],
|
|
"exception if input is empty" => [new IsEmailRule(), "", $value, "Enter an email address."],
|
|
"exception if input misses the '@' symbol" => [new IsEmailRule(), "invalid", $value, "Don't forget to add an '@' symbol."],
|
|
"exception if input misses the domain part" => [new IsEmailRule(), "invalid@", $value, "Add a domain name after the '@'."],
|
|
"exception if input is invalid in a complex way" => [new IsEmailRule(), "invalid@example", $value, "Enter a valid email address."],
|
|
"no exception if input is email" => [new IsEmailRule(), "valid@example.com", null, null],
|
|
];
|
|
}
|
|
}
|