Bugzilla – Attachment 174370 Details for
Bug 34355
Automated MARC record ordering process
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34355: Add unit tests
Bug-34355-Add-unit-tests.patch (text/plain), 4.72 KB, created by
Matt Blenkinsop
on 2024-11-11 15:24:21 UTC
(
hide
)
Description:
Bug 34355: Add unit tests
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-11-11 15:24:21 UTC
Size:
4.72 KB
patch
obsolete
>From 76669ee7a93cdc304189c3a11e9a9fa2ec2a219a Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Wed, 31 Jul 2024 13:17:47 +0000 >Subject: [PATCH] Bug 34355: Add unit tests > >Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Koha/MarcOrder.t | 82 ++++++++++++++++++++++++++------- > 1 file changed, 65 insertions(+), 17 deletions(-) > >diff --git a/t/db_dependent/Koha/MarcOrder.t b/t/db_dependent/Koha/MarcOrder.t >index 4bcb90f9373..8f2d01badb2 100755 >--- a/t/db_dependent/Koha/MarcOrder.t >+++ b/t/db_dependent/Koha/MarcOrder.t >@@ -17,9 +17,10 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > > use Koha::MarcOrder; >+use Koha::MarcOrderAccount; > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Bookseller; > use MARC::Record; >@@ -29,6 +30,10 @@ use Koha::Database; > use t::lib::Mocks; > use t::lib::TestBuilder; > >+use File::Temp qw|tempfile|; >+use MARC::Field; >+use MARC::File::XML; >+ > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >@@ -335,33 +340,24 @@ subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub { > my $client_item_fields = { > 'notforloans' => [ > '', >- '' > ], > 'c_budget_id' => 2, > 'replacementprices' => [ > '0.00', >- '0.00' > ], > 'uris' => [ > '', >- '' > ], > 'c_replacement_price' => '0.00', >- 'public_notes' => [ >- '', >- '' >- ], >- 'itemcallnumbers' => [ >+ 'public_notes' => [''], >+ 'itemcallnumbers' => [ > '', >- '' > ], > 'budget_codes' => [ > '', >- '' > ], > 'nonpublic_notes' => [ > '', >- '' > ], > 'homebranches' => [ > $branchcode, >@@ -369,7 +365,6 @@ subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub { > ], > 'copynos' => [ > '', >- '' > ], > 'holdingbranches' => [ > $branchcode, >@@ -377,7 +372,6 @@ subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub { > ], > 'ccodes' => [ > '', >- '' > ], > 'locs' => [ > '', >@@ -385,7 +379,6 @@ subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub { > ], > 'itemprices' => [ > '10.00', >- '10.00' > ], > 'c_discount' => '', > 'c_price' => '0.00', >@@ -394,7 +387,6 @@ subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub { > 'c_quantity' => '1', > 'itypes' => [ > 'BK', >- 'BK' > ], > 'coded_location_qualifiers' => [], > 'barcodes' => [], >@@ -426,7 +418,7 @@ subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub { > "Listprice has been created successfully" > ); > is( >- @{$orders}[0]->{quantity}, 2, >+ @{$orders}[0]->{quantity}, 1, > "Quantity has been read correctly" > ); > is( >@@ -448,3 +440,59 @@ subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'match_file_to_account' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my ( $fh, $name ) = tempfile( SUFFIX => '.marcxml' ); >+ >+ my $rec = MARC::Record->new; >+ my $fld = MARC::Field->new( '975', '', '', 'p', '12345' ); >+ $rec->append_fields($fld); >+ my $str = $rec->as_xml; >+ >+ print $fh $str; >+ >+ close $fh; >+ >+ my $account1 = Koha::MarcOrderAccount->new( >+ { >+ match_field => '975$p', >+ match_value => '12345', >+ encoding => 'UTF-8', >+ description => 'test', >+ } >+ )->store; >+ >+ my $file_match = Koha::MarcOrder->match_file_to_account( >+ { >+ filename => $name, >+ filepath => $name, >+ profile => $account1, >+ } >+ ); >+ >+ is( $file_match, 1, 'File matched correctly to the account' ); >+ >+ my $account2 = Koha::MarcOrderAccount->new( >+ { >+ match_field => '975$p', >+ match_value => 'abcde', >+ encoding => 'UTF-8', >+ description => 'test', >+ } >+ )->store; >+ >+ my $file_match2 = Koha::MarcOrder->match_file_to_account( >+ { >+ filename => $name, >+ filepath => $name, >+ profile => $account2, >+ } >+ ); >+ >+ is( $file_match2, 0, 'File not matched to the account' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.39.3 (Apple Git-146)
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 34355
:
154705
|
154706
|
154707
|
154708
|
154709
|
154710
|
157092
|
157093
|
157094
|
157095
|
157096
|
157097
|
157098
|
157099
|
157100
|
160858
|
160859
|
160860
|
160861
|
160862
|
160863
|
160864
|
160865
|
160866
|
160867
|
160868
|
160869
|
160870
|
160871
|
160872
|
160873
|
160874
|
160875
|
169896
|
169897
|
169898
|
169899
|
169900
|
169901
|
169902
|
169903
|
169904
|
170395
|
170401
|
170402
|
170403
|
170404
|
170405
|
170406
|
170407
|
170408
|
170409
|
173054
|
173055
|
173056
|
173057
|
173058
|
173059
|
173060
|
173061
|
173062
|
173063
|
173064
|
173065
|
173066
|
173709
|
173805
|
173806
|
173809
|
173824
|
173825
|
173993
|
173994
|
173995
|
173996
|
173997
|
173998
|
173999
|
174000
|
174001
|
174002
|
174003
|
174004
|
174005
|
174006
|
174007
|
174008
|
174009
|
174010
|
174362
|
174363
|
174364
|
174365
|
174366
|
174367
|
174368
|
174369
| 174370 |
174371
|
174372
|
174373
|
174374
|
174375
|
174376
|
174377
|
174378
|
174379
|
174380
|
174382
|
174383