From 288fd54b17c5aa2be6888681f881416f59fad91f Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 5 Jun 2008 19:57:01 +0000 Subject: [PATCH] tests for exporting, and some bug fixes in exportProducts --- lib/WebGUI/Shop/Products.pm | 6 ++++-- t/Shop/Products.t | 13 ++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Shop/Products.pm b/lib/WebGUI/Shop/Products.pm index c618e7942..eb3ffb72a 100644 --- a/lib/WebGUI/Shop/Products.pm +++ b/lib/WebGUI/Shop/Products.pm @@ -42,12 +42,14 @@ sub exportProducts { my @columns = qw{sku title shortdescription price weight quantity}; my $productData = WebGUI::Text::joinCSV('mastersku', @columns) . "\n"; @columns = map { $_ eq 'shortdescription' ? 'shortdesc' : $_ } @columns; - while (my $product = WebGUI::Asset::Sku::Product->getAllProducts($session)) { + my $getAProduct = WebGUI::Asset::Sku::Product->getIsa($session); + while (my $product = $getAProduct->()) { my $mastersku = $product->get('sku'); my $collateri = $product->getAllCollateral('variantsJSON'); foreach my $collateral (@{ $collateri }) { my @productFields = @{ $collateral }{ @columns }; - $productData .= WebGUI::Test::joinCSV($mastersku, @productFields); + $productData .= WebGUI::Text::joinCSV($mastersku, @productFields); + $productData .= "\n"; } } my $storage = WebGUI::Storage->createTemp($session); diff --git a/t/Shop/Products.t b/t/Shop/Products.t index c7132cec0..1d3005e68 100644 --- a/t/Shop/Products.t +++ b/t/Shop/Products.t @@ -33,7 +33,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 22; +my $tests = 25; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -189,6 +189,17 @@ SKIP: { 'collateral set correctly for shirt' ); + ####################################################################### + # + # export + # + ####################################################################### + + my $products = WebGUI::Shop::Products::exportProducts($session); + isa_ok($products, 'WebGUI::Storage', 'exportProducts returns a Storage object'); + is(scalar @{ $products->getFiles }, 1, 'The storage contains just 1 file...'); + is(scalar $products->getFiles->[0], 'siteProductData.csv', '...with the correct filename'); + } #----------------------------------------------------------------------------