From f7e8bb8fa83fb7ef2be12cad3f4627f91f09cfb2 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 11 Jan 2016 21:08:37 -0500 Subject: Move user validator methods --- tests/units/Model/UserTest.php | 32 ---------------------- tests/units/Validator/UserValidatorTest.php | 41 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 tests/units/Validator/UserValidatorTest.php (limited to 'tests') 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 @@ +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]); + } +} -- cgit v1.2.3