|
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 |
|
| 22 |
use utf8; |
| 23 |
use Test::More tests => 1; |
| 24 |
use Test::MockModule; |
| 25 |
|
| 26 |
use C4::Context; |
| 27 |
use Koha::AuthUtils; |
| 28 |
use t::lib::Mocks; |
| 29 |
use t::lib::Selenium; |
| 30 |
use t::lib::TestBuilder; |
| 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 |
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; |
| 40 |
|
| 41 |
our @cleanup; |
| 42 |
subtest 'Search patrons' => sub { |
| 43 |
plan tests => 3; |
| 44 |
|
| 45 |
my @patrons; |
| 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 $patron_category = $builder->build_object( |
| 50 |
{ class => 'Koha::Patron::Categories', category_type => 'A' } ); |
| 51 |
my $library = $builder->build_object( |
| 52 |
{ class => 'Koha::Libraries', value => { branchname => $branchname } } |
| 53 |
); |
| 54 |
for my $i ( 1 .. 25 ) { |
| 55 |
push @patrons, |
| 56 |
$builder->build_object( |
| 57 |
{ |
| 58 |
class => 'Koha::Patrons', |
| 59 |
value => { |
| 60 |
surname => "test_patron_" . $i++, |
| 61 |
categorycode => $patron_category->categorycode, |
| 62 |
branchcode => $library->branchcode, |
| 63 |
borrowernotes => $borrowernotes, |
| 64 |
} |
| 65 |
} |
| 66 |
); |
| 67 |
} |
| 68 |
|
| 69 |
$s->auth; |
| 70 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 71 |
$s->fill_form( { searchmember_filter => 'test_patron' } ); |
| 72 |
$s->submit_form; |
| 73 |
my $first_patron = $patrons[0]; |
| 74 |
|
| 75 |
my @td = $driver->find_elements('//table[@id="memberresultst"]/tbody/tr/td'); |
| 76 |
is( $td[5]->get_text, $branchname, |
| 77 |
'Column "Library" should be the 6th and contain the html tags - they have been html filtered' |
| 78 |
); |
| 79 |
is( $td[9]->get_text, $borrowernotes_displayed, |
| 80 |
'Column "Circ note" should be the 10th and not contain the html tags - they have not been html filtered' |
| 81 |
); |
| 82 |
|
| 83 |
$driver->find_element( |
| 84 |
'//a[@href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=' |
| 85 |
. $first_patron->borrowernumber |
| 86 |
. '"]' )->click; |
| 87 |
is( |
| 88 |
$driver->get_title, |
| 89 |
sprintf( |
| 90 |
"Koha › Patrons › Modify patron %s %s (%s)", |
| 91 |
$first_patron->firstname, $first_patron->surname, |
| 92 |
$first_patron->category->description, |
| 93 |
) |
| 94 |
); |
| 95 |
push @cleanup, $_ for @patrons; |
| 96 |
push @cleanup, $library; |
| 97 |
push @cleanup, $patron_category; |
| 98 |
}; |
| 99 |
|
| 100 |
END { |
| 101 |
$_->delete for @cleanup; |
| 102 |
} |