From a75cd108b1c79faed98c07dd345a38bf2d2ea38e Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 24 Apr 2009 03:47:40 +0000 Subject: [PATCH] Add back code for throwing exceptions when session is not passed to class methods. --- lib/WebGUI/Shop/Tax.pm | 6 ++++++ t/Shop/Tax.t | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Shop/Tax.pm b/lib/WebGUI/Shop/Tax.pm index 9e5fdbc4b..6934423d7 100644 --- a/lib/WebGUI/Shop/Tax.pm +++ b/lib/WebGUI/Shop/Tax.pm @@ -128,6 +128,9 @@ A WebGUI::Session object. Required in class context, optional in instance contex sub getDriver { my $self = shift; my $session = shift || $self->session; + unless (defined $session && $session->isa("WebGUI::Session")) { + WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error=>"Need a session."); + } my $className = $session->setting->get( 'activeTaxPlugin' ); my $driver = eval { @@ -152,6 +155,9 @@ Constructor for the WebGUI::Shop::Tax. Returns a WebGUI::Shop::Tax object. sub new { my $class = shift; my $session = shift; + unless (defined $session && $session->isa("WebGUI::Session")) { + WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error=>"Need a session."); + } my $self = {}; bless $self, $class; register $self; diff --git a/t/Shop/Tax.t b/t/Shop/Tax.t index a923d8dfc..3149055bb 100644 --- a/t/Shop/Tax.t +++ b/t/Shop/Tax.t @@ -98,8 +98,6 @@ SKIP: { isa_ok( $e, 'WebGUI::Error::InvalidParam', 'getDriver throws error when no session object is passed in class context' ); is( $e->error, 'Need a session.', 'getDriver passes correct message for ommitted session object' ); - - TODO: { local $TODO = 'test www_ methods'; #######################################################################