From 26e3996014936268f4acbfa214fa881af9320ddd Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 9 Jan 2016 17:28:31 -0500 Subject: Add forgot password feature --- .../units/Validator/PasswordResetValidatorTest.php | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/units/Validator/PasswordResetValidatorTest.php (limited to 'tests/units/Validator/PasswordResetValidatorTest.php') diff --git a/tests/units/Validator/PasswordResetValidatorTest.php b/tests/units/Validator/PasswordResetValidatorTest.php new file mode 100644 index 00000000..4af6c75e --- /dev/null +++ b/tests/units/Validator/PasswordResetValidatorTest.php @@ -0,0 +1,64 @@ +container); + list($valid, ) = $validator->validateModification(array('password' => 'test123', 'confirmation' => 'test123')); + $this->assertTrue($valid); + } + + public function testValidateModificationWithWrongPasswords() + { + $validator = new PasswordResetValidator($this->container); + list($valid, ) = $validator->validateModification(array('password' => 'test123', 'confirmation' => 'test456')); + $this->assertFalse($valid); + } + + public function testValidateModificationWithPasswordTooShort() + { + $validator = new PasswordResetValidator($this->container); + list($valid, ) = $validator->validateModification(array('password' => 'test', 'confirmation' => 'test')); + $this->assertFalse($valid); + } + + public function testValidateCreation() + { + $this->container['sessionStorage']->captcha = 'test'; + + $validator = new PasswordResetValidator($this->container); + list($valid,) = $validator->validateCreation(array('username' => 'foobar', 'captcha' => 'test')); + $this->assertTrue($valid); + } + + public function testValidateCreationWithNoUsername() + { + $this->container['sessionStorage']->captcha = 'test'; + + $validator = new PasswordResetValidator($this->container); + list($valid,) = $validator->validateCreation(array('captcha' => 'test')); + $this->assertFalse($valid); + } + + public function testValidateCreationWithWrongCaptcha() + { + $this->container['sessionStorage']->captcha = 'test123'; + + $validator = new PasswordResetValidator($this->container); + list($valid,) = $validator->validateCreation(array('username' => 'foobar', 'captcha' => 'test')); + $this->assertFalse($valid); + } + + public function testValidateCreationWithMissingCaptcha() + { + $validator = new PasswordResetValidator($this->container); + list($valid,) = $validator->validateCreation(array('username' => 'foobar', 'captcha' => 'test')); + $this->assertFalse($valid); + } +} -- cgit v1.2.3