add a basic test for CartItemCount macro
This commit is contained in:
parent
49b06039d6
commit
1489c9331e
1 changed files with 66 additions and 0 deletions
66
t/Macro/CartItemCount.t
Normal file
66
t/Macro/CartItemCount.t
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use HTML::TokeParser;
|
||||
use Data::Dumper;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $numTests = 4;
|
||||
|
||||
$numTests += 1; #For the use_ok
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
my $macro = 'WebGUI::Macro::CartItemCount';
|
||||
my $loaded = use_ok($macro);
|
||||
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
my $donation = WebGUI::Asset->getRoot($session)->addChild({
|
||||
className => 'WebGUI::Asset::Sku::Donation',
|
||||
title => 'Charitable donation',
|
||||
defaultPrice => 10.00,
|
||||
});
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
||||
|
||||
my $output;
|
||||
|
||||
$output = WebGUI::Macro::CartItemCount::process($session);
|
||||
is ($output, '0', 'Empty cart returns 0 items');
|
||||
|
||||
my $item1 = $cart->addItem($donation);
|
||||
$output = WebGUI::Macro::CartItemCount::process($session);
|
||||
is ($output, '1', 'Cart contains 1 item');
|
||||
|
||||
my $item2 = $cart->addItem($donation);
|
||||
$output = WebGUI::Macro::CartItemCount::process($session);
|
||||
is ($output, '2', 'Cart contains 2 items, 1 each');
|
||||
|
||||
$item2->setQuantity(10);
|
||||
$output = WebGUI::Macro::CartItemCount::process($session);
|
||||
is ($output, '11', 'Cart contains 11 items, 1 and 10');
|
||||
|
||||
}
|
||||
|
||||
END {
|
||||
$cart->delete;
|
||||
$donation->purge;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue