Browse Source

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 <jmf@liblime.com>
3.0.x
Andrew Moore 16 years ago
committed by Joshua Ferraro
parent
commit
06720cd3cf
  1. 18
      C4/Koha.pm
  2. 4
      t/icondirectories.t
  3. 51
      t/lib/KohaTest/Koha.pm
  4. 27
      t/lib/KohaTest/Koha/getitemtypeimagedir.pm

18
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';
}

4
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 {

51
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;

27
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;
Loading…
Cancel
Save