Example #1
0
 /**
  * Test validation in the setters
  */
 public function testFaultyProperties()
 {
     $label = new Label();
     try {
         $label->setMimeType(str_repeat('a', 9));
     } catch (\Exception $e) {
         $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e);
         $this->assertEquals('Invalid value, possible values are: ' . implode(', ', Label::getPossibleMimeTypeValues()) . '.', $e->getMessage());
     }
 }
Example #2
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return Label
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $label = new Label();
     if (isset($xml->barcode) && $xml->barcode != '') {
         $label->setBarcode((string) $xml->barcode);
     }
     if (isset($xml->mimeType) && $xml->mimeType != '') {
         $label->setMimeType((string) $xml->mimeType);
     }
     if (isset($xml->bytes) && $xml->bytes != '') {
         $label->setBytes((string) base64_decode($xml->bytes));
     }
     return $label;
 }