/**
  * @param $value
  * @param Processor $processor
  * @return \Upg\Library\Request\RequestInterface
  */
 public function unserializeProperty(Processor $processor, $value)
 {
     $paymentInstrument = new PaymentInstrument();
     $paymentInstrument->setUnserializedData($value);
     if ($paymentInstrument->getPaymentInstrumentType() == PaymentInstrument::PAYMENT_INSTRUMENT_TYPE_CARD) {
         list($year, $month) = explode('-', $value['validity']);
         $dateTime = new \DateTime();
         $dateTime->setDate($year, $month, 1);
         $paymentInstrument->setValidity($dateTime);
     }
     return $paymentInstrument;
 }
 private function getPaymentInstrument()
 {
     $payment = new PaymentInstrument();
     $payment->setPaymentInstrumentType(PaymentInstrument::PAYMENT_INSTRUMENT_TYPE_CARD)->setAccountHolder($this->faker->name)->setNumber($this->faker->creditCardNumber)->setIssuer(PaymentInstrument::ISSUER_MC)->setValidity(new \DateTime('now'));
     return $payment;
 }
 public function testPaymentInstrumentTestValidationBic()
 {
     $validation = new Validation();
     $payment = new PaymentInstrument();
     $payment->setPaymentInstrumentType(PaymentInstrument::PAYMENT_INSTRUMENT_TYPE_BANK)->setAccountHolder($this->faker->name)->setIban("FI1350001540000056")->setBic('');
     /**
      * test required
      */
     $validation->getValidator($payment);
     $data = $validation->performValidation();
     $this->assertValidationReturned('Upg\\Library\\Request\\Objects\\PaymentInstrument', 'bic', 'For bank payments bic must be set', $data, "For bank payments bic must be set validation failed");
     /**
      * Format test
      */
     $payment->setBic($this->veryLongString);
     $validation->getValidator($payment);
     $data = $validation->performValidation();
     $this->assertValidationReturned('Upg\\Library\\Request\\Objects\\PaymentInstrument', 'bic', 'Bic must be 11 characters long and contain alphanumeric characters', $data, "Bic must be 11 characters long and contain alphanumeric characters validation failed");
 }