public function _testOneBook() { $bookXml = <<<XML <?xml version="1.0"?> <book itemId="0815"> <name>Book #1 Name</name> <ISBN>123456789</ISBN> <price>\$ 1.23</price> <authors> <authorName>Adam</authorName> <authorName>Bob</authorName> <authorName>Eve</authorName> </authors> <description>Book #1 Description</description> <promotion> <Discount>7%</Discount> </promotion> <publicationDate>2010-12-29</publicationDate> <bookCategory>fiction</bookCategory> </book> XML; $filepath = dirname(__FILE__) . '/../_files/Books/'; $binding = new PiBX_Runtime_Binding($filepath . '/binding.xml'); $unmarshaller = new PiBX_Runtime_Unmarshaller($binding); $book = new BookType(); $book->setName('Book #1 Name'); $book->setIsbn(123456789); $book->setPrice('$ 1.23'); $book->setAuthorNames(array('Adam', 'Bob', 'Eve')); $book->setDescription('Book #1 Description'); $book->setPromotionDiscount('7%'); $book->setPublicationdate('2010-12-29'); $book->setBookcategory('fiction'); $book->setItemId('0815'); $object = $unmarshaller->unmarshal($bookXml); $this->assertEquals($book, $object); }
public function testUnmarshalling() { $booksXml = <<<XML <?xml version="1.0"?> <purchase-order xmlns="http://openuri.org/easypo"> <customer> <name>Gladys Kravitz</name> <address>Anytown, PA</address> </customer> <date>2003-01-07T14:16:00-05:00</date> <line-item> <description>Burnham's Celestial Handbook, Vol 1</description> <per-unit-ounces>5</per-unit-ounces> <price>21.79</price> <quantity>2</quantity> </line-item> <line-item> <description>Burnham's Celestial Handbook, Vol 2</description> <per-unit-ounces>5</per-unit-ounces> <price>19.89</price> <quantity>2</quantity> </line-item> <shipper> <name>ZipShip</name> <per-ounce-rate>0.74</per-ounce-rate> </shipper> </purchase-order> XML; $filepath = dirname(__FILE__) . '/../../_files/EasyPO/'; $binding = new PiBX_Runtime_Binding($filepath . '/binding.xml'); $unmarshaller = new PiBX_Runtime_Unmarshaller($binding); $po = new PurchaseOrder(); $po->setDate('2003-01-07T14:16:00-05:00'); $customer = new Customer(); $customer->setName('Gladys Kravitz'); $customer->setAddress('Anytown, PA'); $lineItem1 = new LineItem(); $lineItem1->setDescription('Burnham\'s Celestial Handbook, Vol 1'); $lineItem1->setPerUnitOunces('5'); $lineItem1->setPrice(21.79); $lineItem1->setQuantity(2); $lineItem2 = new LineItem(); $lineItem2->setDescription('Burnham\'s Celestial Handbook, Vol 2'); $lineItem2->setPerUnitOunces('5'); $lineItem2->setPrice(19.89); $lineItem2->setQuantity(2); $shipper = new Shipper(); $shipper->setName('ZipShip'); $shipper->setPerOunceRate(0.74); $po->setCustomer($customer); $po->setLineItems(array($lineItem1, $lineItem2)); $po->setShipper($shipper); $object = $unmarshaller->unmarshal($booksXml); $this->assertEquals($po, $object); }