From 5ec8c2c0a1a5b15110ebc79bdffa3e0804988acb Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 19 Nov 2024 14:48:54 +0000 Subject: [PATCH] Bug 14907: Unit tests Content-Type: text/plain; charset=utf-8 Signed-off-by: Gretchen Maxeiner Signed-off-by: Marcel de Rooy --- t/db_dependent/Items.t | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index db90d09439..1954162a0a 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -283,7 +283,7 @@ subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { }; subtest 'SearchItems test' => sub { - plan tests => 20; + plan tests => 21; $schema->storage->txn_begin; my $dbh = C4::Context->dbh; @@ -539,6 +539,37 @@ subtest 'SearchItems test' => sub { ($items, $total_results) = SearchItems($filter,$params); is($items->[0]->{barcode}, $item1->barcode, 'Items sorted as expected by availability'); + subtest 'Sort items by callnumber' => sub { + plan tests => 2; + + # Add two items + my $item1 = $builder->build_sample_item( + { + itemcallnumber => 'D102.D3 1930', + cn_source => 'lcc' + } + ); + my $item2 = $builder->build_sample_item( + { + library => $item1->homebranch, + itemcallnumber => 'D1015.B4 1965', + cn_source => 'lcc' + } + ); + my $filter = { + field => 'homebranch', + query => $item1->homebranch, + operator => '=', + }; + my $params = { + sortby => 'itemcallnumber', + sortorder => 'DESC', + }; + ( $items, $total_results ) = SearchItems( $filter, $params ); + is( $items->[0]->{barcode}, $item2->barcode, 'Items sorted by cn_sort correctly' ); + is( $items->[1]->{barcode}, $item1->barcode, 'Items sorted by cn_sort correctly' ); + }; + subtest 'Search items by ISSN and ISBN with variations' => sub { plan tests => 4; -- 2.39.5