Commit ae909771 authored by Tino Goratsch's avatar Tino Goratsch

added unit tests for the EmailValidationRule and PasswordValidationRule

parent 71e660f9
......@@ -18,7 +18,9 @@ class PasswordValidationRule extends AbstractValidationRule
$password = reset($field);
$passwordConfirmation = next($field);
return $this->checkPassword($data[$password], $data[$passwordConfirmation]);
if ($password !== false && $passwordConfirmation !== false) {
return $this->checkPassword($data[$password], $data[$passwordConfirmation]);
}
}
return false;
......
<?php
class EmailValidationRuleTest extends AbstractValidationRuleTest
{
protected function setUp()
{
$this->validationRule = new \ACP3\Core\Validation\ValidationRules\EmailValidationRule();
}
/**
* @return array
*/
public function validationRuleProvider()
{
return [
'valid-data-string' => ['test@example.com', '', [], true],
'valid-data-array' => [['foo' => 'test@example.com'], 'foo', [], true],
'valid-email-with-subdomain' => ['test@subdomain.example.com', '', [], true],
'invalid-data-string' => ['foobar', '', [], false],
'invalid-data-array' => [['foo' => 'foobar'], 'foo', [], false],
'invalid-no-data' => [null, null, [], false]
];
}
}
\ No newline at end of file
<?php
class PasswordValidationRuleTest extends AbstractValidationRuleTest
{
protected function setUp()
{
$this->validationRule = new \ACP3\Core\Validation\ValidationRules\PasswordValidationRule();
}
/**
* @return array
*/
public function validationRuleProvider()
{
return [
'valid-data-array' => [['pw' => 'test1234', 'pw_confirm' => 'test1234'], ['pw', 'pw_confirm'], [], true],
'invalid-data-array' => [['pw' => 'test1234'], ['pw'], [], false],
'invalid-data-flat-array' => [['test1234'], [], [], false],
'invalid-data-string' => ['foobar', '', [], false],
'invalid-no-data' => [null, null, [], false]
];
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment