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

(-)a/t/db_dependent/selenium/self_registration.t (-1 / +74 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
use utf8;
20
21
use C4::Context;
22
23
use Test::More tests => 1;
24
use Test::MockModule;
25
26
use C4::Context;
27
use Koha::AuthUtils;
28
use t::lib::Selenium;
29
use t::lib::TestBuilder;
30
use t::lib::Mocks;
31
32
eval { require Selenium::Remote::Driver; };
33
skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@;
34
35
my $s = t::lib::Selenium->new;
36
37
my $driver = $s->driver;
38
my $opac_base_url = $s->opac_base_url;
39
my $builder = t::lib::TestBuilder->new;
40
41
my $PatronSelfRegistration_value = C4::Context->preference('PatronSelfRegistration');
42
C4::Context->set_preference('PatronSelfRegistration', '1');
43
44
our @cleanup;
45
46
subtest 'Set flags' => sub {
47
    plan tests => 2;
48
49
    $driver->get($opac_base_url . 'opac-main.pl');
50
51
    $driver->get($opac_base_url . 'opac-memberentry.pl');
52
    like( $driver->get_title(), qr(Register a new account), );
53
54
    $driver->find_element('//*[@id="borrower_surname"]')->send_keys("a surname");
55
    $driver->find_element('//*[@id="borrower_firstname"]')->send_keys("a firstname");
56
    $driver->find_element('//*[@id="borrower_initials"]')->send_keys("1");
57
    $driver->execute_script(q{document.querySelector("#borrower_initials").setAttribute("name", "borrower_flags");});
58
    $driver->capture_screenshot('selenium_failure_x.png');
59
    my $captcha = $driver->find_element('//*[@id="captcha"]/following-sibling::span/strong')->get_text();
60
    $driver->find_element('//*[@id="captcha"]')->send_keys($captcha);
61
    $s->submit_form;
62
63
    my $patron = Koha::Patrons->search({ surname => "a surname" })->next;
64
    is( $patron->flags, undef, 'flags must be undef even if user tried to pass it' );
65
    push @cleanup, $patron;
66
};
67
68
69
$driver->quit();
70
71
END {
72
    C4::Context->set_preference('PatronSelfRegistration', $PatronSelfRegistration_value);
73
    $_->delete for @cleanup;
74
};

Return to bug 28929