View | Details | Raw Unified | Return to bug 25131
Collapse All | Expand All

(-)a/C4/Context.pm (+13 lines)
Lines 1073-1078 sub set_remote_address { Link Here
1073
1073
1074
1;
1074
1;
1075
1075
1076
=head3 needs_install
1077
1078
    if ( $context->needs_install ) { ... }
1079
1080
This method returns a boolean representing the install status of the Koha instance.
1081
1082
=cut
1083
1084
sub needs_install {
1085
    my ($self) = @_;
1086
    return ($self->preference('Version')) ? 0 : 1;
1087
}
1088
1076
__END__
1089
__END__
1077
1090
1078
=head1 ENVIRONMENT
1091
=head1 ENVIRONMENT
(-)a/t/Context.t (-2 / +14 lines)
Lines 18-28 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use DBI;
20
use DBI;
21
use Test::More tests => 28;
21
use Test::More tests => 29;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
use YAML;
24
use YAML;
25
25
26
use t::lib::Mocks;
27
26
BEGIN {
28
BEGIN {
27
    use_ok('C4::Context');
29
    use_ok('C4::Context');
28
}
30
}
Lines 50-55 subtest 'yaml_preference() tests' => sub { Link Here
50
    $context->unmock( 'preference' );
52
    $context->unmock( 'preference' );
51
};
53
};
52
54
55
subtest 'needs_install() tests' => sub {
56
57
    plan tests => 2;
58
59
    t::lib::Mocks::mock_preference( 'Version', '3.0.0' );
60
    is( C4::Context->needs_install, 0, 'Preference is defined, no need to install' );
61
62
    t::lib::Mocks::mock_preference( 'Version', undef ); # the behaviour when ->preference fails to fetch
63
    is( C4::Context->needs_install, 1, "->preference(Version) is not defined, need to install" );
64
};
65
53
my $context = new Test::MockModule('C4::Context');
66
my $context = new Test::MockModule('C4::Context');
54
my $userenv = {};
67
my $userenv = {};
55
68
56
- 

Return to bug 25131