/** * @depends testFetchItems */ public function testGetItems($o) { $shipment = $o->getItems(0); $this->assertInternalType('array', $shipment); $list = $o->getItems(null); $this->assertInternalType('array', $list); $this->assertArrayHasKey(0, $list); $this->assertArrayHasKey(1, $list); $this->assertEquals($shipment, $list[0]); $default = $o->getItems(); $this->assertEquals($list, $default); $x = array(); $x1 = array(); $x1['ShipmentId'] = 'SSF85DGIZZ3OF1'; $x1['SellerSKU'] = 'SampleSKU1'; $x1['QuantityShipped'] = '3'; $x1['QuantityInCase'] = '0'; $x1['QuantityReceived'] = '0'; $x1['FulfillmentNetworkSKU'] = 'B000FADVPQ'; $x[0] = $x1; $x2 = array(); $x2['ShipmentId'] = 'SSF85DGIZZ3OF1'; $x2['SellerSKU'] = 'SampleSKU2'; $x2['QuantityShipped'] = '10'; $x2['QuantityInCase'] = '0'; $x2['QuantityReceived'] = '0'; $x2['FulfillmentNetworkSKU'] = 'B0011VECH4'; $x[1] = $x2; $this->assertEquals($x, $list); $this->assertFalse($this->object->getItems()); //not fetched yet for this object }
/** * Returns array of item lists or a single item list. * * If <i>$i</i> is not specified, the method will fetch the items for every * shipment in the list. Please note that for lists with a high number of shipments, * this operation could take a while due to throttling. (Two seconds per order when throttled.) * @param int $i [optional] <p>List index to retrieve the value from. Defaults to null.</p> * @param boolean $token [optional] <p>whether or not to automatically use tokens when fetching items.</p> * @return array|AmazonShipmentItemList <i>AmazonShipmentItemList</i> object or array of objects, or <b>FALSE</b> if non-numeric index */ public function fetchItems($i = null, $token = false) { if (!isset($this->shipmentList)) { return false; } if (is_null($i)) { $a = array(); $n = 0; foreach ($this->shipmentList as $x) { $a[$n] = new AmazonShipmentItemList($this->storeName, $x['ShipmentId'], $this->mockMode, $this->mockFiles, $this->config); $a[$n]->setUseToken($token); $a[$n]->mockIndex = $this->mockIndex; $a[$n]->fetchItems(); $n++; } return $a; } else { if (is_int($i)) { $temp = new AmazonShipmentItemList($this->storeName, $this->shipmentList[$i]['ShipmentId'], $this->mockMode, $this->mockFiles, $this->config); $temp->setUseToken($token); $temp->mockIndex = $this->mockIndex; $temp->fetchItems(); return $temp; } else { return false; } } }