function test_add_packages_to_shipment()
{
    $shipment_number = 'TESTSHIPMENT';
    $manifest = get_manifest_from_facade();
    $label_type = AsendiaWebApiClient::LABEL_TYPE_PDF;
    $asendia_web_api_client = get_asendia_web_api_client('testuser', 'testpass', function (DummyAsendiaWsdlClient $asendia_wsdl_client) use($shipment_number, $manifest, $label_type) {
        return $asendia_wsdl_client->withAddPackagesToShipment2(get_successful_add_packages_to_shipment2_result(), $shipment_number, Xml::fromManifest($manifest)->asXML(), $label_type);
    });
    $added_shipment_packages = $asendia_web_api_client->addPackagesToShipment($shipment_number, $manifest, $label_type);
    return assert('TESTSHIPMENT' === $added_shipment_packages->getShipment()) && assert(2 === count($added_shipment_packages->getPackages())) && assert('BW00709000019' === $added_shipment_packages->getPackages()[0]->getPckId()) && assert('BWW_13940_BW00709000019.pdf' === $added_shipment_packages->getPackages()[0]->getLabelFile()) && assert('BW00709012345' === $added_shipment_packages->getPackages()[1]->getPckId()) && assert('BWW_13940_BW00709012345.pdf' === $added_shipment_packages->getPackages()[1]->getLabelFile());
}
 private static function resolveManifestToXml($manifest)
 {
     if (is_array($manifest)) {
         $xmlstring = Xml::fromProperties($manifest)->asXML();
     } elseif ($manifest instanceof Manifest) {
         $xmlstring = Xml::fromManifest($manifest)->asXML();
     } elseif (is_string($manifest)) {
         $xmlstring = $manifest;
     } else {
         $message = sprintf('Manifest must be an array of properties, and instance of %s, or an XML string.', 'Cpapdotcom\\Asendia\\Manifest\\Manifest');
         throw new InvalidArgumentException($message);
     }
     return $xmlstring;
 }
Example #3
0
 /**
  * @param array $properties
  * @param string $rootElementName
  *
  * @return \SimpleXMLElement
  */
 public static function createXmlFromProperties(array $properties, $rootElementName = 'BwwManifest')
 {
     return Manifest\Xml::fromProperties($properties, $rootElementName);
 }