From 06720cd3cf8c10a0d9079abb7cf408b356b6cd66 Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Mon, 23 Jun 2008 12:35:58 -0500 Subject: [PATCH] bug: 2272 - remove warning from C4::Koha::getitemtypeimagedir I changed getitemtypeimagedir to set a default on its argument so that it would not complain if not passed 'opac'. I improved the documentation on the method. I edited the t/icondirecotries.t test script to explicitly pass an argument to both getitemtypeimagedir calls. - and I adjusted one line of whitespace to make similar things look similar I added a test module for C4::Koha I added a test module for C4::Koha::getitemtypeimagedir. Signed-off-by: Joshua Ferraro --- C4/Koha.pm | 18 ++++++++ t/icondirectories.t | 4 +- t/lib/KohaTest/Koha.pm | 51 ++++++++++++++++++++++ t/lib/KohaTest/Koha/getitemtypeimagedir.pm | 27 ++++++++++++ 4 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 t/lib/KohaTest/Koha.pm create mode 100644 t/lib/KohaTest/Koha/getitemtypeimagedir.pm diff --git a/C4/Koha.pm b/C4/Koha.pm index 13c6d79a38..65822aa8e8 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -455,8 +455,26 @@ sub getitemtypeimagesrcfromurl { return $imageurl; } +=head2 getitemtypeimagedir + +=over + +=item 4 + + my $directory = getitemtypeimagedir( 'opac' ); + +pass in 'opac' or 'intranet'. Defaults to 'opac'. + +returns the full path to the appropriate directory containing images. + +=back + +=cut + sub getitemtypeimagedir { my $src = shift; + $src = 'opac' unless defined $src; + if ($src eq 'intranet') { return C4::Context->config('intrahtdocs') . '/' .C4::Context->preference('template') . '/img/itemtypeimg'; } diff --git a/t/icondirectories.t b/t/icondirectories.t index 524f2fc697..6408d894d2 100644 --- a/t/icondirectories.t +++ b/t/icondirectories.t @@ -24,8 +24,8 @@ use Data::Dumper; use File::Find; use Test::More tests => 1; -my $opac_icon_directory = getitemtypeimagedir(); -my $staff_icon_directory = getitemtypeimagedir( 'intranet' ); +my $opac_icon_directory = getitemtypeimagedir('opac'); +my $staff_icon_directory = getitemtypeimagedir('intranet'); my $opac_icons; # hashref of filenames to sizes sub opac_wanted { diff --git a/t/lib/KohaTest/Koha.pm b/t/lib/KohaTest/Koha.pm new file mode 100644 index 0000000000..c8a19822d8 --- /dev/null +++ b/t/lib/KohaTest/Koha.pm @@ -0,0 +1,51 @@ +package KohaTest::Koha; +use base qw( KohaTest ); + +use strict; +use warnings; + +use Test::More; + +use C4::Koha; +sub testing_class { 'C4::Koha' } + +sub methods : Test( 1 ) { + my $self = shift; + my @methods = qw( slashifyDate + DisplayISBN + subfield_is_koha_internal_p + GetItemTypes + get_itemtypeinfos_of + GetCcodes + getauthtypes + getauthtype + getframeworks + getframeworkinfo + getitemtypeinfo + getitemtypeimagesrcfromurl + getitemtypeimagedir + getitemtypeimagesrc + _getImagesFromDirectory + _getSubdirectoryNames + getImageSets + GetPrinters + GetPrinter + getnbpages + getallthemes + getFacets + get_infos_of + get_notforloan_label_of + displayServers + displaySecondaryServers + GetAuthValCode + GetAuthorisedValues + GetAuthorisedValueCategories + GetKohaAuthorisedValues + GetManagedTagSubfields + display_marc_indicators + ); + + can_ok( $self->testing_class, @methods ); +} + +1; diff --git a/t/lib/KohaTest/Koha/getitemtypeimagedir.pm b/t/lib/KohaTest/Koha/getitemtypeimagedir.pm new file mode 100644 index 0000000000..ea8b034a39 --- /dev/null +++ b/t/lib/KohaTest/Koha/getitemtypeimagedir.pm @@ -0,0 +1,27 @@ +package KohaTest::Koha::getitemtypeimagedir; +use base qw( KohaTest::Koha ); + +use strict; +use warnings; + +use Test::More; + +use C4::Koha; + +sub check_default : Test( 5 ) { + my $self = shift; + + my $opac_directory = C4::Koha::getitemtypeimagedir('opac'); + my $default_directory = C4::Koha::getitemtypeimagedir('opac'); + my $intranet_directory = C4::Koha::getitemtypeimagedir('intranet'); + + ok( $opac_directory, 'the opac directory is defined' ); + ok( $default_directory, 'the default directory is defined' ); + ok( $intranet_directory, 'the intranet directory is defined' ); + + is( $opac_directory, $default_directory, 'the opac directory is returned as the default' ); + isnt( $intranet_directory, $default_directory, 'the intranet directory is not the same as the default' ); + +} + +1; -- 2.39.2