Beispiel #1
0
 /**
  * Tests Day->toXML
  */
 public function testToXML()
 {
     $data = array('parcelValue' => '700', 'contentDescription' => 'BOOK', 'shipmentType' => 'DOCUMENTS', 'parcelReturnInstructions' => 'RTS', 'privateAddress' => false);
     $expectedDocument = self::createDomDocument();
     $customsInfo = $expectedDocument->createElement('customsInfo');
     foreach ($data as $key => $value) {
         if ($key == 'privateAddress') {
             $value = $value ? 'true' : 'false';
         }
         $customsInfo->appendChild($expectedDocument->createElement($key, $value));
     }
     $expectedDocument->appendChild($customsInfo);
     $actualDocument = self::createDomDocument();
     $customsInfo = new CustomsInfo();
     $customsInfo->setParcelValue($data['parcelValue']);
     $customsInfo->setContentDescription($data['contentDescription']);
     $customsInfo->setShipmentType($data['shipmentType']);
     $customsInfo->setParcelReturnInstructions($data['parcelReturnInstructions']);
     $customsInfo->setPrivateAddress($data['privateAddress']);
     $actualDocument->appendChild($customsInfo->toXML($actualDocument, null));
     $this->assertEquals($expectedDocument, $actualDocument);
     $data = array('parcelValue' => '700', 'contentDescription' => 'BOOK', 'shipmentType' => 'DOCUMENTS', 'parcelReturnInstructions' => 'RTS', 'privateAddress' => true);
     $expectedDocument = self::createDomDocument();
     $customsInfo = $expectedDocument->createElement('customsInfo');
     foreach ($data as $key => $value) {
         if ($key == 'privateAddress') {
             $value = $value ? 'true' : 'false';
         }
         $customsInfo->appendChild($expectedDocument->createElement($key, $value));
     }
     $expectedDocument->appendChild($customsInfo);
     $actualDocument = self::createDomDocument();
     $customsInfo = new CustomsInfo();
     $customsInfo->setParcelValue($data['parcelValue']);
     $customsInfo->setContentDescription($data['contentDescription']);
     $customsInfo->setShipmentType($data['shipmentType']);
     $customsInfo->setParcelReturnInstructions($data['parcelReturnInstructions']);
     $customsInfo->setPrivateAddress($data['privateAddress']);
     $actualDocument->appendChild($customsInfo->toXML($actualDocument));
     $this->assertEquals($expectedDocument, $actualDocument);
 }