/** * {@inheritdoc} */ public function isVoteValid(ExecutionContext $context) { if (!$this->checkValue($this->value)) { $message = 'A vote cannot have a 0 value'; $propertyPath = $context->getPropertyPath() . '.value'; $context->addViolationAtPath($propertyPath, $message); } }
public function testAddViolationAtPathUsesPassedNullValue() { $this->translator->expects($this->once())->method('trans')->with('Error', array('foo' => 'bar'))->will($this->returnValue('Translated error')); $this->translator->expects($this->once())->method('transChoice')->with('Choice error', 3, array('foo' => 'bar'))->will($this->returnValue('Translated choice error')); // passed null value should override preconfigured value "invalid" set_error_handler(array($this, "deprecationErrorHandler")); $this->context->addViolationAtPath('bar.baz', 'Error', array('foo' => 'bar'), null); $this->context->addViolationAtPath('bar.baz', 'Choice error', array('foo' => 'bar'), null, 3); restore_error_handler(); $this->assertEquals(new ConstraintViolationList(array(new ConstraintViolation('Translated error', 'Error', array('foo' => 'bar'), 'Root', 'bar.baz', null), new ConstraintViolation('Translated choice error', 'Choice error', array('foo' => 'bar'), 'Root', 'bar.baz', null, 3))), $this->context->getViolations()); }
public function _validateDefaultCosId(ExecutionContext $context) { if (!is_null($this->getDefaultCosId()) && '' == trim($this->getDefaultCosId())) { $context->addViolationAtPath('defaultCosId', 'defaultCosId must be null or a valid Cos ID', array(), $this->getDefaultCosId()); } }
public function isBilleePaymentMethodValid(ExecutionContext $context) { // If user is not paying in full, then check cc/ach details if (!$this->getPayInFull()) { if ($this->getPaymentMethod()->getPaymentType() == 'CREDIT CARD') { if (!$this->getCcNum()) { $context->addViolationAtPath('cc_num', 'Please add cc details'); } else { if (!$this->getCvvNumber()) { $context->addViolationAtPath('cvv_number', 'Please add cvv numbers'); } else { if (!$this->getCcExpirationDate()) { $context->addViolationAtPath('cc_expiration_date', 'Please add cc exp date'); } else { $today = new \DateTime(); if ($this->getCcExpirationDate() < $today) { $context->addViolationAtPath('cc_expiration_date', 'Cc exp date must be in the future'); } else { // now grab a pre-auth for the first payment $pp = $this->getPaymentPlanCustomizedPayments(); $paymentObj = json_decode(stripslashes($pp['paymentsData'])); $payments = $paymentObj->payments; $firstPayment = array_pop($payments); $this->paymentGateway->setCardHoldersName((string) $this->getBilleeContact()); $this->paymentGateway->setCreditCardType($this->getPaymentMethod()->getName()); $this->paymentGateway->setCreditCardNumber($this->getCcNum()); $this->paymentGateway->setCreditCardExpiration($this->getCcExpirationDate()); $this->paymentGateway->setCreditCardVerification($this->getCvvNumber()); $this->paymentGateway->setCreditCardZipcode($this->getBilleeContact()->getPostalCode()); // $this->paymentGateway->setReferenceNumber(222); try { $result = $this->paymentGateway->preAuth($firstPayment); $obj = json_decode($result); if (!$obj->transaction_error) { $this->setTransArmorToken($obj->transarmor_token); } } catch (\Exception $e) { $context->addViolationAtPath('cc_num', $e->getMessage()); } // ld($result); // $obj = json_decode($result); // $obj->transarmor_token; // $obj->transaction_tag; // $obj->retrieval_ref_no; // $context->addViolationAtPath('cc_num', 'Bad cc num'); } } } } } else { if (!$this->getAccountNumber()) { $context->addViolationAtPath('account_number', 'Please add account number'); } if (!$this->getRoutingNumber()) { $context->addViolationAtPath('routing_number', 'Please add routing number'); } } } }