From 70b833179493985550befef9eb9f19d4d466c08a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 15 Feb 2008 22:15:58 +0000 Subject: [PATCH] Add the tax table. Add the getItems method, for accessing the entire tax table. --- docs/upgrades/upgrade_7.5.2-7.5.3.pl | 21 +++++++++++++++++++++ lib/WebGUI/Shop/Tax.pm | 19 ++++++++++++++++++- t/Shop/Tax.t | 8 +++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/docs/upgrades/upgrade_7.5.2-7.5.3.pl b/docs/upgrades/upgrade_7.5.2-7.5.3.pl index 1bd5461cc..bbdca04e0 100644 --- a/docs/upgrades/upgrade_7.5.2-7.5.3.pl +++ b/docs/upgrades/upgrade_7.5.2-7.5.3.pl @@ -24,6 +24,8 @@ my $session = start(); # this line required # upgrade functions go here +insertCommerceTaxTable($session); + finish($session); # this line required @@ -34,6 +36,25 @@ finish($session); # this line required # # and here's our code #} +#------------------------------------------------- +sub insertCommerceTaxTable { + my $session = shift; + print "\tInstall the Commerce Tax Table.\n" unless ($quiet); + # and here's our code + $session->db->write(< my %session; #------------------------------------------------------------------- +=head2 getItems ( ) + +Returns a WebGUI::SQL::Result object for accessing all of the data in the tax table. This +is a convenience method for listing and/or exporting tax data. + +=cut + +sub getItems { + my $self = shift; + my $result = $self->session->db->read('select * from tax'); + return $result; +} + +#------------------------------------------------------------------- + =head2 new ( $session ) Constructor for the WebGUI::Shop::Tax. Returns a WebGUI::Shop::Tax object. diff --git a/t/Shop/Tax.t b/t/Shop/Tax.t index b4c0c0c20..fd2f69d6c 100644 --- a/t/Shop/Tax.t +++ b/t/Shop/Tax.t @@ -27,7 +27,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 3; +my $tests = 5; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -47,6 +47,12 @@ isa_ok($taxer->session, 'WebGUI::Session', 'session method returns a session obj is($session->getId, $taxer->session->getId, 'session method returns OUR session object'); +my $taxIterator = $taxer->getItems; + +isa_ok($taxIterator, 'WebGUI::SQL::ResultSet'); + +is($taxIterator->rows, 0, 'WebGUI ships with no predefined tax data'); + }