From 14a58874edd53b075c3fa57958f92f08dc631109 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 5 Jan 2016 14:23:24 +0000 Subject: [PATCH] Bug 15337: Add tests to ensure that GetItemTypes will return element ordered by desc MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit See comment #3 Signed-off-by: Marc Véron Signed-off-by: Katrin Fischer Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com (cherry picked from commit d33c2bf683f7a4d85531adb27662ddbb03080ae1) Signed-off-by: Julian Maurice --- t/db_dependent/Koha.t | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index 7fdd4192a0..c0134346f4 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -8,7 +8,7 @@ use warnings; use C4::Context; use Koha::DateUtils qw(dt_from_string); -use Test::More tests => 9; +use Test::More tests => 10; use DateTime::Format::MySQL; BEGIN { @@ -147,20 +147,6 @@ subtest 'Itemtype info Tests' => sub { like ( getitemtypeinfo('BK', 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' ); }; - - - - - - - - - - - - - - ### test for C4::Koha->GetDailyQuote() SKIP: { @@ -353,4 +339,14 @@ subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ @expected = ( 'BKghjklo1', 'Qwertyware', 'Veryheavybook' ); is_deeply(\@results,\@expected, 'GetItemTypesCategorized: grouped and ungrouped items returned as expected.'); }; + +subtest 'GetItemTypes test' => sub { + plan tests => 1; + $dbh->do(q|DELETE FROM itemtypes|); + $dbh->do(q|INSERT INTO itemtypes(itemtype, description) VALUES ('a', 'aa desc'), ('b', 'zz desc'), ('d', 'dd desc'), ('c', 'yy desc')|); + my $itemtypes = C4::Koha::GetItemTypes( style => 'array' ); + $itemtypes = [ map { $_->{itemtype} } @$itemtypes ]; + is_deeply( $itemtypes, [ 'a', 'd', 'c', 'b' ], 'GetItemTypes(array) should return itemtypes ordered by description'); +}; + $dbh->rollback(); -- 2.39.5