Bug 21560: Unit test for Koha::Util::OpenDocument
authorFridolin Somers <fridolin.somers@biblibre.com>
Tue, 19 Feb 2019 11:01:16 +0000 (12:01 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 26 Mar 2019 06:30:33 +0000 (07:30 +0100)
Run prove t/Koha/Util/OpenDocument.t

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 99ea714345a6278d68e2abb0d182d8b495cf2950)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 31ebb5abd003f41576febe7a53c27046236e9653)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 13cdadbe8f13f81e4774403b09c4abd1d27a6c6a)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

t/Koha/Util/OpenDocument.t [new file with mode: 0644]

diff --git a/t/Koha/Util/OpenDocument.t b/t/Koha/Util/OpenDocument.t
new file mode 100644 (file)
index 0000000..898c38b
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use File::Temp qw/tempfile/;
+use Test::More tests => 4;
+
+BEGIN { use_ok('Koha::Util::OpenDocument'); }
+
+my ( $ret, $filepath, $content );
+
+$ret = generate_ods( $filepath, $content );
+ok( !defined $ret, 'Call generate_ods with undef args' );
+
+my $fh1 = File::Temp->new( UNLINK => 1 );
+$filepath = $fh1->filename;
+my $content1 = [];
+$ret = generate_ods( $filepath, $content1 );
+ok( defined $ret, 'Call generate_ods with empty content' );
+close $fh1;
+
+my $fh2 = File::Temp->new( UNLINK => 1 );
+$filepath = $fh2->filename;
+my $content2 = [ [ 'A', 'B' ], [ '1', '2' ] ];
+$ret = generate_ods( $filepath, $content2 );
+ok( defined $ret, 'Call generate_ods with 2x2 content' );
+close $fh2;