From 9b8464291ce806414ea1cc4bc142c0d3c83109f9 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Thu, 1 Jan 2015 18:19:24 -0500 Subject: [PATCH] Beginnings of OptionFields tester. I've noticed that the PII_Options field doesn't seem to properly contain the values it should. This is the beginning of a test file for what PII_Options should contain. The initial step here is to simply create one of my forms to create a test transaction, and verify that the transaction has been created. --- .gitignore | 1 + t/OptionFields.t | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 t/OptionFields.t diff --git a/.gitignore b/.gitignore index eac2520..bacccc4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ auth.txt blib perltidy.LOG pm_to_blib +options-payment.html diff --git a/t/OptionFields.t b/t/OptionFields.t new file mode 100644 index 0000000..ff1881b --- /dev/null +++ b/t/OptionFields.t @@ -0,0 +1,76 @@ +# This file is part of Business:PayPal:API Module. License: Same as Perl. See its README for details. +# -*- mode: cperl -*- +use Test::More; +use strict; +if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) { + plan skip_all => + 'No WPP_TEST env var set. Please see README to run tests'; +} +else { + plan tests => 4; +} + +use_ok( 'Business::PayPal::API::TransactionSearch' ); +use_ok( 'Business::PayPal::API::GetTransactionDetails' ); + +######################### + +require 't/API.pl'; + +my %args = do_args(); + +=pod + +These tests verify the options work. + +=cut + + +open(OPTIONS_PAY_HTML, ">", "options-payment.html") + or die "unable to open options-payment.html: $!"; +print OPTIONS_PAY_HTML <<_OPTIONS_PAYMENT_DATA_ + + +
+ + + + + + + + + + +
+_OPTIONS_PAYMENT_DATA_ + ; +close(OPTIONS_PAY_HTML); die "unable to write options-payment.html: $!" if ($? != 0); + +use Cwd; my $cwd = getcwd; + +print STDERR <<"_OPTIONS_LINK_"; +Please note the next series of tests will not succeeed unless there is at +least one transaction that is part of a subscription payments in your business +account. + +if you haven't made one yet, you can visit: + file://$cwd/options-payment.html + +and use the sandbox buyer account to make the payment. +_OPTIONS_LINK_ + +my $startdate = '1998-01-01T01:45:10.00Z'; + +my $ts = new Business::PayPal::API::TransactionSearch( %args ); +my $td = new Business::PayPal::API::GetTransactionDetails( %args ); + +my $resp = $ts->TransactionSearch(StartDate => $startdate); +my %detail; +foreach my $record (@{$resp}) { + %detail = $td->GetTransactionDetails(TransactionID => $record->{TransactionID}); + last if $detail{PII_Name} =~ /Field\s+Options/i; +} +like($detail{PaymentItems}[0]{Name}, qr/Field\s+Options/i, 'Found field options test transaction'); +like($detail{PII_Name}, qr/Field\s+Options/i, 'Found field options test transaction'); +