Exemplo n.º 1
0
Arquivo: email.php Projeto: extend/wee
try {
    $o->setValue('*****@*****.**');
} catch (DomainException $e) {
    $this->fail(_WT('weeEmailValidator should not throw a DomainException when the value is a string.'));
}
try {
    $o->setValue(new weeDummyPrintable('*****@*****.**'));
} catch (DomainException $e) {
    $this->fail(_WT('weeEmailValidator should not throw a DomainException when the value is an instance of Printable.'));
}
try {
    $o->setValue(new CastableInput_testEmailValidator());
} catch (DomainException $e) {
    $this->fail(_WT('weeEmailValidator should not throw a DomainException when the value is an object castable to string.'));
}
// Valid
$this->isTrue(weeEmailValidator::test('*****@*****.**'), _WT('weeEmailValidator fails to validate "*****@*****.**".'));
$this->isTrue(weeEmailValidator::test('*****@*****.**'), _WT('weeEmailValidator fails to validate "*****@*****.**".'));
// Invalid
$this->isFalse(weeEmailValidator::test(''), _WT('weeEmailValidator returns true for the empty string.'));
$this->isFalse(weeEmailValidator::test('example'), _WT('weeEmailValidator returns true for "example".'));
$this->isFalse(weeEmailValidator::test('example.com'), _WT('weeEmailValidator returns true for "example.com".'));
$this->isFalse(weeEmailValidator::test('@example.com'), _WT('weeEmailValidator returns true for "@example.com".'));
$this->isFalse(weeEmailValidator::test('test@example'), _WT('weeEmailValidator returns true for "test@example".'));
$this->isFalse(weeEmailValidator::test('test.test@example'), _WT('weeEmailValidator returns true for "test.test@example".'));
$this->isFalse(weeEmailValidator::test('test@@example.com'), _WT('weeEmailValidator returns true for "test@@example.com".'));
$this->isFalse(weeEmailValidator::test('test@test@example.com'), _WT('weeEmailValidator returns true for "test@test@example.com".'));
// Objects
$this->isTrue(weeEmailValidator::test(new weeDummyPrintable('*****@*****.**')), _WT('weeEmailValidator::test should return true when the value is an instance of Printable which returns a valid number.'));
$this->isTrue(weeEmailValidator::test(new CastableInput_testEmailValidator()), _WT('weeEmailValidator::test should return true when the value is an object castable to string which casts to a valid number.'));