diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 85b9592c5..ad8cb5983 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2016,6 +2016,22 @@ sub processTemplate { } } +#------------------------------------------------------------------- + +=head2 processStyle ( html ) + +Returns some HTML wrappered in a style. Should be overridden by subclasses, because this one actually doesn't do anything other than return the html back to you. + +=head3 html + +The content to wrap up. + +=cut + +sub processStyle { + my ($self, $output) = @_; + return $output; +} #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Sku.pm b/lib/WebGUI/Asset/Sku.pm index fcd5484a7..6452a5ba8 100644 --- a/lib/WebGUI/Asset/Sku.pm +++ b/lib/WebGUI/Asset/Sku.pm @@ -17,7 +17,7 @@ package WebGUI::Asset::Sku; use strict; use Tie::IxHash; use base 'WebGUI::Asset'; - +use WebGUI::Shop::Cart; =head1 NAME @@ -159,7 +159,13 @@ sub definition { #------------------------------------------------------------------- -=head2 getCart ( ) { +=head2 getCart ( ) + +Returns a reference to the current session's cart. + +=cut + +sub getCart { my $self = shift; return WebGUI::Shop::Cart->getCartBySession($self->session); } diff --git a/t/Asset/Sku.t b/t/Asset/Sku.t index dc97f5641..9c0ed9d39 100644 --- a/t/Asset/Sku.t +++ b/t/Asset/Sku.t @@ -30,7 +30,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 8; # Increment this number for each test you create +plan tests => 19; # Increment this number for each test you create #---------------------------------------------------------------------------- # put your tests here @@ -47,17 +47,30 @@ $sku->applyOptions({ test1 => "YY" }); -my %options = $sku->getOptions; -is($options{test1}, "YY", "Can set and get an option."); +my $options = $sku->getOptions; +is($options->{test1}, "YY", "Can set and get an option."); is($sku->getMaxAllowedInCart, 99999999, "Got a valid default max in cart."); +is($sku->getQuantityAvailable, 99999999, "skus should have an unlimited quantity by default"); +is($sku->getQuantityAvailable, $sku->getMaxAllowedInCart, "quantity available and max allowed in cart should be the same"); is($sku->getPrice, 0.00, "Got a valid default price."); is($sku->getWeight, 0, "Got a valid default weight."); is($sku->getTaxRate, undef, "Tax rate is not overridden."); $sku->update({overrideTaxRate=>1, taxRateOverride=>5}); is($sku->getTaxRate, 5, "Tax rate is overridden."); isnt($sku->processStyle, "", "Got some style information."); +is($sku->onAdjustQuantityInCart, undef, "onAdjustQuantityInCart should exist and return undef"); +is($sku->onCompletePurchase, undef, "onCompletePurchase should exist and return undef"); +is($sku->onRemoveFromCart, undef, "onRemoveFromCart should exist and return undef"); +is($sku->isRecurring, 0, "skus are not recurring by default"); +is($sku->isShippingRequired, 0, "skus are not shippable by default"); +is($sku->getConfiguredTitle, $sku->getTitle, "configured title and title should be the same by default"); + +isa_ok($sku->getCart, "WebGUI::Shop::Cart", "can get a cart object"); +my $item = $sku->addToCart; +isa_ok($item, "WebGUI::Shop::CartItem", "can add to cart"); +$item->cart->delete; my $loadSku = WebGUI::Asset::Sku->newBySku($session, $sku->get("sku")); is($loadSku->getId, $sku->getId, "newBySku() works.");