public function testValidateMinScore() { $v = new PasswordValidator(); $v->characterStrength(3, array("lowercase", "uppercase", "digits", "punctuation")); $r = $v->validate('aA', new Member()); $this->assertFalse($r->valid(), 'Passing too few tests'); $r = $v->validate('aA1', new Member()); $this->assertTrue($r->valid(), 'Passing enough tests'); }
/** * Validate this member object. */ public function validate() { $valid = parent::validate(); if (!$this->ID || $this->isChanged('Password')) { if ($this->Password && self::$password_validator) { $valid->combineAnd(self::$password_validator->validate($this->Password, $this)); } } if (!$this->ID && $this->SetPassword || $this->isChanged('SetPassword')) { if ($this->SetPassword && self::$password_validator) { $valid->combineAnd(self::$password_validator->validate($this->SetPassword, $this)); } } return $valid; }
public function __construct() { parent::__construct(); $this->minLength(7); $this->checkHistoricalPasswords(6); $this->characterStrength(3, array('lowercase', 'uppercase', 'digits', 'punctuation')); }