public function testFieldValidation() { $userInfo = $this->getUserInfo(); $userInfo['Username'] = md5(time()); $success = $this->user->register($userInfo); $this->assertEquals($success, !$this->user->log->hasError()); $this->assertFalse($success); $userInfo['Username'] = '******'; $success = $this->user->register($userInfo); $this->assertEquals($success, !$this->user->log->hasError()); $this->assertFalse($success); $userInfo['Username'] = '******'; $success = $this->user->register($userInfo); $this->assertEquals($success, !$this->user->log->hasError()); $this->assertFalse($success); $this->user->addValidation('Username', '2-15'); $success = $this->user->register($userInfo); $this->assertEquals($success, !$this->user->log->hasError()); $this->assertTrue($success); $this->assertEquals(array(), $this->user->log->getErrors()); }
public function testValidations() { $user = new User(array('Username' => 'Pablo', 'Password' => 'password', 'RegDate' => 1396148789)); $user->Username = '******'; $user->addValidation('Username', '1-5'); $this->assertFalse($user->log->hasError()); }