Bugzilla – Attachment 67416 Details for
Bug 17457
Use SearchWithISBNVariations in acquisition advanced search (histsearch.pl)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17457 - Add tests in Acquisition.t
Bug-17457---Add-tests-in-Acquisitiont.patch (text/plain), 4.66 KB, created by
David Bourgault
on 2017-09-27 20:21:19 UTC
(
hide
)
Description:
Bug 17457 - Add tests in Acquisition.t
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2017-09-27 20:21:19 UTC
Size:
4.66 KB
patch
obsolete
>From 9a54e3930de750284a6edbda0d522dadbdc31f64 Mon Sep 17 00:00:00 2001 >From: David Bourgault <david.bourgault@inlibro.com> >Date: Wed, 27 Sep 2017 16:20:40 -0400 >Subject: [PATCH] Bug 17457 - Add tests in Acquisition.t > >--- > C4/Acquisition.pm | 8 ++++---- > t/db_dependent/Acquisition.t | 39 ++++++++++++++++++++++++++++++++++++--- > 2 files changed, 40 insertions(+), 7 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 6e974bc..3d0b9e1 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -2283,18 +2283,18 @@ sub GetHistory { > my $total_price = 0; > > #get variation of isbn >- my @params; >+ my @isbn_params; > my @isbns; > if ($isbn){ > if ( C4::Context->preference("SearchWithISBNVariations") ){ > @isbns = C4::Koha::GetVariationsOfISBN( $isbn ); > foreach my $isb (@isbns){ >- push @params, '?'; >+ push @isbn_params, '?'; > } > } > unless (@isbns){ > push @isbns, $isbn; >- push @params, '?'; >+ push @isbn_params, '?'; > } > } > >@@ -2366,7 +2366,7 @@ sub GetHistory { > } > > if ( @isbns ) { >- $query .= " AND ( biblioitems.isbn LIKE " . join (" OR biblioitems.isbn LIKE ", @params ) . ")"; >+ $query .= " AND ( biblioitems.isbn LIKE " . join (" OR biblioitems.isbn LIKE ", @isbn_params ) . ")"; > foreach my $isb (@isbns){ > push @query_params, "%$isb%"; > } >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index 62a9a76..3dd93a8 100755 >--- a/t/db_dependent/Acquisition.t >+++ b/t/db_dependent/Acquisition.t >@@ -19,9 +19,12 @@ use Modern::Perl; > > use POSIX qw(strftime); > >-use Test::More tests => 65; >+use Test::More tests => 67; >+use t::lib::Mocks; > use Koha::Database; > >+use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat => 'MARC21' ); >+ > BEGIN { > use_ok('C4::Acquisition'); > use_ok('C4::Biblio'); >@@ -161,18 +164,38 @@ my $budgetid = C4::Budgets::AddBudget( > ); > my $budget = C4::Budgets::GetBudget($budgetid); > >+# Prepare a sample MARC record with a ISBN to test GetHistory() >+my $marcxml = qq{<?xml version="1.0" encoding="UTF-8"?> >+<record >+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >+ xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" >+ xmlns="http://www.loc.gov/MARC21/slim"> >+ >+ <leader>03108cam a2200277 i 4500</leader> >+ <controlfield tag="001">a2526595</controlfield> >+ <controlfield tag="003">Koha</controlfield> >+ <controlfield tag="005">20170306104815.0</controlfield> >+ <controlfield tag="006">m o d </controlfield> >+ <controlfield tag="007">cr |||||||||||</controlfield> >+ <controlfield tag="008">150723s2016 vau b 000 0 eng d</controlfield> >+ <datafield tag="020" ind1=" " ind2=" "> >+ <subfield code="a">9780136019701</subfield> >+ </datafield> >+</record> >+}; >+ > my @ordernumbers; > my ( $biblionumber1, $biblioitemnumber1 ) = AddBiblio( MARC::Record->new, '' ); > my ( $biblionumber2, $biblioitemnumber2 ) = AddBiblio( MARC::Record->new, '' ); > my ( $biblionumber3, $biblioitemnumber3 ) = AddBiblio( MARC::Record->new, '' ); > my ( $biblionumber4, $biblioitemnumber4 ) = AddBiblio( MARC::Record->new, '' ); >-my ( $biblionumber5, $biblioitemnumber5 ) = AddBiblio( MARC::Record->new, '' ); >+my ( $biblionumber5, $biblioitemnumber5 ) = AddBiblio( MARC::Record->new_from_xml( $marcxml, 'utf8', 'MARC21' ), '' ); > > # Prepare 5 orders, and make distinction beween fields to be tested with eq and with == > # Ex : a price of 50.1 will be stored internally as 5.100000 > > my @order_content = ( >- { >+ { > str => { > basketno => $basketno, > biblionumber => $biblionumber1, >@@ -433,6 +456,16 @@ is( scalar( @$orders ), 1, 'GetHistory with a given ordernumber returns 1 order' > $orders = GetHistory( ordernumber => $ordernumbers[1], search_children_too => 1 ); > is( scalar( @$orders ), 2, 'GetHistory with a given ordernumber and search_children_too set returns 2 orders' ); > >+# Test GetHistory() with and without SearchWithISBNVariations >+# The ISBN passed as a param is the ISBN-10 version of the 13-digit ISBN in the sample record declared in $marcxml >+t::lib::Mocks::mock_preference('SearchWithISBNVariations', 0); >+$orders = GetHistory( isbn => '0136019706' ); >+is( scalar(@$orders), 0, "GetHistory searches correctly by ISBN" ); >+ >+t::lib::Mocks::mock_preference('SearchWithISBNVariations', 1); >+$orders = GetHistory( isbn => '0136019706' ); >+is( scalar(@$orders), 1, "GetHistory searches correctly by ISBN" ); >+ > my $budgetid2 = C4::Budgets::AddBudget( > { > budget_code => "budget_code_test_modrecv", >-- >2.7.4
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 17457
:
67355
|
67416
|
67417
|
67418
|
67820
|
70279
|
70910