Esempio n. 1
0
 /**
  * Tests Customer->toXML
  */
 public function testToXML()
 {
     $data = array('FirstName' => 'Tijs', 'LastName' => 'Verkoyen', 'Email' => '*****@*****.**', 'Street' => 'Afrikalaan', 'Number' => '289', 'MobilePrefix' => '0032', 'MobileNumber' => '486123456', 'PostalCode' => '9000', 'PreferredLanguage' => 'nl-BE', 'Title' => 'Mr.');
     $expectedDocument = self::createDomDocument();
     $customer = $expectedDocument->createElement('Customer');
     $customer->setAttribute('xmlns', 'http://schema.post.be/ServiceController/customer');
     $customer->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $customer->setAttribute('xsi:schemaLocation', 'http://schema.post.be/ServiceController/customer');
     $customer->appendChild($expectedDocument->createElement('FirstName', $data['FirstName']));
     $customer->appendChild($expectedDocument->createElement('LastName', $data['LastName']));
     $customer->appendChild($expectedDocument->createElement('Street', $data['Street']));
     $customer->appendChild($expectedDocument->createElement('Number', $data['Number']));
     $customer->appendChild($expectedDocument->createElement('Email', $data['Email']));
     $customer->appendChild($expectedDocument->createElement('MobilePrefix', $data['MobilePrefix']));
     $customer->appendChild($expectedDocument->createElement('MobileNumber', $data['MobileNumber']));
     $customer->appendChild($expectedDocument->createElement('PostalCode', $data['PostalCode']));
     $customer->appendChild($expectedDocument->createElement('PreferredLanguage', $data['PreferredLanguage']));
     $customer->appendChild($expectedDocument->createElement('Title', $data['Title']));
     $expectedDocument->appendChild($customer);
     $customer = new Customer();
     $customer->setFirstName($data['FirstName']);
     $customer->setLastName($data['LastName']);
     $customer->setEmail($data['Email']);
     $customer->setStreet($data['Street']);
     $customer->setNumber($data['Number']);
     $customer->setMobileNumber($data['MobileNumber']);
     $customer->setPostalCode($data['PostalCode']);
     $customer->setPreferredLanguage($data['PreferredLanguage']);
     $customer->setTitle($data['Title']);
     $actualDocument = self::createDomDocument();
     $actualDocument->appendChild($customer->toXML($actualDocument));
     $this->assertEquals($expectedDocument->saveXML(), $actualDocument->saveXML());
 }
Esempio n. 2
0
 public function createMember(Customer $customer)
 {
     $url = '/customer';
     $document = new \DOMDocument('1.0', 'utf-8');
     $document->preserveWhiteSpace = false;
     $document->formatOutput = true;
     $document->appendChild($customer->toXML($document));
     return $this->doCall($url, $document->saveXML(), 'POST');
 }