From 76ca06fbd7eac049243975ac26dddaaa6f30e9e9 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 20 Mar 2017 09:05:13 +0000 Subject: [PATCH] Bug 8612: [Follow-up] Fix unit test GetBasketAsCSV.t Content-Type: text/plain; charset=utf-8 Test plan: Run t/db_dependent/Acquisition/GetBasketAsCSV.t Signed-off-by: Marcel de Rooy --- t/db_dependent/Acquisition/GetBasketAsCSV.t | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Acquisition/GetBasketAsCSV.t b/t/db_dependent/Acquisition/GetBasketAsCSV.t index 4cc1ad5..b6dfdbe 100644 --- a/t/db_dependent/Acquisition/GetBasketAsCSV.t +++ b/t/db_dependent/Acquisition/GetBasketAsCSV.t @@ -4,7 +4,7 @@ use Modern::Perl; use CGI; -use Test::More tests => 2; +use Test::More tests => 3; use C4::Acquisition; use C4::Biblio; @@ -16,9 +16,6 @@ use Koha::Acquisition::Order; my $schema = Koha::Database->new()->schema(); $schema->storage->txn_begin(); -my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; - my $query = CGI->new(); my $vendor = Koha::Acquisition::Bookseller->new({ @@ -41,6 +38,13 @@ my $csv_profile = Koha::CsvProfile->new({ content => 'autor=biblio.author|title=biblio.title|quantity=aqorders.quantity', })->store; +my $csv_profile2 = Koha::CsvProfile->new({ + profile => 'my user profile', + type => 'export_basket', + csv_separator => ',', + content => 'biblio.author | title = biblio.title|quantity=aqorders.quantity', +})->store; + my $basketno; $basketno = NewBasket($vendor->id, 1); @@ -65,7 +69,7 @@ is($basket_csv1, 'autor,title,quantity "King, Stephen","Test Record",3 ', 'CSV should be generated with user profile'); -# Use defautl template +# Use default template my $basket_csv2 = C4::Acquisition::GetBasketAsCSV($basketno, $query); is($basket_csv2, 'Contract name,Order number,Entry date,ISBN,Author,Title,Publication year,Publisher,Collection title,Note for vendor,Quantity,RRP,Delivery place,Billing place @@ -73,4 +77,9 @@ is($basket_csv2, 'Contract name,Order number,Entry date,ISBN,Author,Title,Public ', 'CSV should be generated with default template'); +my $basket_csv3 = C4::Acquisition::GetBasketAsCSV($basketno, $query, $csv_profile2->export_format_id); +is($basket_csv3, 'biblio.author,title,quantity +"King, Stephen","Test Record",3 +', 'CSV should be generated with user profile which does not have all headers defined'); + $schema->storage->txn_rollback(); -- 2.1.4