public function testAuthorizeAndCaptureServiceHydrateTransactionRequest()
 {
     $data = $this->getData();
     $transactionRequestType = $this->getTransactionRequestType(AuthorizeAndCaptureService::PAYMENT_TRANSACTION_TYPE);
     $transactionRequestHydrator = new TransactionRequestHydrator($this->getServiceConfig());
     $transactionRequestHydrator->setTransactionRequestType(AuthorizeAndCaptureService::PAYMENT_TRANSACTION_TYPE);
     $transactionRequestTypeReturn = $transactionRequestHydrator->hydrate($data, $transactionRequestType);
     $this->assertInstanceOf(TransactionRequestType::class, $transactionRequestTypeReturn);
 }
 /**
  * @param array $data
  */
 protected function hydrate(array $data)
 {
     $this->transactionRequestHydrator->hydrate($data, $this->transactionRequestType);
     $transactionRequestTypeData = [];
     /** Loop the configured subsets */
     foreach ($this->subset as $subsetKey => $subsetDataClass) {
         if (array_key_exists($subsetKey, $data) && is_array($data[$subsetKey])) {
             if (in_array($subsetKey, $this->subsetCollection)) {
                 /** Hydrate each object in the collection */
                 foreach ($data[$subsetKey] as $collection) {
                     $subset = new $subsetDataClass();
                     $this->transactionRequestHydrator->hydrate($collection, $subset, $subsetKey);
                     $transactionRequestTypeData[$subsetKey][] = $subset;
                 }
             } elseif (array_key_exists($subsetKey, $this->subsetParent)) {
                 /** Hydrate the subset */
                 $subset = new $subsetDataClass();
                 $this->transactionRequestHydrator->hydrate($data[$subsetKey], $subset, $subsetKey);
                 $subsetKeyAlias = $subsetKey;
                 /** Check to see if an alias is defined */
                 if (array_key_exists($subsetKey, $this->subsetAlias)) {
                     $subsetKeyAlias = $this->subsetAlias[$subsetKey];
                 }
                 /** Some subsets share a parent, pull the parent if it already exists */
                 if (array_key_exists($subsetKeyAlias, $transactionRequestTypeData)) {
                     $subsetParent = $transactionRequestTypeData[$subsetKeyAlias];
                 } else {
                     $subsetParent = new $this->subsetParent[$subsetKey]();
                 }
                 $this->transactionRequestHydrator->hydrate([$subsetKey => $subset], $subsetParent, false);
                 $transactionRequestTypeData[$subsetKeyAlias] = $subsetParent;
             } else {
                 /** Hydrate the subset */
                 $subset = new $subsetDataClass();
                 $this->transactionRequestHydrator->hydrate($data[$subsetKey], $subset, $subsetKey);
                 /** Build the data set to be passed to the TransactionRequestType hydrator */
                 $transactionRequestTypeData[$subsetKey] = $subset;
             }
         }
     }
     $this->transactionRequestHydrator->hydrate($transactionRequestTypeData, $this->transactionRequestType, false);
     $this->createTransactionRequest->setTransactionRequest($this->transactionRequestType);
 }