Esempio n. 1
0
    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);
    }
Esempio n. 2
0
 /**
  * Test Test Insert No Key
  */
 function testInsertNoKey()
 {
     $this->initScript('line-item-init.sql');
     $item = new LineItem();
     $item->setId(100);
     $item->setCode("blah");
     $item->setOrder(new Order());
     $item->getOrder()->setId(9);
     $item->setPrice(44.0);
     $item->setQuantity(1);
     $key = $this->sqlmap->Insert("InsertLineItemNoKey", $item);
     $this->assertNull($key);
     $this->assertIdentical(100, $item->getId());
     $param["Order_ID"] = 9;
     $param["LineItem_ID"] = 100;
     $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
     $this->assertNotNull($testItem);
     $this->assertIdentical(100, $testItem->getId());
     $this->initScript('line-item-init.sql');
 }