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>.
23 use Test::More tests => 1;
30 use t::lib::TestBuilder;
32 eval { require Selenium::Remote::Driver; };
33 skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@;
35 my $s = t::lib::Selenium->new;
36 my $driver = $s->driver;
37 my $opac_base_url = $s->opac_base_url;
38 my $base_url = $s->base_url;
39 my $builder = t::lib::TestBuilder->new;
42 subtest 'Search patrons' => sub {
46 my $borrowernotes = q|<strong>just 'a" note</strong> \123 ❤|;
47 my $borrowernotes_displayed = q|just 'a" note \123 ❤|;
48 my $branchname = q|<strong>just 'another" library</strong> \123 ❤|;
49 my $firstname = q|<strong>fir's"tname</strong> \123 ❤|;
50 my $patron_category = $builder->build_object(
51 { class => 'Koha::Patron::Categories', category_type => 'A' } );
52 my $library = $builder->build_object(
53 { class => 'Koha::Libraries', value => { branchname => $branchname } }
55 for my $i ( 1 .. 25 ) {
57 $builder->build_object(
59 class => 'Koha::Patrons',
61 surname => "test_patron_" . $i++,
62 firstname => $firstname,
63 categorycode => $patron_category->categorycode,
64 branchcode => $library->branchcode,
65 borrowernotes => $borrowernotes,
72 $driver->get( $base_url . "/members/members-home.pl" );
73 $s->fill_form( { searchmember_filter => 'test_patron' } );
75 my $first_patron = $patrons[0];
77 my @td = $driver->find_elements('//table[@id="memberresultst"]/tbody/tr/td');
78 like ($td[2]->get_text, qr[\Q$firstname\E],
79 'Column "Name" should be the 3rd and contain the firstname correctly filtered'
81 is( $td[5]->get_text, $branchname,
82 'Column "Library" should be the 6th and contain the html tags - they have been html filtered'
84 is( $td[9]->get_text, $borrowernotes_displayed,
85 'Column "Circ note" should be the 10th and not contain the html tags - they have not been html filtered'
88 $driver->find_element(
89 '//a[@href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber='
90 . $first_patron->borrowernumber
95 "Koha › Patrons › Modify patron %s %s (%s)",
96 $first_patron->firstname, $first_patron->surname,
97 $first_patron->category->description,
100 push @cleanup, $_ for @patrons;
101 push @cleanup, $library;
102 push @cleanup, $patron_category;
106 $_->delete for @cleanup;