/** * * @expectedException Application\Exceptions\ValidateException */ public function testLastUsedPasswordsMaxReached() { // User should be a service provider $user = clone $this->_user; $user->id = null; $user->setOrganizationId(self::PROVIDER_COMMERCIAL_ORG_ID); $user->save(); // Update password N times $limit = \app::config('lastUsedPasswordsLimit'); $loops = $limit + 5; for ($i = 0; $i < $loops; $i++) { $lastPassword = '******' . rand(1000, 9999); $user = $this->_service->updatePassword($user, $lastPassword); $lastUsedPasswords = $this->_service->getLastUsedPasswords($user->id); $this->assertNotEmpty($lastUsedPasswords); } $this->assertEquals(count($lastUsedPasswords), $limit); // Try to insert an existent password in a list $this->_service->updatePassword($user, $lastPassword); }