tests for exporting, and some bug fixes in exportProducts
This commit is contained in:
parent
f87e32452a
commit
288fd54b17
2 changed files with 16 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue