function testConstructWithObject()
    {
        Config::setIdSeparator(false);
        $address = new Address(array('first_name' => 'Hans', 'last_name' => 'Müller', 'address1' => 'Domstr. 12', 'city' => 'München', 'zip_code' => '80234', 'country' => 'DE'));
        $this->assertEqual('Hans', $address->first_name);
        $this->assertEqual('DE', $address->country);
        $data = array('type' => 'MobilePayment', 'amount' => 3000, 'currency' => 'CHF', 'usage' => 'the usage', 'transaction_id' => 'test-1234', 'notification_url' => 'https://my-server.com/hypercharge/notification.php', 'billing_address' => $address);
        $r = new PaymentRequest($data);
        $r->validate();
        $this->assertIsA($r->billing_address, 'Hypercharge\\Address');
        $this->assertEqual($r->billing_address->first_name, 'Hans');
        $serializer = new XmlSerializer();
        $str = $serializer->toXml($r);
        $this->assertEqual('<?xml version="1.0" encoding="UTF-8"?>
<payment>
  <type>MobilePayment</type>
  <amount>3000</amount>
  <currency>CHF</currency>
  <usage>the usage</usage>
  <transaction_id>test-1234</transaction_id>
  <notification_url>https://my-server.com/hypercharge/notification.php</notification_url>
  <billing_address>
    <first_name>Hans</first_name>
    <last_name>Müller</last_name>
    <address1>Domstr. 12</address1>
    <city>München</city>
    <zip_code>80234</zip_code>
    <country>DE</country>
  </billing_address>
</payment>
', $str);
    }
 /**
  * @param Hypercharge\IUrl $url
  * @param Hypercharge\IRequest $request
  * @return Hypercharge\IResponse
  * @throws Hypercharge\Error
  */
 public function call(IUrl $url, IRequest $request)
 {
     $curl = Config::getFactory()->createHttpsClient(Config::getUser(), Config::getPassword());
     $serializer = new XmlSerializer();
     $responseStr = $curl->xmlPost($url->get(), $serializer->toXml($request));
     $responseDom = new \SimpleXMLElement($responseStr);
     return $request->createResponse(XmlSerializer::dom2hash($responseDom));
 }
    function testSerialize()
    {
        $c = new SimplePaymentReturningRequest('cancel', '345');
        $serializer = new XmlSerializer();
        $str = $serializer->toXml($c);
        $this->assertEqual('<?xml version="1.0" encoding="UTF-8"?>
<cancel>
  <unique_id>345</unique_id>
</cancel>
', $str);
    }