Reformat the JSON test for Shop/Tax.t
Add JSON tets to Shop/Transaction.t Reindent several methods in SQL/ResultSet.pm add a method for returning a YUI Data Table structure to SQL.pm
This commit is contained in:
parent
94b03aa3f5
commit
4db53bb8ed
5 changed files with 94 additions and 13 deletions
12
t/Shop/Tax.t
12
t/Shop/Tax.t
|
|
@ -607,7 +607,6 @@ is($taxer->calculate($cart), 5.5, 'calculate: simple tax calculation on 2 items
|
|||
|
||||
$session->user({userId=>3});
|
||||
my $json = $taxer->www_getTaxesAsJson();
|
||||
diag $json;
|
||||
ok($json, 'www_getTaxesAsJson returned something');
|
||||
my $jsonTax = JSON::from_json($json);
|
||||
cmp_deeply(
|
||||
|
|
@ -618,9 +617,16 @@ cmp_deeply(
|
|||
totalRecords => 1778,
|
||||
recordsReturned => 25,
|
||||
dir => 'desc',
|
||||
records => array_each({taxId=>ignore, country => 'USA', state=>ignore, city=>ignore, code=>ignore, taxRate=>re('^\d+\.\d+$')}),
|
||||
records => array_each({
|
||||
taxId=>ignore,
|
||||
country => 'USA',
|
||||
state=>ignore,
|
||||
city=>ignore,
|
||||
code=>ignore,
|
||||
taxRate=>re('^\d+\.\d+$')
|
||||
}),
|
||||
},
|
||||
'Check major elements of JSON',
|
||||
'Check major elements of tax JSON',
|
||||
);
|
||||
|
||||
$taxableDonation->purge;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 64; # Increment this number for each test you create
|
||||
plan tests => 66; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -183,13 +183,48 @@ my $icopy = $transaction->getItem($item->getId);
|
|||
isa_ok($icopy, "WebGUI::Shop::TransactionItem");
|
||||
is($icopy->getId, $item->getId, "items are the same");
|
||||
|
||||
# get itmes
|
||||
# get items
|
||||
is(scalar @{$transaction->getItems}, 1, "can retrieve items");
|
||||
|
||||
# delete
|
||||
$item->delete;
|
||||
is(scalar @{$transaction->getItems}, 0, "can delete items");
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# www_getTaxesAsJson
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
$session->user({userId=>3});
|
||||
my $json = WebGUI::Shop::Transaction->www_getTransactionsAsJson($session);
|
||||
ok($json, 'www_getTransactionsAsJson returned something');
|
||||
my $jsonTransactions = JSON::from_json($json);
|
||||
cmp_deeply(
|
||||
$jsonTransactions,
|
||||
{
|
||||
sort => undef,
|
||||
startIndex => 0,
|
||||
totalRecords => 1,
|
||||
recordsReturned => 1,
|
||||
dir => 'desc',
|
||||
records => array_each({
|
||||
orderNumber=>ignore,
|
||||
transactionId=>ignore,
|
||||
transactionCode=>ignore,
|
||||
paymentDriverLabel=>ignore,
|
||||
dateOfPurchase=>ignore,
|
||||
username=>ignore,
|
||||
amount=>ignore,
|
||||
isSuccessful=>ignore,
|
||||
statusCode=>ignore,
|
||||
statusMessage=>ignore,
|
||||
}),
|
||||
},
|
||||
'Check major elements of transaction JSON',
|
||||
);
|
||||
|
||||
|
||||
$transaction->delete;
|
||||
is($session->db->quickScalar("select transactionId from transaction where transactionId=?",[$transaction->getId]), undef, "can delete transactions");
|
||||
|
||||
|
|
@ -198,5 +233,5 @@ is($session->db->quickScalar("select transactionId from transaction where transa
|
|||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
$session->db->write('delete from transaction');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue