Browse Source

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

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
MM-OPAC/theme_dep
Bernardo Gonzalez Kriegel 10 years ago
committed by Tomas Cohen Arazi
parent
commit
ab0d9ae516
  1. 47
      t/db_dependent/Koha.t

47
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,48 @@ subtest 'getFacets() tests' => sub {
'location facet present with singleBranchMode on (bug 10078)'
);
};
subtest 'GetFrameworksLoop() tests' => sub {
plan tests => 6;
$dbh->do("DELETE FROM biblio_framework");
my $frameworksloop = GetFrameworksLoop();
is ( scalar(@$frameworksloop), 0, 'No frameworks' );
$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' )");
$frameworksloop = GetFrameworksLoop();
is ( scalar(@$frameworksloop), 3, 'All frameworks' );
is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 0, 'None selected' );
$frameworksloop = GetFrameworksLoop( 'B' );
is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 1, 'One selected' );
my @descriptions = map { $_->{'description'} } @$frameworksloop;
is ( $descriptions[0], 'First framework', 'Ordered result' );
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,
}
],
'Full check, sorted by description with selected val (Bug 12675)'
);
};
$dbh->rollback();

Loading…
Cancel
Save