Bugzilla – Attachment 18222 Details for
Bug 10270
GetOrdersByBiblionumber needs better unit tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 10270: GetOrdersByBiblionumber needs better unit tests
PASSED-QA-Bug-10270-GetOrdersByBiblionumber-needs-.patch (text/plain), 4.88 KB, created by
Katrin Fischer
on 2013-05-18 08:08:53 UTC
(
hide
)
Description:
[PASSED QA] Bug 10270: GetOrdersByBiblionumber needs better unit tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2013-05-18 08:08:53 UTC
Size:
4.88 KB
patch
obsolete
>From d9dd99b3897f2626a6403fd576c5b08c8355fa5d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 17 May 2013 11:38:34 +0200 >Subject: [PATCH] [PASSED QA] Bug 10270: GetOrdersByBiblionumber needs better > unit tests > >prove t/db_dependent/Acquisition/GetOrdersByBiblionumber.t > >Signed-off-by:Mathieu Saby <mathieu.saby@univ-rennes2.fr> >I made 2 tests : >$prove -v t/db_dependent/Acquisition/GetOrdersByBiblionumber.t >and >$prove -v t/db_dependent/Acquisition.t >The 2 tests are successful. > >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >All tests and QA script pass. >--- > t/db_dependent/Acquisition.t | 19 +---- > .../Acquisition/GetOrdersByBiblionumber.t | 84 ++++++++++++++++++++ > 2 files changed, 85 insertions(+), 18 deletions(-) > create mode 100644 t/db_dependent/Acquisition/GetOrdersByBiblionumber.t > >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index b339db3..c015425 100755 >--- a/t/db_dependent/Acquisition.t >+++ b/t/db_dependent/Acquisition.t >@@ -10,7 +10,7 @@ use POSIX qw(strftime); > > use C4::Bookseller qw( GetBookSellerFromId ); > >-use Test::More tests => 41; >+use Test::More tests => 37; > > BEGIN { > use_ok('C4::Acquisition'); >@@ -32,23 +32,6 @@ my $grouped = 0; > my $orders = GetPendingOrders( $supplierid, $grouped ); > isa_ok( $orders, 'ARRAY' ); > >-# testing GetOrdersByBiblionumber >-# result should be undef if no params >-my @ordersbybiblionumber = GetOrdersByBiblionumber(); >-is(@ordersbybiblionumber,0,'GetOrdersByBiblionumber : no argument, return undef'); >-# TODO : create 2 orders using the same biblionumber, and check the result of GetOrdersByBiblionumber >-# if a record is used in at least one order, result should be an array with at least one element >-SKIP: { >- skip 'No Orders, cannot test GetOrdersByBiblionumber', 3 unless( scalar @$orders ); >- my $testorder = @$orders[0]; >- my $testbiblio = $testorder->{'biblionumber'}; >- my @listorders = GetOrdersByBiblionumber($testbiblio); >- ok( @listorders ,'GetOrdersByBiblionumber : result is defined' ); >- ok( scalar (@listorders) >0,'GetOrdersByBiblionumber : result contains at least one element' ); >- my @matched_biblios = grep {$_->{biblionumber} == $testbiblio} @listorders; >- ok ( @matched_biblios == @listorders, "all orders match"); >-} >- > my @lateorders = GetLateOrders(0); > SKIP: { > skip 'No Late Orders, cannot test AddClaim', 1 unless @lateorders; >diff --git a/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t b/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t >new file mode 100644 >index 0000000..4bdd4a8 >--- /dev/null >+++ b/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t >@@ -0,0 +1,84 @@ >+#!/usr/bin/env perl >+ >+use Modern::Perl; >+ >+use Test::More; >+use C4::Acquisition; >+use C4::Biblio; >+use C4::Bookseller; >+use C4::Budgets; >+use MARC::Record; >+ >+my $booksellerid = C4::Bookseller::AddBookseller( >+ { >+ name => "my vendor", >+ address1 => "bookseller's address", >+ phone => "0123456", >+ active => 1 >+ } >+); >+ >+my $basketno = C4::Acquisition::NewBasket( >+ $booksellerid >+); >+ >+my $budgetid = C4::Budgets::AddBudget( >+ { >+ budget_code => "budget_code_test_getordersbybib", >+ budget_name => "budget_name_test_getordersbybib", >+ } >+); >+ >+my $budget = C4::Budgets::GetBudget( $budgetid ); >+ >+my ($ordernumber1, $ordernumber2, $ordernumber3); >+my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, ''); >+my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, ''); >+( undef, $ordernumber1 ) = C4::Acquisition::NewOrder( >+ { >+ basketno => $basketno, >+ quantity => 24, >+ biblionumber => $biblionumber1, >+ budget_id => $budget->{budget_id}, >+ } >+); >+ >+( undef, $ordernumber2 ) = C4::Acquisition::NewOrder( >+ { >+ basketno => $basketno, >+ quantity => 42, >+ biblionumber => $biblionumber2, >+ budget_id => $budget->{budget_id}, >+ } >+); >+ >+( undef, $ordernumber3 ) = C4::Acquisition::NewOrder( >+ { >+ basketno => $basketno, >+ quantity => 4, >+ biblionumber => $biblionumber2, >+ budget_id => $budget->{budget_id}, >+ } >+); >+ >+my @orders = GetOrdersByBiblionumber(); >+is(scalar(@orders), 0, 'GetOrdersByBiblionumber : no argument, return undef'); >+ >+@orders = GetOrdersByBiblionumber( $biblionumber1 ); >+is(scalar(@orders), 1, '1 order on biblionumber 1'); >+ >+@orders = GetOrdersByBiblionumber( $biblionumber2 ); >+is(scalar(@orders), 2, '2 orders on biblionumber 2'); >+ >+END { >+ C4::Acquisition::DelOrder( 1, $ordernumber1 ); >+ C4::Acquisition::DelOrder( 2, $ordernumber2 ); >+ C4::Acquisition::DelOrder( 3, $ordernumber3 ); >+ C4::Budgets::DelBudget( $budgetid ); >+ C4::Acquisition::DelBasket( $basketno ); >+ C4::Bookseller::DelBookseller( $booksellerid ); >+ C4::Biblio::DelBiblio($biblionumber1); >+ C4::Biblio::DelBiblio($biblionumber2); >+}; >+ >+done_testing; >-- >1.7.9.5
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 10270
:
18185
|
18186
|
18188
|
18192
|
18202
|
18204
| 18222 |
18223