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); }
function testConstructorShouldNotAppendRandomIdToTransactionId() { Config::setIdSeparator(false); $p = new PaymentRequest($this->fixture('wpf_payment_request_simple.json')); $p->validate(); $this->assertPattern('/^wev238f328nc$/', $p->transaction_id); }
function testSetIdSeparatorShouldWorkWithString() { Config::setIdSeparator('<<<'); $this->assertTrue(Config::hasIdSeparator()); $this->assertEqual('<<<', Config::getIdSeparator()); }
function setUp() { $this->credentials(); Config::setIdSeparator('---'); $this->channelToken = $this->credentials->channelTokens->USD; }
function testExtractRandomIdWithCustomDivider() { Config::setIdSeparator('###'); $o = Helper::extractRandomId('an---order---id###adef-ag#exg'); $this->assertEqual('an---order---id', $o->transaction_id); $this->assertEqual('adef-ag#exg', $o->random_id); }