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

(-)a/t/db_dependent/selenium/ilsdi.t (-1 / +120 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use C4::Context;
21
use XML::LibXML;
22
23
use Test::More tests => 4;
24
25
use t::lib::Selenium;
26
use t::lib::TestBuilder;
27
use utf8;
28
29
my $original_ILSDI_value      = C4::Context->preference('ILS-DI');
30
my $original_OpacPublic_value = C4::Context->preference('OpacPublic');
31
my $builder                   = t::lib::TestBuilder->new;
32
33
my $login = $ENV{KOHA_USER} || 'koha';
34
35
my @cleanup;
36
37
SKIP: {
38
    eval { require Selenium::Remote::Driver; };
39
    skip "Selenium::Remote::Driver is needed for selenium tests.", 2 if $@;
40
41
    my $s      = t::lib::Selenium->new;
42
    my $driver = $s->driver;
43
    $driver->set_window_size( 3840, 1080 );
44
45
    subtest 'Disabled ILS-DI and enabled OPAC' => sub {
46
        plan tests => 2;
47
        C4::Context->set_preference( 'ILS-DI',     0 );
48
        C4::Context->set_preference( 'OpacPublic', 1 );
49
        my $ilsdi_page = $s->opac_base_url . q|ilsdi.pl?service=LookupPatron&id=abceasyas123|;
50
        $driver->get($ilsdi_page);
51
        my $xml_content = $driver->get_page_source;
52
        my $parser      = XML::LibXML->new();
53
        my $doc         = $parser->parse_string($xml_content);
54
        my $result      = $doc->find('/LookupPatron/message');
55
        my $literal     = $result->to_literal->value();
56
        is( "$literal", 'ILS-DI is disabled.', "ILS-DI is disabled" );
57
58
        $driver->get( $s->opac_base_url . q|ilsdi.pl| );
59
        isnt( $driver->get_title(), 'Log in to your account › Koha online catalog', "HTML explanation shows" );
60
    };
61
62
    subtest 'Disabled ILS-DI and disabled OPAC' => sub {
63
        plan tests => 2;
64
        C4::Context->set_preference( 'ILS-DI',     0 );
65
        C4::Context->set_preference( 'OpacPublic', 0 );
66
        my $ilsdi_page = $s->opac_base_url . q|ilsdi.pl?service=LookupPatron&id=abceasyas123|;
67
        $driver->get($ilsdi_page);
68
        my $xml_content = $driver->get_page_source;
69
        my $parser      = XML::LibXML->new();
70
        my $doc         = $parser->parse_string($xml_content);
71
        my $result      = $doc->find('/LookupPatron/message');
72
        my $literal     = $result->to_literal->value();
73
        is( "$literal", 'ILS-DI is disabled.', "ILS-DI is disabled" );
74
75
        $driver->get( $s->opac_base_url . q|ilsdi.pl| );
76
        isnt( $driver->get_title(), 'Log in to your account › Koha online catalog', "HTML explanation shows" );
77
    };
78
79
    subtest 'Enabled ILS-DI and enabled OPAC' => sub {
80
        plan tests => 2;
81
        C4::Context->set_preference( 'ILS-DI',     1 );
82
        C4::Context->set_preference( 'OpacPublic', 1 );
83
        my $ilsdi_page = $s->opac_base_url . q|ilsdi.pl?service=LookupPatron&id=abceasyas123|;
84
        $driver->get($ilsdi_page);
85
        my $xml_content = $driver->get_page_source;
86
        my $parser      = XML::LibXML->new();
87
        my $doc         = $parser->parse_string($xml_content);
88
        my $result      = $doc->find('/LookupPatron/message');
89
        my $literal     = $result->to_literal->value();
90
        isnt( "$literal", 'ILS-DI is disabled.', "ILS-DI is NOT disabled" );
91
92
        $driver->get( $s->opac_base_url . q|ilsdi.pl| );
93
        isnt( $driver->get_title(), 'Log in to your account › Koha online catalog', "HTML explanation shows" );
94
    };
95
96
    subtest 'Enabled ILS-DI and disabled OPAC' => sub {
97
        plan tests => 2;
98
        C4::Context->set_preference( 'ILS-DI',     1 );
99
        C4::Context->set_preference( 'OpacPublic', 0 );
100
        my $ilsdi_page = $s->opac_base_url . q|ilsdi.pl?service=LookupPatron&id=abceasyas123|;
101
        $driver->get($ilsdi_page);
102
        my $xml_content = $driver->get_page_source;
103
        my $parser      = XML::LibXML->new();
104
        my $doc         = $parser->parse_string($xml_content);
105
        my $result      = $doc->find('/LookupPatron/message');
106
        my $literal     = $result->to_literal->value();
107
        isnt( "$literal", 'ILS-DI is disabled.', "ILS-DI is NOT disabled" );
108
109
        $driver->get( $s->opac_base_url . q|ilsdi.pl| );
110
        isnt( $driver->get_title(), 'Log in to your account › Koha online catalog', "HTML explanation shows" );
111
    };
112
113
    $driver->quit();
114
}
115
116
END {
117
    C4::Context->set_preference( 'ILS-DI',     $original_ILSDI_value );
118
    C4::Context->set_preference( 'OpacPublic', $original_OpacPublic_value );
119
    $_->delete for @cleanup;
120
}

Return to bug 35008