remap_fields() is actually buggy in 2.x -- copying from 3.x
[Business-OnlinePayment-InternetSecure.git] / t / 20emit.t
index 7fac2d6..8ba4804 100755 (executable)
@@ -1,4 +1,6 @@
-use Test::More tests => 4 + 2;
+# vim:set syntax=perl encoding=utf-8:
+
+use Test::More tests => 4 + 3;
 
 BEGIN { use_ok('Business::OnlinePayment') };
 BEGIN { use_ok('Business::OnlinePayment::InternetSecure') };
@@ -14,7 +16,7 @@ use constant TRANSACTIONS => (
                action          => 'Normal Authorization',
 
                type            => 'Visa',
-               card_number     => '0000000000000000',
+               card_number     => '4111 1111 1111 1111',
                exp_date        => '2004-07',
                cvv2            => '000',
 
@@ -29,8 +31,8 @@ use constant TRANSACTIONS => (
                email           => 'fbriere@fbriere.net',
 
                amount          => undef,
-               currency        => 'CAD',
-               taxes           => 'GST PST',
+               currency        => 'USD',
+               taxes           => 'HST',
 
                description => [
                                {
@@ -42,11 +44,12 @@ use constant TRANSACTIONS => (
                                {
                                amount          => 5.65,
                                description     => 'Shipping',
+                               taxes           => 'GST PST',
                                },
                                {
                                amount          => 10.00,
                                description     => 'Some HST example',
-                               taxes           => 'HST',
+                               taxes           => [ 'GST', 'PST' ],
                                },
                                ],
        },
@@ -55,29 +58,46 @@ use constant TRANSACTIONS => (
 
                action          => 'Normal Authorization',
 
-               type            => 'Visa',
-               card_number     => '4000000000000000',
+               card_number     => '5111-1111-1111-1111',
                exp_date        => '7/2004',
 
-               name            => "Fr\x{e9}d\x{e9}ric Bri\x{e8}re",
+               name            => "\x{201c}Fr\x{e9}d\x{e9}ric Bri\x{e8}re\x{201d}",
 
                amount          => 12.95,
-               currency        => 'USD',
-               taxes           => '',
                description     => "Box o' goodies",
+               currency        => 'USD',
+               taxes           => 'GST',
+       },
+       {
+               _test           => -1,
+
+               action          => 'Normal Authorization',
+
+               card_number     => '5111-1111-1111-1111',
+               exp_date        => '0704',
+
+               name            => "Fr\x{e9}d\x{e9}ric Bri\x{e8}re",
+
+               amount          => 13.95,
        },
 );
 
 
 my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000';
 
-$/ = '';
 foreach (TRANSACTIONS) {
        $txn->test_transaction(delete $_->{_test});
        $txn->content(%$_);
+
+       my $data = do {
+               # Work around bug #17687
+               local $/ = '';
+               scalar <DATA>;
+       };
+
        is_deeply(
-               xml_in(Encode::encode('utf8', $txn->to_xml)),
-               xml_in(scalar <DATA>)
+               xml_in($txn->to_xml),
+               xml_in($data)
        ); 
 }
 
@@ -86,12 +106,12 @@ __DATA__
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <TranxRequest>
   <MerchantNumber>0000</MerchantNumber>
-  <xxxCard_Number>0000000000000000</xxxCard_Number>
+  <xxxCard_Number>4111111111111111</xxxCard_Number>
   <xxxCCMonth>07</xxxCCMonth>
   <xxxCCYear>2004</xxxCCYear>
   <CVV2>1</CVV2>
   <CVV2Indicator>000</CVV2Indicator>
-  <Products>9.99::5::a 001::Some product::{CAD}{GST}{PST}|5.65::1::::Shipping::{CAD}{GST}{PST}|10.00::1::::Some HST example::{CAD}{HST}</Products>
+  <Products>9.99::5::a 001::Some product::{USD}{HST}|5.65::1::::Shipping::{USD}{GST}{PST}|10.00::1::::Some HST example::{USD}{GST}{PST}</Products>
   <xxxName>Frédéric Brière</xxxName>
   <xxxCompany></xxxCompany>
   <xxxAddress>123 Street</xxxAddress>
@@ -115,12 +135,41 @@ __DATA__
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <TranxRequest>
   <MerchantNumber>0000</MerchantNumber>
-  <xxxCard_Number>4000000000000000</xxxCard_Number>
+  <xxxCard_Number>5111111111111111</xxxCard_Number>
+  <xxxCCMonth>07</xxxCCMonth>
+  <xxxCCYear>2004</xxxCCYear>
+  <CVV2>0</CVV2>
+  <CVV2Indicator></CVV2Indicator>
+  <Products>12.95::1::::Box o' goodies::{USD}{GST}{TEST}</Products>
+  <xxxName>?Frédéric Brière?</xxxName>
+  <xxxCompany></xxxCompany>
+  <xxxAddress></xxxAddress>
+  <xxxCity></xxxCity>
+  <xxxProvince></xxxProvince>
+  <xxxPostal></xxxPostal>
+  <xxxCountry></xxxCountry>
+  <xxxPhone></xxxPhone>
+  <xxxEmail></xxxEmail>
+  <xxxShippingName></xxxShippingName>
+  <xxxShippingCompany></xxxShippingCompany>
+  <xxxShippingAddress></xxxShippingAddress>
+  <xxxShippingCity></xxxShippingCity>
+  <xxxShippingProvince></xxxShippingProvince>
+  <xxxShippingPostal></xxxShippingPostal>
+  <xxxShippingCountry></xxxShippingCountry>
+  <xxxShippingPhone></xxxShippingPhone>
+  <xxxShippingEmail></xxxShippingEmail>
+</TranxRequest>
+
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<TranxRequest>
+  <MerchantNumber>0000</MerchantNumber>
+  <xxxCard_Number>5111111111111111</xxxCard_Number>
   <xxxCCMonth>07</xxxCCMonth>
   <xxxCCYear>2004</xxxCCYear>
   <CVV2>0</CVV2>
   <CVV2Indicator></CVV2Indicator>
-  <Products>12.95::1::::Box o' goodies::{USD}{TEST}</Products>
+  <Products>13.95::1::::::{CAD}{TESTD}</Products>
   <xxxName>Frédéric Brière</xxxName>
   <xxxCompany></xxxCompany>
   <xxxAddress></xxxAddress>