Skip to content

Commit 6ac892f

Browse files
authored
Merge pull request CPIGroup#87 from Peardian/newtests
New tests and Bug fixes
2 parents ec1ceaa + e0a92c0 commit 6ac892f

29 files changed

+684
-52
lines changed

includes/classes/AmazonCore.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,10 +734,7 @@ protected function sleep(){
734734
* @return boolean <b>FALSE</b> if no XML data
735735
*/
736736
protected function checkToken($xml){
737-
if (!$xml){
738-
return false;
739-
}
740-
if ($xml->NextToken && (string)$xml->HasNext != 'false' && (string)$xml->MoreResultsAvailable != 'false'){
737+
if ($xml && $xml->NextToken && (string)$xml->HasNext != 'false' && (string)$xml->MoreResultsAvailable != 'false'){
741738
$this->tokenFlag = true;
742739
$this->options['NextToken'] = (string)$xml->NextToken;
743740
} else {

includes/classes/AmazonFulfillmentOrder.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,20 @@ protected function parseXML($xml) {
180180
$this->order['Details']['CODSettings']['IsCODRequired'] = (string)$d->CODSettings->IsCODRequired;
181181
}
182182
if (isset($d->CODSettings->CODCharge)){
183-
$this->order['Details']['CODSettings']['CODCharge'] = (string)$d->CODSettings->CODCharge;
183+
$this->order['Details']['CODSettings']['CODCharge']['CurrencyCode'] = (string)$d->CODSettings->CODCharge->CurrencyCode;
184+
$this->order['Details']['CODSettings']['CODCharge']['Value'] = (string)$d->CODSettings->CODCharge->Value;
184185
}
185186
if (isset($d->CODSettings->CODChargeTax)){
186-
$this->order['Details']['CODSettings']['CODChargeTax'] = (string)$d->CODSettings->CODChargeTax;
187+
$this->order['Details']['CODSettings']['CODChargeTax']['CurrencyCode'] = (string)$d->CODSettings->CODChargeTax->CurrencyCode;
188+
$this->order['Details']['CODSettings']['CODChargeTax']['Value'] = (string)$d->CODSettings->CODChargeTax->Value;
187189
}
188190
if (isset($d->CODSettings->ShippingCharge)){
189-
$this->order['Details']['CODSettings']['ShippingCharge'] = (string)$d->CODSettings->ShippingCharge;
191+
$this->order['Details']['CODSettings']['ShippingCharge']['CurrencyCode'] = (string)$d->CODSettings->ShippingCharge->CurrencyCode;
192+
$this->order['Details']['CODSettings']['ShippingCharge']['Value'] = (string)$d->CODSettings->ShippingCharge->Value;
190193
}
191194
if (isset($d->CODSettings->ShippingChargeTax)){
192-
$this->order['Details']['CODSettings']['ShippingChargeTax'] = (string)$d->CODSettings->ShippingChargeTax;
195+
$this->order['Details']['CODSettings']['ShippingChargeTax']['CurrencyCode'] = (string)$d->CODSettings->ShippingChargeTax->CurrencyCode;
196+
$this->order['Details']['CODSettings']['ShippingChargeTax']['Value'] = (string)$d->CODSettings->ShippingChargeTax->Value;
193197
}
194198

195199
//Section 2: Order Items

includes/classes/AmazonFulfillmentOrderCreator.php

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public function setCodSettings($cu, $r = null, $c = null, $ct = null, $s = null,
314314
return false;
315315
}
316316
if (isset($r)) {
317-
if (filter_var($s, FILTER_VALIDATE_BOOLEAN)) {
317+
if (filter_var($r, FILTER_VALIDATE_BOOLEAN)) {
318318
$r = 'true';
319319
} else {
320320
$r = 'false';
@@ -364,9 +364,13 @@ public function resetCodSettings(){
364364
* The parameters are passed through <i>strtotime</i>, so values such as "-1 hour" are fine.
365365
* @param string $s <p>A time string for the earliest time.</p>
366366
* @param string $e <p>A time string for the latest time.</p>
367+
* @return boolean <b>FALSE</b> if improper input
367368
* @see genTime
368369
*/
369370
public function setDeliveryWindow($s, $e){
371+
if (empty($s) || empty($e)) {
372+
return false;
373+
}
370374
$times = $this->genTime($s);
371375
$this->options['DeliveryWindow.StartDateTime'] = $times;
372376
$timee = $this->genTime($e);
@@ -480,7 +484,7 @@ protected function resetItems(){
480484
*/
481485
public function createOrder(){
482486
if (!array_key_exists('SellerFulfillmentOrderId',$this->options)){
483-
$this->log("Seller Fulfillment OrderID must be set in order to create an order",'Warning');
487+
$this->log("Seller Fulfillment Order ID must be set in order to create an order",'Warning');
484488
return false;
485489
}
486490
if (!array_key_exists('DisplayableOrderId',$this->options)){
@@ -531,39 +535,13 @@ public function createOrder(){
531535
* Updates a Fulfillment Order with Amazon.
532536
*
533537
* Submits an <i>UpdateFulfillmentOrder</i> request to Amazon. In order to do this,
534-
* a number of parameters are required. Amazon will send back an HTTP response,
535-
* so there is no data to retrieve afterwards. The following parameters are required:
536-
* fulfillment order ID, displayed order ID, displayed timestamp, comment,
537-
* shipping speed, address, and items.
538+
* a fulfillment order ID is required. Amazon will send back an HTTP response,
539+
* so there is no data to retrieve afterwards.
538540
* @return boolean <b>TRUE</b> if the order creation was successful, <b>FALSE</b> if something goes wrong
539541
*/
540542
public function updateOrder(){
541543
if (!array_key_exists('SellerFulfillmentOrderId',$this->options)){
542-
$this->log("Seller Fulfillment OrderID must be set in order to create an order",'Warning');
543-
return false;
544-
}
545-
if (!array_key_exists('DisplayableOrderId',$this->options)){
546-
$this->log("Displayable Order ID must be set in order to create an order",'Warning');
547-
return false;
548-
}
549-
if (!array_key_exists('DisplayableOrderDateTime',$this->options)){
550-
$this->log("Date must be set in order to create an order",'Warning');
551-
return false;
552-
}
553-
if (!array_key_exists('DisplayableOrderComment',$this->options)){
554-
$this->log("Comment must be set in order to create an order",'Warning');
555-
return false;
556-
}
557-
if (!array_key_exists('ShippingSpeedCategory',$this->options)){
558-
$this->log("Shipping Speed must be set in order to create an order",'Warning');
559-
return false;
560-
}
561-
if (!array_key_exists('DestinationAddress.Name',$this->options)){
562-
$this->log("Address must be set in order to create an order",'Warning');
563-
return false;
564-
}
565-
if (!array_key_exists('Items.member.1.SellerSKU',$this->options)){
566-
$this->log("Items must be set in order to create an order",'Warning');
544+
$this->log("Seller Fulfillment Order ID must be set in order to update an order",'Warning');
567545
return false;
568546
}
569547

@@ -581,7 +559,7 @@ public function updateOrder(){
581559
if (!$this->checkResponse($response)){
582560
return false;
583561
} else {
584-
$this->log("Successfully created Fulfillment Order ".$this->options['SellerFulfillmentOrderId']." / ".$this->options['DisplayableOrderId']);
562+
$this->log("Successfully updated Fulfillment Order ".$this->options['SellerFulfillmentOrderId']);
585563
return true;
586564
}
587565
}

includes/classes/AmazonFulfillmentOrderList.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ protected function parseXML($xml){
224224
}
225225
if (isset($x->FulfillmentMethod)){
226226
//deprecated
227-
$this->orderList[$i]['FulfillmentPolicy'] = (string)$x->FulfillmentMethod;
227+
$this->orderList[$i]['FulfillmentMethod'] = (string)$x->FulfillmentMethod;
228228
}
229229
$this->orderList[$i]['ReceivedDateTime'] = (string)$x->ReceivedDateTime;
230230
$this->orderList[$i]['FulfillmentOrderStatus'] = (string)$x->FulfillmentOrderStatus;
@@ -239,16 +239,20 @@ protected function parseXML($xml){
239239
$this->orderList[$i]['CODSettings']['IsCODRequired'] = (string)$x->CODSettings->IsCODRequired;
240240
}
241241
if (isset($x->CODSettings->CODCharge)){
242-
$this->orderList[$i]['CODSettings']['CODCharge'] = (string)$x->CODSettings->CODCharge;
242+
$this->orderList[$i]['CODSettings']['CODCharge']['CurrencyCode'] = (string)$x->CODSettings->CODCharge->CurrencyCode;
243+
$this->orderList[$i]['CODSettings']['CODCharge']['Value'] = (string)$x->CODSettings->CODCharge->Value;
243244
}
244245
if (isset($x->CODSettings->CODChargeTax)){
245-
$this->orderList[$i]['CODSettings']['CODChargeTax'] = (string)$x->CODSettings->CODChargeTax;
246+
$this->orderList[$i]['CODSettings']['CODChargeTax']['CurrencyCode'] = (string)$x->CODSettings->CODChargeTax->CurrencyCode;
247+
$this->orderList[$i]['CODSettings']['CODChargeTax']['Value'] = (string)$x->CODSettings->CODChargeTax->Value;
246248
}
247249
if (isset($x->CODSettings->ShippingCharge)){
248-
$this->orderList[$i]['CODSettings']['ShippingCharge'] = (string)$x->CODSettings->ShippingCharge;
250+
$this->orderList[$i]['CODSettings']['ShippingCharge']['CurrencyCode'] = (string)$x->CODSettings->ShippingCharge->CurrencyCode;
251+
$this->orderList[$i]['CODSettings']['ShippingCharge']['Value'] = (string)$x->CODSettings->ShippingCharge->Value;
249252
}
250253
if (isset($x->CODSettings->ShippingChargeTax)){
251-
$this->orderList[$i]['CODSettings']['ShippingChargeTax'] = (string)$x->CODSettings->ShippingChargeTax;
254+
$this->orderList[$i]['CODSettings']['ShippingChargeTax']['CurrencyCode'] = (string)$x->CODSettings->ShippingChargeTax->CurrencyCode;
255+
$this->orderList[$i]['CODSettings']['ShippingChargeTax']['Value'] = (string)$x->CODSettings->ShippingChargeTax->Value;
252256
}
253257
$this->index++;
254258
}

includes/classes/AmazonInventoryList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function setUseToken($b = true){
8181
* were updated after the given time.
8282
* If this parameters is set, seller SKUs cannot be set.
8383
* The parameter is passed through <i>strtotime</i>, so values such as "-1 hour" are fine.
84-
* @param string $s <p>Time string.</p>
84+
* @param string $t <p>Time string.</p>
8585
* @return boolean <b>FALSE</b> if improper input
8686
*/
8787
public function setStartTime($t = null){
@@ -101,7 +101,7 @@ public function setStartTime($t = null){
101101
* This method sets the list of seller SKUs to be sent in the next request.
102102
* Setting this parameter tells Amazon to only return inventory supplies that match
103103
* the IDs in the list. If this parameter is set, Start Time cannot be set.
104-
* @param array|string $s <p>A list of Seller SKUs, or a single ID string.</p>
104+
* @param array|string $a <p>A list of Seller SKUs, or a single ID string.</p>
105105
* @return boolean <b>FALSE</b> if improper input
106106
*/
107107
public function setSellerSkus($a){

includes/classes/AmazonOrderList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,11 @@ public function setMaxResultsPerPage($num){
370370
public function setTfmShipmentStatusFilter($list){
371371
if (is_string($list)){
372372
//if single string, set as filter
373-
$this->resetOrderStatusFilter();
373+
$this->resetTfmShipmentStatusFilter();
374374
$this->options['TFMShipmentStatus.Status.1'] = $list;
375375
} else if (is_array($list)){
376376
//if array of strings, set all filters
377-
$this->resetOrderStatusFilter();
377+
$this->resetTfmShipmentStatusFilter();
378378
$i = 1;
379379
foreach($list as $x){
380380
$this->options['TFMShipmentStatus.Status.'.$i] = $x;

includes/classes/AmazonShipmentItemList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ protected function parseXML($xml){
242242
$a['QuantityInCase'] = (string)$x->QuantityInCase;
243243
}
244244
if (isset($x->PrepDetailsList)) {
245-
foreach ($x->PrepDetailsList as $z) {
245+
foreach ($x->PrepDetailsList->children() as $z) {
246246
$temp = array();
247247
$temp['PrepInstruction'] = (string)$z->PrepInstruction;
248248
$temp['PrepOwner'] = (string)$z->PrepOwner;

test-cases/includes/classes/AmazonFeedListTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,16 @@ public function testFetchFeedSubmissions(){
168168
$this->assertEquals('_MOCK_FEED_',$r[0]['FeedType']);
169169
$this->assertEquals('2012-12-12T12:12:12+00:00',$r[0]['SubmittedDate']);
170170
$this->assertEquals('_SUBMITTED_',$r[0]['FeedProcessingStatus']);
171+
$this->assertEquals('2012-12-15T12:12:12+00:00',$r[0]['StartedProcessingDate']);
172+
$this->assertEquals('2012-12-16T12:12:12+00:00',$r[0]['CompletedProcessingDate']);
171173

172174
$this->assertFalse($this->object->hasToken());
173175

174176
return $this->object;
175177
}
176178

177179
/**
180+
* @param AmazonFeedList $o
178181
* @depends testFetchFeedSubmissions
179182
*/
180183
public function testGetFeedInfo($o){
@@ -188,6 +191,8 @@ public function testGetFeedInfo($o){
188191
$this->assertArrayHasKey('FeedType',$info);
189192
$this->assertArrayHasKey('SubmittedDate',$info);
190193
$this->assertArrayHasKey('FeedProcessingStatus',$info);
194+
$this->assertArrayHasKey('StartedProcessingDate',$info);
195+
$this->assertArrayHasKey('CompletedProcessingDate',$info);
191196

192197
$id = $o->getFeedId();
193198
$type = $o->getFeedType();
@@ -199,17 +204,23 @@ public function testGetFeedInfo($o){
199204
$this->assertEquals($info['FeedType'],$type);
200205
$this->assertEquals($info['SubmittedDate'],$date);
201206
$this->assertEquals($info['FeedProcessingStatus'],$status);
207+
$this->assertEquals($info['StartedProcessingDate'], $o->getDateStarted());
208+
$this->assertEquals($info['CompletedProcessingDate'],$o->getDateCompleted());
202209

203210
$this->assertFalse($o->getFeedInfo(null));
204211
$this->assertFalse($o->getFeedId(null));
205212
$this->assertFalse($o->getFeedType(null));
206213
$this->assertFalse($o->getDateSubmitted(null));
207214
$this->assertFalse($o->getFeedStatus(null));
215+
$this->assertFalse($o->getDateStarted(null));
216+
$this->assertFalse($o->getDateCompleted(null));
208217
$this->assertFalse($o->getFeedInfo('string'));
209218
$this->assertFalse($o->getFeedId('string'));
210219
$this->assertFalse($o->getFeedType('string'));
211220
$this->assertFalse($o->getDateSubmitted('string'));
212221
$this->assertFalse($o->getFeedStatus('string'));
222+
$this->assertFalse($o->getDateStarted('string'));
223+
$this->assertFalse($o->getDateCompleted('string'));
213224

214225
$this->assertFalse($this->object->getFeedList()); //not fetched yet for this object
215226
}

0 commit comments

Comments
 (0)