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.
---
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 13c6d79..65822aa 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 524f2fc..6408d89 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 0000000..c8a1982
--- /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 0000000..ea8b034
--- /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;
--
1.5.5.GIT
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches