Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 622c421

Browse files
authored
Merge pull request #40 from MondstaubRepos/master
Update AmazonShipmentItemList.php Resolves #39
2 parents 64fd76c + 7994541 commit 622c421

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/AmazonShipmentItemList.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ public function resetTimeLimits()
179179
*/
180180
public function fetchItems($r = true)
181181
{
182-
if (! array_key_exists('ShipmentId', $this->options)) {
183-
$this->log('Shipment ID must be set before requesting items!', 'Warning');
182+
if (! array_key_exists('ShipmentId', $this->options) and ! (array_key_exists('LastUpdatedAfter', $this->options) and array_key_exists('LastUpdatedBefore', $this->options))) {
183+
$this->log('Shipment ID or TimeLimits must be set before requesting items!', 'Warning');
184184

185185
return false;
186186
}
187187

188+
if (array_key_exists('ShipmentId', $this->options) and (array_key_exists('LastUpdatedAfter', $this->options) or array_key_exists('LastUpdatedBefore', $this->options))) {
189+
$this->log('If Shipment ID AND TimeLimits is set, TimeLimits get ignored!', 'Warning');
190+
}
191+
188192
$this->prepareToken();
189193

190194
$url = $this->urlbase.$this->urlbranch;

tests/classes/AmazonShipmentItemListTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,25 @@ public function testFetchItems()
103103
{
104104
resetLog();
105105
$this->object->setMock(true, 'fetchShipmentItems.xml'); //no token
106-
$this->assertFalse($this->object->fetchItems()); //no ID set yet
106+
$this->assertFalse($this->object->fetchItems()); //no ID and no time is set yet
107107

108-
$this->object->setShipmentId('123');
108+
$this->object->setShipmentId('123'); //Only ID
109+
$this->assertNull($this->object->fetchItems());
110+
111+
$this->object->setShipmentId(null); //Only Tine
112+
$this->object->setTimeLimits(strtotime('now -9999 years'), strtotime('now'));
113+
$this->assertNull($this->object->fetchItems());
114+
115+
$this->object->setShipmentId('123'); //Both (Time gets ignored)
109116
$this->assertNull($this->object->fetchItems());
110117

111118
$o = $this->object->getOptions();
112119
$this->assertEquals('ListInboundShipmentItems', $o['Action']);
113120

114121
$check = parseLog();
115122
$this->assertEquals('Single Mock File set: fetchShipmentItems.xml', $check[1]);
116-
$this->assertEquals('Shipment ID must be set before requesting items!', $check[2]);
123+
$this->assertEquals('Shipment ID or TimeLimits must be set before requesting items!', $check[2]);
124+
$this->assertEquals('If Shipment ID AND TimeLimits is set, TimeLimits get ignored!', $check[4]);
117125

118126
$this->assertFalse($this->object->hasToken());
119127

0 commit comments

Comments
 (0)