Bugzilla – Attachment 141548 Details for
Bug 31649
Acquisition basket CSV export fails if biblio does not exist
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31649: Add unit tests
Bug-31649-Add-unit-tests.patch (text/plain), 5.06 KB, created by
Katrin Fischer
on 2022-10-08 12:41:19 UTC
(
hide
)
Description:
Bug 31649: Add unit tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2022-10-08 12:41:19 UTC
Size:
5.06 KB
patch
obsolete
>From 657a88e05e0075a6d23c2b0e2188f5c397c985ac Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Wed, 28 Sep 2022 20:32:58 -1000 >Subject: [PATCH] Bug 31649: Add unit tests > >Creates new test file GetBasketGroupAsCSV.t > >Test with : >prove t/db_dependent/Acquisition/GetBasketAsCSV.t >prove t/db_dependent/Acquisition/GetBasketGroupAsCSV.t > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/db_dependent/Acquisition/GetBasketAsCSV.t | 10 ++- > .../Acquisition/GetBasketGroupAsCSV.t | 73 +++++++++++++++++++ > 2 files changed, 82 insertions(+), 1 deletion(-) > create mode 100755 t/db_dependent/Acquisition/GetBasketGroupAsCSV.t > >diff --git a/t/db_dependent/Acquisition/GetBasketAsCSV.t b/t/db_dependent/Acquisition/GetBasketAsCSV.t >index ae79a8d8aa..d1dabb7e53 100755 >--- a/t/db_dependent/Acquisition/GetBasketAsCSV.t >+++ b/t/db_dependent/Acquisition/GetBasketAsCSV.t >@@ -4,13 +4,14 @@ use Modern::Perl; > > use CGI; > >-use Test::More tests => 4; >+use Test::More tests => 5; > > use C4::Acquisition qw( NewBasket GetBasket GetBasketAsCSV ); > use C4::Biblio qw( AddBiblio ); > use Koha::Database; > use Koha::CsvProfiles; > use Koha::Acquisition::Orders; >+use Koha::Biblios; > > use t::lib::Mocks; > use Try::Tiny; >@@ -92,4 +93,11 @@ try { > ok($_->isa("Koha::Exceptions::ObjectNotFound"), "Using non-existant profile should throw ObjectNotFound exception"); > }; > >+Koha::Biblios->find($biblionumber)->delete; >+my $basket_csv4 = C4::Acquisition::GetBasketAsCSV($basketno, $query); >+is($basket_csv4, 'Contract name,Order number,Entry date,ISBN,Author,Title,Publication year,Publisher,Collection title,Note for vendor,Quantity,RRP,Delivery place,Billing place >+"",' . $order->ordernumber . ',2016-01-02,,"","",,"","","",3,,"","" >+', 'CSV should not fail if biblio does not exist'); >+ >+ > $schema->storage->txn_rollback(); >diff --git a/t/db_dependent/Acquisition/GetBasketGroupAsCSV.t b/t/db_dependent/Acquisition/GetBasketGroupAsCSV.t >new file mode 100755 >index 0000000000..577a8d52d2 >--- /dev/null >+++ b/t/db_dependent/Acquisition/GetBasketGroupAsCSV.t >@@ -0,0 +1,73 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use Test::More tests => 2; >+ >+use C4::Acquisition qw( NewBasket NewBasketgroup GetBasketGroupAsCSV ); >+use C4::Biblio qw( AddBiblio ); >+use Koha::Database; >+use Koha::CsvProfiles; >+use Koha::Acquisition::Orders; >+use Koha::Biblios; >+ >+use t::lib::Mocks; >+use Try::Tiny; >+ >+my $schema = Koha::Database->new()->schema(); >+$schema->storage->txn_begin(); >+ >+my $query = CGI->new(); >+ >+my $vendor = Koha::Acquisition::Bookseller->new({ >+ name => 'my vendor', >+ address1 => 'vendor address', >+ active => 1, >+ deliverytime => 5, >+})->store; >+ >+my $budget_id = C4::Budgets::AddBudget({ >+ budget_code => 'my_budget_code', >+ budget_name => 'My budget name', >+}); >+my $budget = C4::Budgets::GetBudget( $budget_id ); >+ >+my $basketno = C4::Acquisition::NewBasket($vendor->id, 1); >+ >+my $basketgroupid = C4::Acquisition::NewBasketgroup( >+ { >+ booksellerid => $vendor->id, >+ basketlist => [ $basketno ], >+ } >+); >+ >+my $biblio = MARC::Record->new(); >+$biblio->append_fields( >+ MARC::Field->new( '100', ' ', ' ', a => 'King, Stephen' ), >+ MARC::Field->new( '245', ' ', ' ', a => 'Test Record' ), >+); >+my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, ''); >+ >+my $order = Koha::Acquisition::Order->new({ >+ basketno => $basketno, >+ quantity => 3, >+ biblionumber => $biblionumber, >+ budget_id => $budget_id, >+ entrydate => '2016-01-02', >+})->store; >+ >+my $basketgroup_csv1 = C4::Acquisition::GetBasketGroupAsCSV($basketgroupid, $query); >+is($basketgroup_csv1, 'Account number,Basket name,Order number,Author,Title,Publisher,Publication year,Collection title,ISBN,Quantity,RRP tax included,RRP tax excluded,Discount,Estimated cost tax included,Estimated cost tax excluded,Note for vendor,Entry date,Bookseller name,Bookseller physical address,Bookseller postal address,Contract number,Contract name,Basket group delivery place,Basket group billing place,Basket delivery place,Basket billing place >+,"",' . $order->ordernumber . ',"King, Stephen","Test Record","",,"",,3,0.00,0.00,,0.00,0.00,"",2016-01-02,"my vendor","vendor address","",,"","","","","" >+', 'CSV should be generated'); >+ >+Koha::Biblios->find($biblionumber)->delete; >+my $basketgroup_csv2 = C4::Acquisition::GetBasketGroupAsCSV($basketgroupid, $query); >+is($basketgroup_csv2, 'Account number,Basket name,Order number,Author,Title,Publisher,Publication year,Collection title,ISBN,Quantity,RRP tax included,RRP tax excluded,Discount,Estimated cost tax included,Estimated cost tax excluded,Note for vendor,Entry date,Bookseller name,Bookseller physical address,Bookseller postal address,Contract number,Contract name,Basket group delivery place,Basket group billing place,Basket delivery place,Basket billing place >+,"",' . $order->ordernumber . ',"","","",,"",,3,0.00,0.00,,0.00,0.00,"",2016-01-02,"my vendor","vendor address","",,"","","","","" >+', 'CSV should not fail if biblio does not exist'); >+ >+ >+$schema->storage->txn_rollback(); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31649
:
141076
|
141077
|
141078
|
141084
|
141085
|
141086
| 141548 |
141549
|
141550