/** * Ensures that the getError() function returns an array of * message key values corresponding to the messages. * * @return void */ public function testGetErrors() { $this->assertFalse($this->_validator->isValid('abcdefghij')); $messages = $this->_validator->getMessages(); $this->assertEquals("'abcdefghij' is greater than 8 characters long", $messages[0]); $errors = $this->_validator->getErrors(); $this->assertEquals(Zend_Validate_StringLength::TOO_LONG, $errors[0]); }
/** * Ensures that the getError() function returns an array of * message key values corresponding to the messages. * * @return void */ public function testGetErrors() { $inputInvalid = 'abcdefghij'; $this->assertFalse($this->_validator->isValid($inputInvalid)); $messages = $this->_validator->getMessages(); $this->assertEquals("'{$inputInvalid}' is more than 8 characters long", current($messages)); $errors = $this->_validator->getErrors(); $this->assertEquals(Zend_Validate_StringLength::TOO_LONG, current($errors)); }
/** * Validate "syntax" of this field * * @throws Setup_Exception_InvalidSchema if {@param $throwException} is set to true * * @param $throwException * @return bool */ public function isValid($throwException = false) { $isValid = true; $messages = array(); $nameValidator = new Zend_Validate_StringLength(1, 30); if (!$nameValidator->isValid($this->name)) { $isValid = false; $messages = array_merge($messages, $nameValidator->getErrors()); } if (!$isValid) { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Invalid schema specified for field ' . $this->name . ': ' . print_r($messages, 1)); if ($throwException) { throw new Setup_Exception_InvalidSchema('Invalid schema specified for field ' . $this->name . ': ' . print_r($messages, 1)); } } return $isValid; }