Пример #1
0
 /**
  * Checks required items
  * Checks variables type
  * Checks if payment type exist in code list
  *
  * @param $payment
  *
  * @throws InvalidPaymentTypeException
  * @throws MissingRequiredDataException
  */
 private function validatePayment($payment)
 {
     if (!$this->checkRequiredItems($this->requiredPaymentItems, $payment)) {
         throw new MissingRequiredDataException('Payment must contain all required data');
     }
     $this->checkVariableType($payment[PaymentDeliveryService::PAYMENT_ID], self::TYPE_INTEGER);
     $this->checkVariableType($payment[PaymentDeliveryService::PAYMENT_TYPE], self::TYPE_INTEGER);
     $this->checkVariableType($payment[PaymentDeliveryService::PAYMENT_NAME], self::TYPE_STRING);
     $this->checkVariableType($payment[PaymentDeliveryService::PAYMENT_PRICE], self::TYPE_FLOAT);
     if (!$this->paymentTypeCodes->isValid($payment[PaymentDeliveryService::PAYMENT_TYPE])) {
         throw new InvalidPaymentTypeException('Cannot found type from payment in code list');
     }
 }
Пример #2
0
 /**
  * @dataProvider existCodeProvider
  *
  * @param $code
  * @param $expected
  */
 public function testExistCode($code, $expected)
 {
     $paymentTypeCodes = new PaymentType();
     $this->assertSame($expected, $paymentTypeCodes->isValid($code));
 }