summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-11 21:08:37 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-11 21:08:37 -0500
commitf7e8bb8fa83fb7ef2be12cad3f4627f91f09cfb2 (patch)
treea66239ab944463c66f215de6bdae5c271a6ab2b3 /tests
parentcec8491acd07520ec1c83a8747b631e2d809d96b (diff)
Move user validator methods
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Model/UserTest.php32
-rw-r--r--tests/units/Validator/UserValidatorTest.php41
2 files changed, 41 insertions, 32 deletions
diff --git a/tests/units/Model/UserTest.php b/tests/units/Model/UserTest.php
index 1d381006..0987fa56 100644
--- a/tests/units/Model/UserTest.php
+++ b/tests/units/Model/UserTest.php
@@ -391,36 +391,4 @@ class UserTest extends Base
$this->assertEquals('toto', $user['username']);
$this->assertEmpty($user['token']);
}
-
- public function testValidatePasswordModification()
- {
- $u = new User($this->container);
-
- $this->container['sessionStorage']->user = array(
- 'id' => 1,
- 'role' => Role::APP_ADMIN,
- 'username' => 'admin',
- );
-
- $result = $u->validatePasswordModification(array());
- $this->assertFalse($result[0]);
-
- $result = $u->validatePasswordModification(array('id' => 1));
- $this->assertFalse($result[0]);
-
- $result = $u->validatePasswordModification(array('id' => 1, 'password' => '123456'));
- $this->assertFalse($result[0]);
-
- $result = $u->validatePasswordModification(array('id' => 1, 'password' => '123456', 'confirmation' => 'wrong'));
- $this->assertFalse($result[0]);
-
- $result = $u->validatePasswordModification(array('id' => 1, 'password' => '123456', 'confirmation' => '123456'));
- $this->assertFalse($result[0]);
-
- $result = $u->validatePasswordModification(array('id' => 1, 'password' => '123456', 'confirmation' => '123456', 'current_password' => 'wrong'));
- $this->assertFalse($result[0]);
-
- $result = $u->validatePasswordModification(array('id' => 1, 'password' => '123456', 'confirmation' => '123456', 'current_password' => 'admin'));
- $this->assertTrue($result[0]);
- }
}
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]);
+ }
+}