diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-11 21:08:37 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-11 21:08:37 -0500 |
commit | f7e8bb8fa83fb7ef2be12cad3f4627f91f09cfb2 (patch) | |
tree | a66239ab944463c66f215de6bdae5c271a6ab2b3 /tests/units/Validator | |
parent | cec8491acd07520ec1c83a8747b631e2d809d96b (diff) |
Move user validator methods
Diffstat (limited to 'tests/units/Validator')
-rw-r--r-- | tests/units/Validator/UserValidatorTest.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/units/Validator/UserValidatorTest.php b/tests/units/Validator/UserValidatorTest.php new file mode 100644 index 00000000..6d904ade --- /dev/null +++ b/tests/units/Validator/UserValidatorTest.php @@ -0,0 +1,41 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\Validator\UserValidator; +use Kanboard\Core\Security\Role; + +class UserValidatorTest extends Base +{ + public function testValidatePasswordModification() + { + $validator = new UserValidator($this->container); + + $this->container['sessionStorage']->user = array( + 'id' => 1, + 'role' => Role::APP_ADMIN, + 'username' => 'admin', + ); + + $result = $validator->validatePasswordModification(array()); + $this->assertFalse($result[0]); + + $result = $validator->validatePasswordModification(array('id' => 1)); + $this->assertFalse($result[0]); + + $result = $validator->validatePasswordModification(array('id' => 1, 'password' => '123456')); + $this->assertFalse($result[0]); + + $result = $validator->validatePasswordModification(array('id' => 1, 'password' => '123456', 'confirmation' => 'wrong')); + $this->assertFalse($result[0]); + + $result = $validator->validatePasswordModification(array('id' => 1, 'password' => '123456', 'confirmation' => '123456')); + $this->assertFalse($result[0]); + + $result = $validator->validatePasswordModification(array('id' => 1, 'password' => '123456', 'confirmation' => '123456', 'current_password' => 'wrong')); + $this->assertFalse($result[0]); + + $result = $validator->validatePasswordModification(array('id' => 1, 'password' => '123456', 'confirmation' => '123456', 'current_password' => 'admin')); + $this->assertTrue($result[0]); + } +} |