Ejemplo n.º 1
0
 /**
  * Test validation in the setters
  */
 public function testFaultyProperties()
 {
     $customer = new Customer();
     try {
         $customer->setEmailAddress(str_repeat('a', 51));
     } catch (\Exception $e) {
         $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e);
         $this->assertEquals('Invalid length, maximum is 50.', $e->getMessage());
     }
     try {
         $customer->setPhoneNumber(str_repeat('a', 21));
     } catch (\Exception $e) {
         $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e);
         $this->assertEquals('Invalid length, maximum is 20.', $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 /**
  * @param  \SimpleXMLElement $xml
  * @param  Customer          $instance
  * @return Customer
  */
 public static function createFromXMLHelper(\SimpleXMLElement $xml, Customer $instance)
 {
     if (isset($xml->name) && $xml->name != '') {
         $instance->setName((string) $xml->name);
     }
     if (isset($xml->company) && $xml->company != '') {
         $instance->setCompany((string) $xml->company);
     }
     if (isset($xml->address)) {
         $instance->setAddress(Address::createFromXML($xml->address));
     }
     if (isset($xml->emailAddress) && $xml->emailAddress != '') {
         $instance->setEmailAddress((string) $xml->emailAddress);
     }
     if (isset($xml->phoneNumber) && $xml->phoneNumber != '') {
         $instance->setPhoneNumber((string) $xml->phoneNumber);
     }
     return $instance;
 }