summaryrefslogtreecommitdiff
path: root/tests/units/UserTest.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-20 14:49:31 +0200
committerFrédéric Guillot <fred@kanboard.net>2014-09-20 14:49:31 +0200
commit41e796c52aa693d13636b54efe15705eaec27f3f (patch)
treebc670e457e98c1d8a9ac8e2b82bf8e2c424af328 /tests/units/UserTest.php
parent00cdc609d113fedf977da1d55136dc4d699fb308 (diff)
Models refactoring/improvements
Diffstat (limited to 'tests/units/UserTest.php')
-rw-r--r--tests/units/UserTest.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/units/UserTest.php b/tests/units/UserTest.php
index cc0b7c44..9a304e85 100644
--- a/tests/units/UserTest.php
+++ b/tests/units/UserTest.php
@@ -8,6 +8,57 @@ use Model\Project;
class UserTest extends Base
{
+ public function testPrepare()
+ {
+ $u = new User($this->registry);
+
+ $input = array(
+ 'username' => 'user1',
+ 'password' => '1234',
+ 'confirmation' => '1234',
+ 'name' => 'me',
+ 'is_admin' => '',
+ );
+
+ $u->prepare($input);
+ $this->assertArrayNotHasKey('confirmation', $input);
+
+ $this->assertArrayHasKey('password', $input);
+ $this->assertNotEquals('1234', $input['password']);
+ $this->assertNotEmpty($input['password']);
+
+ $this->assertArrayHasKey('is_admin', $input);
+ $this->assertInternalType('integer', $input['is_admin']);
+
+ $input = array(
+ 'username' => 'user1',
+ 'password' => '1234',
+ 'current_password' => 'bla',
+ 'confirmation' => '1234',
+ 'name' => 'me',
+ 'is_ldap_user' => '1',
+ );
+
+ $u->prepare($input);
+ $this->assertArrayNotHasKey('confirmation', $input);
+ $this->assertArrayNotHasKey('current_password', $input);
+
+ $this->assertArrayHasKey('password', $input);
+ $this->assertNotEquals('1234', $input['password']);
+ $this->assertNotEmpty($input['password']);
+
+ $this->assertArrayHasKey('is_ldap_user', $input);
+ $this->assertEquals(1, $input['is_ldap_user']);
+
+ $input = array(
+ 'id' => 2,
+ 'name' => 'me',
+ );
+
+ $u->prepare($input);
+ $this->assertEquals(array('id' => 2, 'name' => 'me'), $input);
+ }
+
public function testCreate()
{
$u = new User($this->registry);