add a test for importing product tables when the headers and fields are quoted
This commit is contained in:
parent
b8f7c6ea9d
commit
aaa1e0ab0e
2 changed files with 35 additions and 2 deletions
|
|
@ -33,7 +33,7 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $tests = 41;
|
my $tests = 44;
|
||||||
plan tests => 1 + $tests;
|
plan tests => 1 + $tests;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
@ -44,7 +44,7 @@ my $loaded = use_ok($class);
|
||||||
|
|
||||||
my $storage;
|
my $storage;
|
||||||
my ($e, $failure);
|
my ($e, $failure);
|
||||||
my $shelf;
|
my ($shelf, $shelf2);
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
|
|
||||||
|
|
@ -367,6 +367,30 @@ SKIP: {
|
||||||
'collateral added correctly for classical record'
|
'collateral added correctly for classical record'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$shelf->purge;
|
||||||
|
undef $shelf;
|
||||||
|
|
||||||
|
$record = WebGUI::Asset::Sku->newBySku($session, 'classical-records-1');
|
||||||
|
is($record, undef, 'deleting a shelf deletes all products beneath it');
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
#
|
||||||
|
# import, quoted headers and fields
|
||||||
|
#
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
$shelf2 = WebGUI::Asset->getRoot($session)->addChild({className => $class});
|
||||||
|
|
||||||
|
$pass = 0;
|
||||||
|
eval {
|
||||||
|
$pass = $shelf2->importProducts(
|
||||||
|
WebGUI::Test->getTestCollateralPath('productTables/quotedTable.csv'),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
ok($pass, 'Able to load a table with quoted fields');
|
||||||
|
$e = Exception::Class->caught();
|
||||||
|
is($e, '', 'No exception thrown on a file with quoted fields');
|
||||||
|
is($shelf2->getChildCount, 3, 'imported 3 children skus for shelf2 with quoted fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
@ -375,4 +399,7 @@ END {
|
||||||
if (defined $shelf and ref $shelf eq $class) {
|
if (defined $shelf and ref $shelf eq $class) {
|
||||||
$shelf->purge;
|
$shelf->purge;
|
||||||
}
|
}
|
||||||
|
if (defined $shelf2 and ref $shelf2 eq $class) {
|
||||||
|
$shelf2->purge;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
t/supporting_collateral/productTables/quotedTable.csv
Normal file
6
t/supporting_collateral/productTables/quotedTable.csv
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
"mastersku","sku","title","shortdescription","price","weight","quantity"
|
||||||
|
"Kids-lashed","red-t-shirt","Colored T-Shirts","Red T-Shirt",5,1.33,1000
|
||||||
|
"Kids-lashed","blue-t-shirt","Colored T-Shirts","Blue T-Shirt",5.25,1.33,2000
|
||||||
|
"soda","soda-sweet","Sweet Soda-bottled in Oregon","Sweet Soda",0.95,0.95,500
|
||||||
|
"classical-records-1","track-16","The Marriage of Figaro","Track 16",3.25,0,50
|
||||||
|
"classical-records-1","track-9","The Marriage of Figaro","Track 9",3.25,0,55
|
||||||
|
Loading…
Add table
Add a link
Reference in a new issue