Bug 19096: Online help changes
[koha.git] / t / Koha / Config.t
blob2ae3c25640d51aff755adb381f670b7fdf8710ed
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Modern::Perl;
20 use Test::More tests => 2;
21 use Test::MockModule;
22 use Test::Warn;
24 use Carp;
26 my $parsing_result = 'ok';
28 my $xml_simple = Test::MockModule->new('XML::Simple');
29 $xml_simple->mock(
30 XMLin => sub {
31 if ( $parsing_result eq 'error' ) {
32 croak "Something";
33 } else {
34 return "XML data";
39 use_ok('Koha::Config');
41 subtest 'read_from_file() tests' => sub {
43 plan tests => 4;
45 is( Koha::Config->read_from_file(undef), undef,
46 "Undef parameter makes function return undef");
48 $parsing_result = 'ok';
50 my $result = Koha::Config->read_from_file("SomeFile.xml");
51 is( $result, 'XML data', 'File read correctly' );
53 $parsing_result = 'error';
55 warning_is
56 {$result = Koha::Config->read_from_file("SomeFile.xml")}
57 'Error reading file SomeFile.xml',
58 'File failing to read raises warning';
59 is( $result, undef, 'Returns undef on error confition' );