tests are getting closer to working
This commit is contained in:
parent
d207994e90
commit
449c3c26e0
4 changed files with 29 additions and 82 deletions
|
|
@ -30,7 +30,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 9; # Increment this number for each test you create
|
||||
plan tests => 14; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -41,13 +41,21 @@ isa_ok($cart, "WebGUI::Shop::Cart");
|
|||
isa_ok($cart->session, "WebGUI::Session");
|
||||
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
my $product = $root->addChild($session, {
|
||||
my $product = $root->addChild({
|
||||
className=>"WebGUI::Asset::Sku",
|
||||
title=>"Test Product",
|
||||
});
|
||||
|
||||
$cart->addItem($product, 1);
|
||||
is(scalar(@{$cart->getItems}), 1, "Added an item to the cart.");
|
||||
my $item = $cart->addItem($product);
|
||||
isa_ok($item, "WebGUI::Shop::CartItem");
|
||||
isa_ok($item->cart, "WebGUI::Cart", "Does the item have a cart?");
|
||||
is(ref($item->get), "HASH", "Do we have a hash of properties?");
|
||||
|
||||
is($item->get("quantity"), 2, "Should have 1 of these in the cart.");
|
||||
$item->incrementQuantity(2);
|
||||
is($item->get("quantity"), 3, "Should have 3 of these in the cart.");
|
||||
is(scalar(@{$cart->getItems}), 1, "Should have 3 of these in the cart.");
|
||||
|
||||
like($cart->getId, qr/[A-Za-z0-9\_\-]{22}/, "Id looks like a guid.");
|
||||
|
||||
is(ref($cart->get), "HASH", "Cart properties are a hash reference.");
|
||||
|
|
@ -61,6 +69,7 @@ is($session->db->quickScalar("select count(*) from cartItems where cartId=?",[$c
|
|||
$cart->delete;
|
||||
is($cart, undef, "Can destroy cart.");
|
||||
|
||||
|
||||
$product->purge;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Shop::CartItem;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 5; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
my $product = $root->addChild($session, {
|
||||
className=>"WebGUI::Asset::Sku::Product",
|
||||
title=>"Test Product",
|
||||
price=>4.99
|
||||
});
|
||||
|
||||
my $item = WebGUI::Shop::CartItem->create($session, "XXX", $product, 2);
|
||||
isa_ok($item, "WebGUI::Shop::CartItem");
|
||||
isa_ok($item->session, "WebGUI::Session", "did we get a session");
|
||||
|
||||
is(ref($item->get), "HASH", "Do we have a hash of properties?");
|
||||
is($item->get("quantity"), 2, "Should have 2 of these in the cart.");
|
||||
is($item->delete, undef, "actually deletes the item");
|
||||
|
||||
|
||||
$product->purge;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue