/** * @dataProvider providerForStringify */ public function testSettingExceptionParamsMakesThemAvailable($input, $expected) { $x = new ValidationException; $x->setParam('foo', $input); $this->assertEquals( $expected, $x->getParam('foo') ); }
/** * Test that ValidationException can be created with both a ValidationResult * and a custom message */ public function testCreateWithComplexValidationResultAndMessage() { $result = new ValidationResult(); $result->error('A spork is not a knife')->error('A knife is not a back scratcher'); $exception = new ValidationException($result, 'An error has occurred', E_USER_WARNING); $this->assertEquals(E_USER_WARNING, $exception->getCode()); $this->assertEquals('An error has occurred', $exception->getMessage()); $this->assertEquals(false, $exception->getResult()->valid()); $this->assertEquals('A spork is not a knife; A knife is not a back scratcher', $exception->getResult()->message()); }
function __construct($field = null) { $this->field = $field; $message = 'A validation Exception occurred'; if ($field) { $message .= ' with ' . $field; } parent::__construct($message); }
/** * Constructor. * * @param string $check name of check that failed * @param mixed $value the value that isn't valid * @param string $message optional custom message * @param array $options */ public function __construct($check, $value, $message = null) { $this->check = $check; $this->value = $value; if (is_null($message)) { $message = "The validation check '{$check}' failed for value " . $this->getValueSimple(); } parent::__construct($message); }
public function configure($name, array $params = []) { if ($params['networkRange']) { $range = $params['networkRange']; $message = $range['min']; if (isset($range['max'])) { $message .= '-' . $range['max']; } else { $message .= '/' . long2ip((int) $range['mask']); } $params['range'] = $message; } return parent::configure($name, $params); }
public function testValidationExceptionContext() { $e = new ValidationException(); $e->setContext("test"); $this->assertEquals("test", $e->getContext()); }
public function configure($name, array $params = array()) { $params['format'] = date($params['format'], strtotime('2005-12-30 01:02:03')); return parent::configure($name, $params); }
public function __construct($paramName, $code = null, $previous = null) { parent::__construct(sprintf($this->msg, $paramName), $code, $previous); }
/** * Generate a response object for a form validation error * * @param Form $form The source form * @param ValidationException $e The validation error message * @return SS_HTTPResponse * @throws SS_HTTPResponse_Exception */ protected function generateValidationResponse($form, $e) { $controller = $this->getToplevelController(); $form->sessionMessage($e->getResult()->message(), 'bad', false); $responseNegotiator = new PjaxResponseNegotiator(array('CurrentForm' => function () use(&$form) { return $form->forTemplate(); }, 'default' => function () use(&$controller) { return $controller->redirectBack(); })); if ($controller->getRequest()->isAjax()) { $controller->getRequest()->addHeader('X-Pjax', 'CurrentForm'); } return $responseNegotiator->respond($controller->getRequest()); }
public function __construct(array $violations) { $this->violations = $violations; parent::__construct('Input validation failed', 400); }
public function __construct() { parent::__construct('The product was not found', 0, null); }
public function __construct($name, $value) { parent::__construct('Validation of value "' . $value . '" for argument "' . $name . '" is not numerical.'); }
public function __construct() { parent::__construct('The coupon was already added', 0, null); }
public function __construct($has, $expected) { parent::__construct('Expected type was "' . $expected . '", but type was "' . $has . '".'); }
/** * @dataProvider providerForStringify */ public function test_setting_exception_params_makes_them_available($input, $expected) { $x = new ValidationException(); $x->setParam('foo', $input); $this->assertEquals($expected, $x->getParam('foo')); }
/** * Constructor for ValidationException where the exception will appear * as "Validation failed for [$trigger] with value [$value]: $message". * * @param string $trigger the trigger for the validation error * @param string $value the value for the trigger * @param string $message the message representing the error in validation */ public function __construct($trigger, $value, $message) { $this->trigger = $trigger; parent::__construct($trigger, $value, $message); }
/** * Create a new ValidationException. * * @param string $userMessage The message displayed to the user * @param string $logMessage the message logged * * @return does not return a value. */ public function __construct($userMessage = '', $logMessage = '') { parent::__construct($userMessage, $logMessage); }
public function configure($name, array $params = array()) { $params['minValue'] = static::stringify($params['minValue']); $params['maxValue'] = static::stringify($params['maxValue']); return parent::configure($name, $params); }
public function __construct() { parent::__construct('The coupon was not found', 0, null); }