From 06b556f7bfc711a8ef23a57f90ac605400561aca Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Wed, 30 Jul 2014 11:31:39 -0300 Subject: [PATCH] Bug 12675: Add unit test to GetFrameworksLoop to test: 1. Apply the patch 2. Run the test, prove t/db_dependent/Koha.t 3. Check that it pass --- t/db_dependent/Koha.t | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index 0e90403..cec7eb8 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 => 7; +use Test::More tests => 8; use DateTime::Format::MySQL; BEGIN { @@ -261,3 +261,37 @@ subtest 'getFacets() tests' => sub { 'location facet present with singleBranchMode on (bug 10078)' ); }; + +subtest 'GetFrameworksLoop() tests' => sub { + plan tests => 1; + + $dbh->do("DELETE FROM biblio_framework"); + $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'A', 'Third framework' )"); + $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'B', 'Second framework' )"); + $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'C', 'First framework' )"); + + my $frameworksloop = GetFrameworksLoop( 'B' ); + cmp_deeply( + $frameworksloop, + [ + { + 'value' => 'C', + 'description' => 'First framework', + 'selected' => undef + }, + { + 'value' => 'B', + 'description' => 'Second framework', + 'selected' => 1, # selected + }, + { + 'value' => 'A', + 'description' => 'Third framework', + 'selected' => undef + }, + ], + 'frameworks sorted by description with selected val (Bug 12675)' + ); + + $dbh->rollback(); +}; -- 1.7.9.5