Esempio n. 1
0
 /**
  * Checks required items
  * Checks variables type
  * Checks if exist transport type in code list
  * Checks if exist store and validate it
  *
  * @param $transport
  *
  * @throws InvalidStoreTypeException
  * @throws InvalidTransportTypeException
  * @throws MissingRequiredDataException
  */
 private function validateTransport($transport)
 {
     if (!$this->checkRequiredItems($this->requiredTransportItems, $transport)) {
         throw new MissingRequiredDataException('Transport must contain all required data');
     }
     $this->checkVariableType($transport[PaymentDeliveryService::TRANSPORT_ID], self::TYPE_INTEGER);
     $this->checkVariableType($transport[PaymentDeliveryService::TRANSPORT_TYPE], self::TYPE_INTEGER);
     $this->checkVariableType($transport[PaymentDeliveryService::TRANSPORT_NAME], self::TYPE_STRING);
     $this->checkVariableType($transport[PaymentDeliveryService::TRANSPORT_PRICE], self::TYPE_FLOAT);
     $this->checkVariableType($transport[PaymentDeliveryService::TRANSPORT_DESCRIPTION], self::TYPE_STRING);
     if (!$this->deliveryTypeCodes->isValid($transport[PaymentDeliveryService::TRANSPORT_TYPE])) {
         throw new InvalidTransportTypeException('Cannot found type from transport in code list');
     }
     if (array_key_exists(PaymentDeliveryService::KEY_STORE, $transport)) {
         $this->validateStore($transport[PaymentDeliveryService::KEY_STORE]);
     }
 }
Esempio n. 2
0
 /**
  * @covers       DeliveryTypeCodes::isValid
  * @dataProvider existCodeProvider
  *
  * @param $code
  * @param $expected
  */
 public function testExistCode($code, $expected)
 {
     $deliveryCodes = new DeliveryType();
     $this->assertSame($expected, $deliveryCodes->isValid($code));
 }