diff --git a/.travis.yml b/.travis.yml index af78f761..a89d0130 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,24 @@ language: php php: - - '5.4' - - '5.5' - - '5.6' - - '7' -script: cd test-cases && phpunit --bootstrap bootstrap.php + - 5.4 + - 5.5 + - 5.6 + - 7 + - 7.1 + - 7.2 + +matrix: + allow_failures: + php: 7.1 + php: 7.2 + +# install packages explicitly +install: + - composer self-update && composer install + +# show me what phpunit version we are running +before_script: + - vendor/bin/phpunit --version + +# run the test suite +script: cd test-cases && php ../vendor/bin/phpunit --bootstrap bootstrap.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 89f32937..becd5e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## 1.4.0 - 2017-11-17 +### Added + - Travis support for PHP 7.1 and 7.2 + - Option to disable SSL verification (not recommended outside of testing) + - New response fields in Financial Event List class for SAFE-T Reimbursement events + - New response fields in the Fulfillment Order class: `ReturnItems` and `ReturnAuthorizations` + - New response field in the Merchant Service List class: `AvailableLabelFormats` + - New response fields in the Merchant Shipment class: `CustomTextForLabel`, `LabelFormat`, and `StandardIdForLabel` + - New parameters for the Merchant Shipment Creator class: `CustomTextForLabel`, `LabelFormat`, `StandardIdForLabel`, and `HazmatType` + - New response fields in the Order class: `PaymentMethodDetails`, `IsReplacementOrder`, `ReplacedOrderId`, `BuyerCounty`, and `BuyerTaxInfo` + - New product class for getting Product Fee Estimates +### Changed + - Composer now allows PHPUnit versions 4 and 5 + - Tries to create the log file specified in config if it does not exist + - Fixed undefined index error when processing an empty or invalid response from cURL + ## 1.3.0 - 2016-08-03 ### Added - Travis support diff --git a/composer.json b/composer.json index 10c0a2dd..086e7fd6 100644 --- a/composer.json +++ b/composer.json @@ -3,15 +3,21 @@ "type": "library", "description": "An open-source library to connect to Amazon's MWS web services in an object-oriented manner, with a focus on intuitive usage.", "license": "Apache-2.0", - "keywords": ["API", "Amazon", "PHP"], - "require":{ - "php": ">=5.4", - "ext-curl": "*" + "keywords": [ + "API", + "Amazon", + "PHP" + ], + "require": { + "php": ">=5.4", + "ext-curl": "*" }, "require-dev": { - "phpunit/phpunit": "3.7.*" - }, + "phpunit/phpunit": ">=4.0.0, <6.0.0" + }, "autoload": { - "classmap": ["includes/classes/"] + "classmap": [ + "includes/classes/" + ] } } diff --git a/environment.php b/environment.php index 800ef873..4d8cdebd 100644 --- a/environment.php +++ b/environment.php @@ -65,6 +65,7 @@ $THROTTLE_TIME_PRODUCTMATCH = 1; $THROTTLE_TIME_PRODUCTID = 4; $THROTTLE_TIME_PRODUCTPRICE = 2; +$THROTTLE_TIME_PRODUCTFEE = 10; //Requesting a Report $THROTTLE_LIMIT_REPORTREQUEST = 15; $THROTTLE_TIME_REPORTREQUEST = 60; diff --git a/includes/classes/AmazonCore.php b/includes/classes/AmazonCore.php index 3cc301b3..348d0c7a 100644 --- a/includes/classes/AmazonCore.php +++ b/includes/classes/AmazonCore.php @@ -106,7 +106,8 @@ abstract class AmazonCore{ protected $logpath; protected $env; protected $rawResponses = array(); - + protected $disableSslVerify = false; + /** * AmazonCore constructor sets up key information used in all Amazon requests. * @@ -378,6 +379,10 @@ public function setConfig($path){ * @throws Exception If the file cannot be found or read. */ public function setLogPath($path){ + if (!file_exists($path)){ + touch($path); + } + if (file_exists($path) && is_readable($path)){ $this->logpath = $path; } else { @@ -607,7 +612,7 @@ protected function sendRequest($url,$param){ $this->log("Making request to Amazon: ".$this->options['Action']); $response = $this->fetchURL($url,$param); - while ($response['code'] == '503' && $this->throttleStop==false){ + while (isset($response['code']) && $response['code'] == '503' && $this->throttleStop==false){ $this->sleep(); $response = $this->fetchURL($url,$param); } @@ -742,7 +747,24 @@ protected function checkToken($xml){ $this->tokenFlag = false; } } - + + /** + * Disables or enables the use of SSL verification when sending requests to Amazon. + * + * This is not recommended for a production environment, + * as it is a security risk and can put merchant credentials in danger. + * However, this option is still available in case it is needed. + * + * Use at your own risk. + * @param boolean $b [optional]
Defaults to TRUE.
+ */ + public function setDisableSslVerify($b = true) { + $this->disableSslVerify = $b; + if ($b) { + $this->log('Caution: Disabling SSL verification.', 'Warning'); + } + } + //Functions from Athena: /** * Get url or send POST data @@ -765,6 +787,11 @@ function fetchURL ($url, $param) { curl_setopt($ch,CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch,CURLOPT_HEADER, 1); curl_setopt($ch,CURLOPT_URL,$url); + if ($this->disableSslVerify) { + $this->log('Caution: Request being sent without SSL verification.', 'Warning'); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + } if (!empty($param)){ if (!empty($param['Header'])){ curl_setopt($ch,CURLOPT_HTTPHEADER, $param['Header']); diff --git a/includes/classes/AmazonFinancialEventList.php b/includes/classes/AmazonFinancialEventList.php index fa263d13..6cef707a 100644 --- a/includes/classes/AmazonFinancialEventList.php +++ b/includes/classes/AmazonFinancialEventList.php @@ -426,6 +426,29 @@ protected function parseXml($xml) { $this->list['Adjustment'][] = $temp; } } + if (isset($xml->SAFETReimbursementEventList)) { + foreach($xml->SAFETReimbursementEventList->children() as $x) { + $temp = array(); + $temp['PostedDate'] = (string)$x->PostedDate; + $temp['SAFETClaimId'] = (string)$x->SAFETClaimId; + $temp['Amount'] = (string)$x->ReimbursedAmount->CurrencyAmount; + $temp['CurrencyCode'] = (string)$x->ReimbursedAmount->CurrencyCode; + $temp['SAFETReimbursementItemList'] = array(); + if (isset($x->SAFETReimbursementItemList)) { + foreach($x->SAFETReimbursementItemList->children() as $y) { + if (!isset($y->ItemChargeList)) { + continue; + } + $ztemp = array(); + foreach($y->ItemChargeList->children() as $z) { + $ztemp['ItemChargeList'][] = $this->parseCharge($z); + } + $temp['SAFETReimbursementItemList'][] = $ztemp; + } + } + $this->list['SAFET'][] = $temp; + } + } } /** @@ -542,8 +565,8 @@ protected function parseShipmentEvent($xml) { /** * Parses XML for a single charge into an array. * This structure is used many times throughout shipment events. - * @param SimpleXMLElement $xmlThe XML response from Amazon.
- * @return array parsed structure from XML + * @param SimpleXMLElement $xmlCharge node of the XML response from Amazon.
+ * @return array Parsed structure from XML */ protected function parseCharge($xml) { $r = array(); @@ -585,6 +608,7 @@ protected function parseFee($xml) { *Address node of the XML response from Amazon.
+ * @return array Parsed structure from XML + */ + public function parseAddress($xml) { + $r = array(); + $r['Name'] = (string)$xml->Name; + $r['Line1'] = (string)$xml->Line1; + if (isset($xml->Line2)){ + $r['Line2'] = (string)$xml->Line2; + } + if (isset($xml->Line3)){ + $r['Line3'] = (string)$xml->Line3; + } + if (isset($xml->DistrictOrCounty)){ + $r['DistrictOrCounty'] = (string)$xml->DistrictOrCounty; + } + $r['City'] = (string)$xml->City; + $r['StateOrProvinceCode'] = (string)$xml->StateOrProvinceCode; + $r['CountryCode'] = (string)$xml->CountryCode; + if (isset($xml->PostalCode)){ + $r['PostalCode'] = (string)$xml->PostalCode; + } + if (isset($xml->PhoneNumber)){ + $r['PhoneNumber'] = (string)$xml->PhoneNumber; + } + return $r; } /** @@ -323,6 +374,8 @@ public function cancelOrder(){ *Set to TRUE to get the raw, double-encoded file contents.
* @return array|boolean multi-dimensional array, or FALSE if label not set yet diff --git a/includes/classes/AmazonMerchantShipmentCreator.php b/includes/classes/AmazonMerchantShipmentCreator.php index 8a1f7f51..7f1ae644 100644 --- a/includes/classes/AmazonMerchantShipmentCreator.php +++ b/includes/classes/AmazonMerchantShipmentCreator.php @@ -418,6 +418,56 @@ public function setCarrierWillPickUp($b = true) { $this->options['ShipmentRequestDetails.ShippingServiceOptions.CarrierWillPickUp'] = $v; } + /** + * Sets the Label Format. (Optional) + * + * This method sets the label format to be sent in the next request. + * @param string $fLabel format (ex: "PNG")
+ * @return boolean FALSE if improper input + */ + public function setLabelFormat($f) { + if (is_string($f)){ + $this->options['ShipmentRequestDetails.ShippingServiceOptions.LabelFormat'] = $f; + } else { + $this->log("Tried to set LabelFormat to invalid value",'Warning'); + return false; + } + } + + /** + * Sets the Custom Text for the Label. (Optional) + * + * This method sets the custom text for the label to be sent in the next request. + * @param string $tUp to 14 characters
+ * @return boolean FALSE if improper input + */ + public function setCustomText($t) { + if (is_string($t)){ + $this->options['ShipmentRequestDetails.LabelCustomization.CustomTextForLabel'] = $t; + } else { + $this->log("Tried to set CustomTextForLabel to invalid value",'Warning'); + return false; + } + } + + /** + * Sets the Standard ID for the Label. (Optional) + * + * This method sets the standard ID option for the label to be sent in the next request. + * @param string $id"AmazonOrderId"
+ */ + public function setLabelId($id) { + $options = array( + 'AmazonOrderId' + ); + if (in_array($id, $options)){ + $this->options['ShipmentRequestDetails.LabelCustomization.StandardIdForLabel'] = $id; + } else { + $this->log("Tried to set StandardIdForLabel to invalid value",'Warning'); + return false; + } + } + /** * Sets the Shipping Service ID. (Required) * @@ -451,6 +501,26 @@ public function setServiceOffer($id) { } } + /** + * Sets the Hazmat Type. (Optional) + * + * This method sets the hazmat type to be sent in the next request. + * @param string $h"None" or "LQHazmat"
+ * @return boolean FALSE if improper input + */ + public function setHazmat($h) { + $options = array( + 'None', + 'LQHazmat' + ); + if (in_array($h, $options)){ + $this->options['HazmatType'] = $h; + } else { + $this->log("Tried to set HazmatType to invalid value",'Warning'); + return false; + } + } + /** * Fetches eligible services for the shipment from Amazon using the current options. * diff --git a/includes/classes/AmazonOrder.php b/includes/classes/AmazonOrder.php index 266c841c..dc7647d3 100644 --- a/includes/classes/AmazonOrder.php +++ b/includes/classes/AmazonOrder.php @@ -70,7 +70,7 @@ public function __construct($s = null, $id = null, $data = null, $mock = false, * * This method sets the Amazon Order ID to be sent in the next request. * This parameter is required for fetching the order from Amazon. - * @param string $seither string or number
+ * @param string $ideither string or number
* @return boolean FALSE if improper input */ public function setOrderId($id){ @@ -209,6 +209,15 @@ protected function parseXML($xml){ if (isset($xml->PaymentMethod)){ $d['PaymentMethod'] = (string)$xml->PaymentMethod; } + if (isset($xml->PaymentMethodDetails)){ + foreach ($xml->PaymentMethodDetails as $x) { + $d['PaymentMethodDetails'][] = (string)$x->PaymentMethodDetail; + } + } + if (isset($xml->IsReplacementOrder)){ + $d['IsReplacementOrder'] = (string)$xml->IsReplacementOrder; + $d['ReplacedOrderId'] = (string)$xml->ReplacedOrderId; + } $d['MarketplaceId'] = (string)$xml->MarketplaceId; if (isset($xml->BuyerName)){ $d['BuyerName'] = (string)$xml->BuyerName; @@ -216,6 +225,26 @@ protected function parseXML($xml){ if (isset($xml->BuyerEmail)){ $d['BuyerEmail'] = (string)$xml->BuyerEmail; } + if (isset($xml->BuyerCounty)){ + $d['BuyerCounty'] = (string)$xml->BuyerCounty; + } + if (isset($xml->BuyerTaxInfo)){ + $d['BuyerTaxInfo'] = array(); + if (isset($xml->BuyerTaxInfo->CompanyLegalName)){ + $d['BuyerTaxInfo']['CompanyLegalName'] = (string)$xml->BuyerTaxInfo->CompanyLegalName; + } + if (isset($xml->BuyerTaxInfo->TaxingRegion)){ + $d['BuyerTaxInfo']['TaxingRegion'] = (string)$xml->BuyerTaxInfo->TaxingRegion; + } + if (isset($xml->BuyerTaxInfo->TaxClassifications)){ + foreach($xml->BuyerTaxInfo->TaxClassifications->children() as $x){ + $temp = array(); + $temp['Name'] = (string)$x->Name; + $temp['Value'] = (string)$x->Value; + $d['BuyerTaxInfo']['TaxClassifications'][] = $temp; + } + } + } if (isset($xml->ShipmentServiceLevelCategory)){ $d['ShipmentServiceLevelCategory'] = (string)$xml->ShipmentServiceLevelCategory; } @@ -281,10 +310,28 @@ protected function parseXML($xml){ *This is a flag for enabling Mock Mode. + * This defaults to FALSE.
+ * @param array|string $m [optional]The files (or file) to use in Mock Mode.
+ * @param string $config [optional]An alternate config file to set. Used for testing.
+ */ + public function __construct($s = null, $mock = false, $m = null, $config = null){ + parent::__construct($s, $mock, $m, $config); + include($this->env); + + $this->options['Action'] = 'GetMyFeesEstimate'; + + if(isset($THROTTLE_TIME_PRODUCTFEE)) { + $this->throttleTime = $THROTTLE_TIME_PRODUCTFEE; + } + $this->throttleGroup = 'GetMyFeesEstimate'; + } + + /** + * Sets the estimate request(s). (Required) + * + * This method sets the list of estimate requests to be sent in the next request. + * This parameter is required for getting fee estimates from Amazon. + * The array provided should contain a list of arrays, each with the following fields: + *See above.
+ * @return boolean FALSE if improper input + */ + public function setRequests($a){ + if (!is_array($a) || !$a){ + $this->log('Tried to set Fee Estimate Requests to invalid values','Warning'); + return false; + } + $this->resetRequests(); + $i = 1; + foreach ($a as $x){ + if (is_array($x) && array_key_exists('MarketplaceId', $x) && + array_key_exists('IdType', $x) && array_key_exists('IdValue', $x) && + array_key_exists('ListingPrice', $x) && array_key_exists('Identifier', $x) && + array_key_exists('IsAmazonFulfilled', $x) && is_array($x['ListingPrice']) && + array_key_exists('CurrencyCode', $x['ListingPrice']) && + array_key_exists('Value', $x['ListingPrice'])){ + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.MarketplaceId'] = $x['MarketplaceId']; + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.IdType'] = $x['IdType']; + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.IdValue'] = $x['IdValue']; + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.ListingPrice.CurrencyCode'] = $x['ListingPrice']['CurrencyCode']; + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.ListingPrice.Value'] = $x['ListingPrice']['Value']; + if (isset($x['Shipping']) && is_array($x['Shipping'])){ + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.Shipping.CurrencyCode'] = $x['Shipping']['CurrencyCode']; + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.Shipping.Value'] = $x['Shipping']['Value']; + } + if (array_key_exists('Points', $x)){ + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.Points.PointsNumber'] = $x['Points']; + } + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.Identifier'] = $x['Identifier']; + $this->options['FeesEstimateRequestList.FeesEstimateRequest.'.$i.'.IsAmazonFulfilled'] = $x['IsAmazonFulfilled']; + + $i++; + } else { + $this->resetRequests(); + $this->log('Tried to set Fee Estimate Requests with invalid array','Warning'); + return false; + } + } + } + + /** + * Removes request options. + * + * Since the list of requests is a required parameter, these options should not be removed + * without replacing them, so this method is not public. + */ + protected function resetRequests() { + foreach($this->options as $op=>$junk){ + if(preg_match("#FeesEstimateRequestList#",$op)){ + unset($this->options[$op]); + } + } + } + + /** + * Fetches a list of product fee estimates from Amazon. + * + * Submits a GetMyFeesEstimate request to Amazon. Amazon will send + * the list back as a response, which can be retrieved using getEstimates. + * @return boolean FALSE if something goes wrong + */ + public function fetchEstimates(){ + if (!array_key_exists('FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId',$this->options)){ + $this->log('Fee Requests must be set in order to fetch estimates!','Warning'); + return false; + } + + $url = $this->urlbase.$this->urlbranch; + + $query = $this->genQuery(); + + $path = $this->options['Action'].'Result'; + + if ($this->mockMode){ + $xml = $this->fetchMockFile(); + } else { + $response = $this->sendRequest($url, array('Post'=>$query)); + + if (!$this->checkResponse($response)){ + return false; + } + + $xml = simplexml_load_string($response['body']); + } + + $this->parseXml($xml->$path); + } + + /** + * Parses XML response into array. + * + * This is what reads the response XML and converts it into an array. + * @param SimpleXMLElement $xmlThe XML response from Amazon.
+ * @return boolean FALSE if no XML data is found + */ + protected function parseXml($xml){ + if (!$xml){ + return false; + } + + $this->productList = array(); + if (!isset($xml->FeesEstimateResultList)){ + return; + } + foreach($xml->FeesEstimateResultList->children() as $x){ + $temp = array(); + $temp['MarketplaceId'] = (string)$x->FeesEstimateIdentifier->MarketplaceId; + $temp['IdType'] = (string)$x->FeesEstimateIdentifier->IdType; + $temp['IdValue'] = (string)$x->FeesEstimateIdentifier->IdValue; + $temp['ListingPrice'] = $this->parseMoney($x->FeesEstimateIdentifier->PriceToEstimateFees->ListingPrice); + if (isset($x->FeesEstimateIdentifier->PriceToEstimateFees->Shipping)){ + $temp['Shipping'] = $this->parseMoney($x->FeesEstimateIdentifier->PriceToEstimateFees->Shipping); + } + if (isset($x->FeesEstimateIdentifier->PriceToEstimateFees->Points->PointsNumber)){ + $temp['Points'] = (string)$x->FeesEstimateIdentifier->PriceToEstimateFees->Points->PointsNumber; + } + $temp['IsAmazonFulfilled'] = (string)$x->FeesEstimateIdentifier->IsAmazonFulfilled; + $temp['SellerInputIdentifier'] = (string)$x->FeesEstimateIdentifier->SellerInputIdentifier; + $temp['TimeOfFeesEstimation'] = (string)$x->FeesEstimateIdentifier->TimeOfFeesEstimation; + $temp['Status'] = (string)$x->Status; + if (isset($x->FeesEstimate)){ + $temp['TotalFeesEstimate'] = $this->parseMoney($x->FeesEstimate->TotalFeesEstimate); + $temp['FeeDetailList'] = array(); + if (isset($x->FeesEstimate->FeeDetailList)){ + foreach($x->FeesEstimate->FeeDetailList->children() as $z){ + $temp['FeeDetailList'][] = $this->parseFeeDetail($z); + } + } + } + if (isset($x->Error)){ + $temp['Error']['Type'] = (string)$x->Error->Type; + $temp['Error']['Code'] = (string)$x->Error->Code; + $temp['Error']['Message'] = (string)$x->Error->Message; + } + $this->productList[] = $temp; + } + } + + /** + * Parses XML for a single money element into an array. + * This structure is used many times throughout fee estimates. + * @param SimpleXMLElement $xmlMoney node of the XML response from Amazon.
+ * @return array Parsed structure from XML + */ + protected function parseMoney($xml){ + $r = array(); + $r['Amount'] = (string)$xml->Amount; + $r['CurrencyCode'] = (string)$xml->CurrencyCode; + return $r; + } + + /** + * Parses XML for a single fee detail into an array. + * This structure is used recursively in fee estimates. + * @param SimpleXMLElement $xmlFee Detail node of the XML response from Amazon.
+ * @return array Parsed structure from XML + */ + protected function parseFeeDetail($xml){ + $r = array(); + $r['FeeType'] = (string)$xml->FeeType; + $r['FeeAmount'] = $this->parseMoney($xml->FeeAmount); + if (isset($xml->FeePromotion)){ + $r['FeePromotion'] = $this->parseMoney($xml->FeePromotion); + } + if (isset($xml->TaxAmount)){ + $r['TaxAmount'] = $this->parseMoney($xml->TaxAmount); + } + $r['FinalFee'] = $this->parseMoney($xml->FinalFee); + if (isset($xml->IncludedFeeDetailList)){ + $r['IncludedFeeDetailList'] = array(); + foreach($xml->IncludedFeeDetailList->children() as $x){ + $r['IncludedFeeDetailList'][] = $this->parseFeeDetail($x); + } + } + return $r; + } + + /** + * Returns fee estimate specified or array of fee estimates. + * Each estimate array will have the following keys: + *List index to retrieve the value from.
+ * @return array|boolean multi-dimensional array, or FALSE if list not filled yet + */ + public function getEstimates($num = null){ + if (!isset($this->productList)){ + return false; + } + if (is_numeric($num)){ + return $this->productList[$num]; + } else { + return $this->productList; + } + } + + /** + * Iterator function + * @return array + */ + public function current(){ + return $this->productList[$this->i]; + } + + /** + * Iterator function + */ + public function rewind(){ + $this->i = 0; + } + + /** + * Iterator function + * @return int + */ + public function key() { + return $this->i; + } + + /** + * Iterator function + */ + public function next() { + $this->i++; + } + + /** + * Iterator function + * @return boolean + */ + public function valid() { + return isset($this->productList[$this->i]); + } + +} diff --git a/test-cases/includes/classes/AmazonCoreTest.php b/test-cases/includes/classes/AmazonCoreTest.php index 56c46052..09a66204 100644 --- a/test-cases/includes/classes/AmazonCoreTest.php +++ b/test-cases/includes/classes/AmazonCoreTest.php @@ -24,7 +24,11 @@ protected function setUp() { * This method is called after a test is executed. */ protected function tearDown() { - + $fileName = 'no-file.log'; + + if (file_exists($fileName)){ + @unlink($fileName); + } } /** @@ -41,7 +45,7 @@ public function mockProvider() { array('no',null, null), ); } - + /** * @covers AmazonCore::setMock * @dataProvider mockProvider @@ -69,11 +73,22 @@ public function testSetConfig() { /** * @covers AmazonCore::setLogPath - * @expectedException Exception - * @expectedExceptionMessage Log file does not exist or cannot be read! (no) */ public function testSetLogPath() { - $this->object->setLogPath('no'); + $fileName = 'no-file.log'; + + $this->object->setLogPath($fileName); + + $this->assertFileExists($fileName); + } + + /** + * @covers AmazonCore::setLogPath + * @expectedException Exception + * @expectedExceptionMessage Log file does not exist or cannot be read! () + */ + public function testSetLogPathThrowsException() { + $this->object->setLogPath(false); } /** @@ -92,7 +107,7 @@ public function testSetStore() { $this->assertEquals('Access Key ID is missing!',$bad[1]); $this->assertEquals('Secret Key is missing!',$bad[2]); } - + public function testGetOptions(){ $o = $this->object->getOptions(); $this->assertInternalType('array',$o); @@ -103,7 +118,7 @@ public function testGetOptions(){ $this->assertArrayHasKey('SignatureMethod',$o); $this->assertArrayHasKey('Version',$o); } - + } require_once('helperFunctions.php'); diff --git a/test-cases/includes/classes/AmazonFinancialEventListTest.php b/test-cases/includes/classes/AmazonFinancialEventListTest.php index 3a297d94..8480f6d1 100644 --- a/test-cases/includes/classes/AmazonFinancialEventListTest.php +++ b/test-cases/includes/classes/AmazonFinancialEventListTest.php @@ -173,6 +173,8 @@ public function testGetEvents($o) { $this->assertEquals($o->getLoanServicingEvents(), $list['LoanServicing']); $this->assertArrayHasKey('Adjustment', $list); $this->assertEquals($o->getAdjustmentEvents(), $list['Adjustment']); + $this->assertArrayHasKey('SAFET', $list); + $this->assertEquals($o->getSafetEvents(), $list['SAFET']); //not fetched yet for this object $this->assertFalse($this->object->getEvents()); } @@ -790,6 +792,40 @@ public function testGetAdjustmentEvents($o) { $this->assertFalse($this->object->getAdjustmentEvents()); } + /** + * @param AmazonFinancialEventList $o + * @depends testFetchEventList + */ + public function testGetSafetEvents($o) { + $x = array(); + $x[0]['Amount'] = '4.99'; + $x[0]['CurrencyCode'] = 'INR'; + $x[0]['PostedDate'] = '2017-01-11T13:17:15.000Z'; + $x[0]['SAFETClaimId'] = '77165-06605-4776427'; + $x[0]['SAFETReimbursementItemList'][0]['ItemChargeList'][0]['ChargeType'] = 'SAFE-T Reimbursement'; + $x[0]['SAFETReimbursementItemList'][0]['ItemChargeList'][0]['Amount'] = '25.99'; + $x[0]['SAFETReimbursementItemList'][0]['ItemChargeList'][0]['CurrencyCode'] = 'USD'; + $x[0]['SAFETReimbursementItemList'][0]['ItemChargeList'][1]['ChargeType'] = 'Test'; + $x[0]['SAFETReimbursementItemList'][0]['ItemChargeList'][1]['Amount'] = '1.99'; + $x[0]['SAFETReimbursementItemList'][0]['ItemChargeList'][1]['CurrencyCode'] = 'USD'; + $x[1]['Amount'] = '12.99'; + $x[1]['CurrencyCode'] = 'INR'; + $x[1]['PostedDate'] = '2017-02-11T14:15:16.000Z'; + $x[1]['SAFETClaimId'] = '12345-98760-8675309'; + $x[1]['SAFETReimbursementItemList'][0]['ItemChargeList'][0]['ChargeType'] = 'SAFE-T Reimbursement'; + $x[1]['SAFETReimbursementItemList'][0]['ItemChargeList'][0]['Amount'] = '29.99'; + $x[1]['SAFETReimbursementItemList'][0]['ItemChargeList'][0]['CurrencyCode'] = 'USD'; + $x[1]['SAFETReimbursementItemList'][1]['ItemChargeList'][0]['ChargeType'] = 'Double Test'; + $x[1]['SAFETReimbursementItemList'][1]['ItemChargeList'][0]['Amount'] = '22.22'; + $x[1]['SAFETReimbursementItemList'][1]['ItemChargeList'][0]['CurrencyCode'] = 'USD'; + + $list = $o->getSafetEvents(); + $this->assertInternalType('array', $list); + $this->assertEquals($x, $list); + //not fetched yet for this object + $this->assertFalse($this->object->getSafetEvents()); + } + } require_once('helperFunctions.php'); diff --git a/test-cases/includes/classes/AmazonFulfillmentOrderTest.php b/test-cases/includes/classes/AmazonFulfillmentOrderTest.php index 1d2ba5ed..54c3422a 100644 --- a/test-cases/includes/classes/AmazonFulfillmentOrderTest.php +++ b/test-cases/includes/classes/AmazonFulfillmentOrderTest.php @@ -178,6 +178,60 @@ public function testGetOrder($o){ $xs[1]['FulfillmentShipmentPackage'][0]['EstimatedArrivalDateTime'] = '2012-12-12T12:12:12Z'; $x['Shipments'] = $xs; + + $xr = array(); + $xr[0]['SellerReturnItemId'] = '16a6a142EXAMPLE'; + $xr[1]['SellerReturnItemId'] = '16a6a142EXAMPLE2'; + $xr[0]['SellerFulfillmentOrderItemId'] = 'order-item-1'; + $xr[1]['SellerFulfillmentOrderItemId'] = 'order-item-2'; + $xr[0]['AmazonShipmentId'] = 'DLHg36GDN'; + $xr[1]['AmazonShipmentId'] = 'DKMKLXJmN'; + $xr[0]['SellerReturnReasonCode'] = 'REASON-CODE'; + $xr[1]['SellerReturnReasonCode'] = 'REASON-CODE-2'; + $xr[0]['ReturnComment'] = 'Did not like color'; + $xr[1]['ReturnComment'] = 'Did not like shape'; + $xr[0]['AmazonReturnReasonCode'] = 'OTHER-REASON-CODE'; + $xr[1]['AmazonReturnReasonCode'] = 'OTHER-REASON-CODE-2'; + $xr[0]['Status'] = 'Processed'; + $xr[1]['Status'] = 'Processed2'; + $xr[0]['StatusChangedDate'] = '2016-09-02T02:40:36Z'; + $xr[1]['StatusChangedDate'] = '2016-09-08T02:40:36Z'; + $xr[0]['ReturnAuthorizationId'] = 'amzn-rma-id'; + $xr[1]['ReturnAuthorizationId'] = 'amzn-rma-id-2'; + $xr[0]['ReturnReceivedCondition'] = 'Sellable'; + $xr[1]['ReturnReceivedCondition'] = 'Sellable2'; + $xr[0]['FulfillmentCenterId'] = 'FC123'; + $xr[1]['FulfillmentCenterId'] = 'FC321'; + + $x['ReturnItems'] = $xr; + + $xa = array(); + $xa[0]['ReturnAuthorizationId'] = 'amzn-rma-id'; + $xa[1]['ReturnAuthorizationId'] = 'amzn-rma-id-2'; + $xa[0]['FulfillmentCenterId'] = 'FC123'; + $xa[1]['FulfillmentCenterId'] = 'FC321'; + $xa[0]['ReturnToAddress']['Name'] = 'Amazon FC'; + $xa[1]['ReturnToAddress']['Name'] = 'Amazon FC2'; + $xa[0]['ReturnToAddress']['Line1'] = '123 Main Street'; + $xa[1]['ReturnToAddress']['Line1'] = '321 Main Street'; + $xa[0]['ReturnToAddress']['Line2'] = 'Suite 16'; + $xa[0]['ReturnToAddress']['Line3'] = 'Hole in Wall'; + $xa[0]['ReturnToAddress']['DistrictOrCounty'] = 'Ninth'; + $xa[0]['ReturnToAddress']['City'] = 'Anywhere'; + $xa[1]['ReturnToAddress']['City'] = 'Somewhere'; + $xa[0]['ReturnToAddress']['StateOrProvinceCode'] = 'WA'; + $xa[1]['ReturnToAddress']['StateOrProvinceCode'] = 'WA'; + $xa[0]['ReturnToAddress']['CountryCode'] = 'US'; + $xa[1]['ReturnToAddress']['CountryCode'] = 'US'; + $xa[0]['ReturnToAddress']['PostalCode'] = '98122'; + $xa[1]['ReturnToAddress']['PostalCode'] = '98123'; + $xa[0]['ReturnToAddress']['PhoneNumber'] = '555-867-5309'; + $xa[0]['AmazonRmaId'] = 'test123'; + $xa[1]['AmazonRmaId'] = 'test321'; + $xa[0]['RmaPageURL'] = 'https://sellercentral.amazon.com/URL'; + $xa[1]['RmaPageURL'] = 'https://sellercentral.amazon.com/URL#2'; + + $x['ReturnAuthorizations'] = $xa; $this->assertEquals($x,$get); diff --git a/test-cases/includes/classes/AmazonMerchantShipmentTest.php b/test-cases/includes/classes/AmazonMerchantShipmentTest.php index 482b015e..bd5599b5 100644 --- a/test-cases/includes/classes/AmazonMerchantShipmentTest.php +++ b/test-cases/includes/classes/AmazonMerchantShipmentTest.php @@ -275,6 +275,107 @@ public function testSetCarrierWillPickUp() { $this->assertEquals('false', $o4[$key]); } + public function testSetLabelFormat() { + $key = 'ShipmentRequestDetails.ShippingServiceOptions.LabelFormat'; + $this->assertNull($this->object->setLabelFormat('PNG')); + $o = $this->object->getOptions(); + $this->assertArrayHasKey($key, $o); + $this->assertEquals('PNG', $o[$key]); + + $this->assertFalse($this->object->setLabelFormat(77)); //won't work for this + $this->assertFalse($this->object->setLabelFormat(array())); //won't work for this + $this->assertFalse($this->object->setLabelFormat(null)); //won't work for other things + + $check = parseLog(); + $this->assertEquals('Tried to set LabelFormat to invalid value',$check[1]); + $this->assertEquals('Tried to set LabelFormat to invalid value',$check[2]); + $this->assertEquals('Tried to set LabelFormat to invalid value',$check[3]); + } + + public function testSetCustomText() { + $key = 'ShipmentRequestDetails.LabelCustomization.CustomTextForLabel'; + $this->assertNull($this->object->setCustomText('Very Neat')); + $o = $this->object->getOptions(); + $this->assertArrayHasKey($key, $o); + $this->assertEquals('Very Neat', $o[$key]); + + $this->assertFalse($this->object->setCustomText(77)); //won't work for this + $this->assertFalse($this->object->setCustomText(array())); //won't work for this + $this->assertFalse($this->object->setCustomText(null)); //won't work for other things + + $check = parseLog(); + $this->assertEquals('Tried to set CustomTextForLabel to invalid value',$check[1]); + $this->assertEquals('Tried to set CustomTextForLabel to invalid value',$check[2]); + $this->assertEquals('Tried to set CustomTextForLabel to invalid value',$check[3]); + } + + public function testSetLabelId() { + $key = 'ShipmentRequestDetails.LabelCustomization.StandardIdForLabel'; + $this->assertNull($this->object->setLabelId('AmazonOrderId')); + $o = $this->object->getOptions(); + $this->assertArrayHasKey($key, $o); + $this->assertEquals('AmazonOrderId', $o[$key]); + + $this->assertFalse($this->object->setLabelId('something')); //won't work for this + $this->assertFalse($this->object->setLabelId(array())); //won't work for other things + $this->assertFalse($this->object->setLabelId(null)); //won't work for other things + + $check = parseLog(); + $this->assertEquals('Tried to set StandardIdForLabel to invalid value',$check[1]); + $this->assertEquals('Tried to set StandardIdForLabel to invalid value',$check[2]); + $this->assertEquals('Tried to set StandardIdForLabel to invalid value',$check[3]); + } + + public function testSetService() { + $key = 'ShippingServiceId'; + $this->assertNull($this->object->setService('Ground')); + $o = $this->object->getOptions(); + $this->assertArrayHasKey($key, $o); + $this->assertEquals('Ground', $o[$key]); + + $this->assertFalse($this->object->setService(77)); //won't work for this + $this->assertFalse($this->object->setService(array())); //won't work for this + $this->assertFalse($this->object->setService(null)); //won't work for other things + + $check = parseLog(); + $this->assertEquals('Tried to set ShippingServiceId to invalid value',$check[1]); + $this->assertEquals('Tried to set ShippingServiceId to invalid value',$check[2]); + $this->assertEquals('Tried to set ShippingServiceId to invalid value',$check[3]); + } + + public function testSetServiceOffer() { + $key = 'ShippingServiceOfferId'; + $this->assertNull($this->object->setServiceOffer('123ABC')); + $o = $this->object->getOptions(); + $this->assertArrayHasKey($key, $o); + $this->assertEquals('123ABC', $o[$key]); + + $this->assertFalse($this->object->setServiceOffer(77)); //won't work for this + $this->assertFalse($this->object->setServiceOffer(array())); //won't work for this + $this->assertFalse($this->object->setServiceOffer(null)); //won't work for other things + + $check = parseLog(); + $this->assertEquals('Tried to set ShippingServiceOfferId to invalid value',$check[1]); + $this->assertEquals('Tried to set ShippingServiceOfferId to invalid value',$check[2]); + $this->assertEquals('Tried to set ShippingServiceOfferId to invalid value',$check[3]); + } + + public function testSetHazmat() { + $key = 'HazmatType'; + $this->assertNull($this->object->setHazmat('LQHazmat')); + $o = $this->object->getOptions(); + $this->assertArrayHasKey($key, $o); + $this->assertEquals('LQHazmat', $o[$key]); + + $this->assertFalse($this->object->setHazmat('something')); //won't work for this + $this->assertFalse($this->object->setHazmat(array())); //won't work for other things + $this->assertFalse($this->object->setHazmat(null)); //won't work for other things + + $check = parseLog(); + $this->assertEquals('Tried to set HazmatType to invalid value',$check[1]); + $this->assertEquals('Tried to set HazmatType to invalid value',$check[2]); + $this->assertEquals('Tried to set HazmatType to invalid value',$check[3]); + } public function testCreateShipment(){ resetLog(); @@ -515,6 +616,9 @@ public function testGetLabelData($o) { $x['FileContents']['Contents'] = 'This is a test'; $x['FileContents']['FileType'] = 'application/pdf'; $x['FileContents']['Checksum'] = 'DmsWbJpdMPALN3jV4wHOrg=='; + $x['CustomTextForLabel'] = 'Wow Cool'; + $x['LabelFormat'] = 'ZPL203'; + $x['StandardIdForLabel'] = 'AmazonOrderId'; $this->assertEquals($x, $get); $this->assertEquals($x['FileContents']['Contents'], $o->getLabelFileContents()); diff --git a/test-cases/includes/classes/AmazonOrderTest.php b/test-cases/includes/classes/AmazonOrderTest.php index f831a74f..75dfe13f 100644 --- a/test-cases/includes/classes/AmazonOrderTest.php +++ b/test-cases/includes/classes/AmazonOrderTest.php @@ -123,9 +123,17 @@ public function testGetData($o){ $x['PaymentExecutionDetail'][1]['CurrencyCode'] = 'USD'; $x['PaymentExecutionDetail'][1]['SubPaymentMethod'] = 'GC'; $x['PaymentMethod'] = 'COD'; + $x['PaymentMethodDetails'][0] = 'CreditCard'; + $x['IsReplacementOrder'] = 'true'; + $x['ReplacedOrderId'] = '555-1233752-8214740'; $x['MarketplaceId'] = 'ATVPDKIKX0DER'; $x['BuyerName'] = 'Amazon User'; $x['BuyerEmail'] = '5vlh04mgfmjh9h5@marketplace.amazon.com'; + $x['BuyerCounty'] = 'Best'; + $x['BuyerTaxInfo']['CompanyLegalName'] = 'Company Name'; + $x['BuyerTaxInfo']['TaxingRegion'] = 'US'; + $x['BuyerTaxInfo']['TaxClassifications'][0]['Name'] = 'VATNumber'; + $x['BuyerTaxInfo']['TaxClassifications'][0]['Value'] = 'XXX123'; $x['ShipmentServiceLevelCategory'] = 'Standard'; $x['CbaDisplayableShippingLabel'] = 'Best'; $x['ShippedByAmazonTFM'] = 'false'; @@ -326,6 +334,37 @@ public function testGetPaymentMethod($o){ $this->assertFalse($this->object->getPaymentMethod()); //not fetched yet for this object } + + /** + * @depends testFetchOrder + */ + public function testGetPaymentMethodDetails($o){ + $get = $o->getPaymentMethodDetails(); + $x = array('CreditCard'); + $this->assertEquals($x, $get); + + $this->assertFalse($this->object->getPaymentMethodDetails()); //not fetched yet for this object + } + + /** + * @depends testFetchOrder + */ + public function testGetIsReplacementOrder($o){ + $get = $o->getIsReplacementOrder(); + $this->assertEquals('true',$get); + + $this->assertFalse($this->object->getIsReplacementOrder()); //not fetched yet for this object + } + + /** + * @depends testFetchOrder + */ + public function testGetReplacedOrderId($o){ + $get = $o->getReplacedOrderId(); + $this->assertEquals('555-1233752-8214740',$get); + + $this->assertFalse($this->object->getReplacedOrderId()); //not fetched yet for this object + } /** * @depends testFetchOrder @@ -356,6 +395,31 @@ public function testGetBuyerEmail($o){ $this->assertFalse($this->object->getBuyerEmail()); //not fetched yet for this object } + + /** + * @depends testFetchOrder + */ + public function testGetBuyerCounty($o){ + $get = $o->getBuyerCounty(); + $this->assertEquals('Best', $get); + + $this->assertFalse($this->object->getBuyerCounty()); //not fetched yet for this object + } + + /** + * @depends testFetchOrder + */ + public function testGetBuyerTaxInfo($o){ + $get = $o->getBuyerTaxInfo(); + $x = array(); + $x['CompanyLegalName'] = 'Company Name'; + $x['TaxingRegion'] = 'US'; + $x['TaxClassifications'][0]['Name'] = 'VATNumber'; + $x['TaxClassifications'][0]['Value'] = 'XXX123'; + $this->assertEquals($x, $get); + + $this->assertFalse($this->object->getBuyerTaxInfo()); //not fetched yet for this object + } /** * @depends testFetchOrder @@ -421,7 +485,7 @@ public function testGetEarliestShipDate($o) { * @depends testFetchOrder * @param AmazonOrder $o */ - public function testgetLatestShipDate($o) { + public function testGetLatestShipDate($o) { $this->assertEquals('2010-10-07T12:43:16.000Z', $o->getLatestShipDate()); $this->assertFalse($this->object->getLatestShipDate()); //not fetched yet for this object diff --git a/test-cases/includes/classes/AmazonProductFeeEstimateTest.php b/test-cases/includes/classes/AmazonProductFeeEstimateTest.php new file mode 100644 index 00000000..3c40a593 --- /dev/null +++ b/test-cases/includes/classes/AmazonProductFeeEstimateTest.php @@ -0,0 +1,209 @@ +object = new AmazonProductFeeEstimate('testStore', true, null, __DIR__.'/../../test-config.php'); + } + + public function testSetRequest() { + //bad input + $this->assertFalse($this->object->setRequests(null)); + $this->assertFalse($this->object->setRequests(123)); + $this->assertFalse($this->object->setRequests('word')); + $this->assertFalse($this->object->setRequests(array())); + $this->assertFalse($this->object->setRequests(array(123))); + $this->assertFalse($this->object->setRequests(array('word'))); + + $op = array(); + $this->assertFalse($this->object->setRequests(array($op))); //missing keys + + $op['MarketplaceId'] = 'Marketplace'; + $this->assertFalse($this->object->setRequests(array($op))); //still missing keys + $op['IdType'] = 'ASIN'; + $this->assertFalse($this->object->setRequests(array($op))); //still missing keys + $op['IdValue'] = 'B00123ASIN'; + $this->assertFalse($this->object->setRequests(array($op))); //still missing keys + $op['ListingPrice'] = array(); + $this->assertFalse($this->object->setRequests(array($op))); //still missing keys + $op['ListingPrice']['CurrencyCode'] = 'USD'; + $this->assertFalse($this->object->setRequests(array($op))); //still missing keys + $op['ListingPrice']['Value'] = '123'; + $this->assertFalse($this->object->setRequests(array($op))); //still missing keys + $op['Identifier'] = 'TEST123'; + $this->assertFalse($this->object->setRequests(array($op))); //still missing keys + $op['IsAmazonFulfilled'] = 'false'; + $this->assertNull($this->object->setRequests(array($op))); //finally good + + //test doubles + $op2 = $op; + $op2['MarketplaceId'] = 'Mark II'; + $op2['Shipping']['CurrencyCode'] = 'USD'; + $op2['Shipping']['Value'] = '1.23'; + $op2['Points'] = '3'; + $this->assertNull($this->object->setRequests(array($op, $op2))); + + //verify options were set correctly + $o = $this->object->getOptions(); + $pre = 'FeesEstimateRequestList.FeesEstimateRequest.'; + $this->assertArrayHasKey($pre.'1.MarketplaceId', $o); + $this->assertEquals('Marketplace', $o[$pre.'1.MarketplaceId']); + $this->assertArrayHasKey($pre.'1.IdType', $o); + $this->assertEquals('ASIN', $o[$pre.'1.IdType']); + $this->assertArrayHasKey($pre.'1.IdValue', $o); + $this->assertEquals('B00123ASIN', $o[$pre.'1.IdValue']); + $this->assertArrayHasKey($pre.'1.ListingPrice.CurrencyCode', $o); + $this->assertEquals('USD', $o[$pre.'1.ListingPrice.CurrencyCode']); + $this->assertArrayHasKey($pre.'1.ListingPrice.Value', $o); + $this->assertEquals('123', $o[$pre.'1.ListingPrice.Value']); + $this->assertArrayHasKey($pre.'1.Identifier', $o); + $this->assertEquals('TEST123', $o[$pre.'1.Identifier']); + $this->assertArrayHasKey($pre.'1.IsAmazonFulfilled', $o); + $this->assertEquals('false', $o[$pre.'1.IsAmazonFulfilled']); + $this->assertArrayHasKey($pre.'2.MarketplaceId', $o); + $this->assertEquals('Mark II', $o[$pre.'2.MarketplaceId']); + $this->assertArrayHasKey($pre.'2.Shipping.CurrencyCode', $o); + $this->assertEquals('USD', $o[$pre.'2.Shipping.CurrencyCode']); + $this->assertArrayHasKey($pre.'2.Shipping.Value', $o); + $this->assertEquals('1.23', $o[$pre.'2.Shipping.Value']); + $this->assertArrayHasKey($pre.'2.Points.PointsNumber', $o); + $this->assertEquals('3', $o[$pre.'2.Points.PointsNumber']); + + //setting again should reset + $this->assertNull($this->object->setRequests(array($op))); + $o2 = $this->object->getOptions(); + $this->assertArrayHasKey($pre.'1.MarketplaceId', $o2); + $this->assertArrayNotHasKey($pre.'2.MarketplaceId', $o2); + $this->assertArrayNotHasKey($pre.'3.MarketplaceId', $o2); + + //check logs + $check = parseLog(); + $err1 = 'Tried to set Fee Estimate Requests to invalid values'; + $err2 = 'Tried to set Fee Estimate Requests with invalid array'; + $this->assertEquals($err1, $check[1]); + $this->assertEquals($err1, $check[2]); + $this->assertEquals($err1, $check[3]); + $this->assertEquals($err1, $check[4]); + $this->assertEquals($err2, $check[5]); + $this->assertEquals($err2, $check[6]); + $this->assertEquals($err2, $check[7]); + $this->assertEquals($err2, $check[8]); + $this->assertEquals($err2, $check[9]); + $this->assertEquals($err2, $check[10]); + $this->assertEquals($err2, $check[11]); + $this->assertEquals($err2, $check[12]); + $this->assertEquals($err2, $check[13]); + $this->assertEquals($err2, $check[14]); + + return $this->object; + } + + /** + * @depends testSetRequest + * @param AmazonProductFeeEstimate $o + */ + public function testFetchEstimates($o) { + resetLog(); + $this->object->setMock(true, 'fetchEstimates.xml'); + $this->assertFalse($this->object->getEstimates()); //no data yet + $this->assertFalse($this->object->fetchEstimates()); //no requests yet + $o->setMock(true, 'fetchEstimates.xml'); + $this->assertNull($o->fetchEstimates()); //good, request already set + + $check = parseLog(); + $this->assertEquals('Single Mock File set: fetchEstimates.xml', $check[1]); + $this->assertEquals('Fee Requests must be set in order to fetch estimates!', $check[2]); + + return $o; + } + + /** + * @depends testFetchEstimates + * @param AmazonProductFeeEstimate $o + */ + public function testGetEstimates($o) { + $get = $o->getEstimates(); + $this->assertInternalType('array', $get); + $x = array(); + $x[0]['MarketplaceId'] = 'ATVPDKIKX0DER'; + $x[0]['IdType'] = 'ASIN'; + $x[0]['IdValue'] = 'B0002GTTRC'; + $x[0]['ListingPrice']['Amount'] = '58.00'; + $x[0]['ListingPrice']['CurrencyCode'] = 'USD'; + $x[0]['Shipping']['Amount'] = '0.01'; + $x[0]['Shipping']['CurrencyCode'] = 'USD'; + $x[0]['Points'] = '1'; + $x[0]['IsAmazonFulfilled'] = 'True'; + $x[0]['SellerInputIdentifier'] = 'IDDDDDDDD'; + $x[0]['TimeOfFeesEstimation'] = '2015-07-19T23:15:11.859Z'; + $x[0]['Status'] = 'Success'; + $x[0]['TotalFeesEstimate']['Amount'] = '10.00'; + $x[0]['TotalFeesEstimate']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][0]['FeeType'] = 'AmazonReferralFee'; + $x[0]['FeeDetailList'][0]['FeeAmount']['Amount'] = '8.70'; + $x[0]['FeeDetailList'][0]['FeeAmount']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][0]['FeePromotion']['Amount'] = '1.00'; + $x[0]['FeeDetailList'][0]['FeePromotion']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][0]['FinalFee']['Amount'] = '7.70'; + $x[0]['FeeDetailList'][0]['FinalFee']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][1]['FeeType'] = 'VariableClosingFee'; + $x[0]['FeeDetailList'][1]['FeeAmount']['Amount'] = '0.01'; + $x[0]['FeeDetailList'][1]['FeeAmount']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][1]['FinalFee']['Amount'] = '0.02'; + $x[0]['FeeDetailList'][1]['FinalFee']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][2]['FeeType'] = 'FulfillmentFees'; + $x[0]['FeeDetailList'][2]['FeeAmount']['Amount'] = '2.30'; + $x[0]['FeeDetailList'][2]['FeeAmount']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][2]['FinalFee']['Amount'] = '2.31'; + $x[0]['FeeDetailList'][2]['FinalFee']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][0]['FeeType'] = 'OrderHandlingFee'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][0]['FeeAmount']['Amount'] = '1.00'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][0]['FeeAmount']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][0]['FinalFee']['Amount'] = '1.01'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][0]['FinalFee']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][1]['FeeType'] = 'PickAndPackFee'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][1]['FeeAmount']['Amount'] = '0.30'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][1]['FeeAmount']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][1]['FinalFee']['Amount'] = '0.31'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][1]['FinalFee']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][2]['FeeType'] = 'WeightHandlingFee'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][2]['FeeAmount']['Amount'] = '1.00'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][2]['FeeAmount']['CurrencyCode'] = 'USD'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][2]['FinalFee']['Amount'] = '1.01'; + $x[0]['FeeDetailList'][2]['IncludedFeeDetailList'][2]['FinalFee']['CurrencyCode'] = 'USD'; + $x[1]['MarketplaceId'] = 'ATVPDKIKX0DER'; + $x[1]['IdType'] = 'ASIN'; + $x[1]['IdValue'] = 'B00032ASIN'; + $x[1]['ListingPrice']['Amount'] = '58.00'; + $x[1]['ListingPrice']['CurrencyCode'] = 'USD'; + $x[1]['Shipping']['Amount'] = '0.00'; + $x[1]['Shipping']['CurrencyCode'] = 'USD'; + $x[1]['Points'] = '100'; + $x[1]['IsAmazonFulfilled'] = 'True'; + $x[1]['SellerInputIdentifier'] = 'IDDDDDDDD2'; + $x[1]['TimeOfFeesEstimation'] = '2015-07-20T12:13:14.000Z'; + $x[1]['Status'] = 'Success'; + $x[1]['TotalFeesEstimate']['Amount'] = '10.00'; + $x[1]['TotalFeesEstimate']['CurrencyCode'] = 'USD'; + $x[1]['FeeDetailList'][0]['FeeType'] = 'AmazonReferralFee'; + $x[1]['FeeDetailList'][0]['FeeAmount']['Amount'] = '2.24'; + $x[1]['FeeDetailList'][0]['FeeAmount']['CurrencyCode'] = 'USD'; + $x[1]['FeeDetailList'][0]['FeePromotion']['Amount'] = '1.01'; + $x[1]['FeeDetailList'][0]['FeePromotion']['CurrencyCode'] = 'USD'; + $x[1]['FeeDetailList'][0]['FinalFee']['Amount'] = '1.23'; + $x[1]['FeeDetailList'][0]['FinalFee']['CurrencyCode'] = 'USD'; + $this->assertEquals($x, $get); + $this->assertFalse($this->object->getEstimates()); //not fetched yet for this object + } + +} diff --git a/test-cases/mock/createMerchantShipment.xml b/test-cases/mock/createMerchantShipment.xml index 12047f47..dfc1d18b 100644 --- a/test-cases/mock/createMerchantShipment.xml +++ b/test-cases/mock/createMerchantShipment.xml @@ -32,6 +32,9 @@