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 Test::More tests => 1; |
23 |
|
24 |
use Koha::AuthUtils; |
25 |
use t::lib::Selenium; |
26 |
use t::lib::TestBuilder; |
27 |
|
28 |
eval { require Selenium::Remote::Driver; }; |
29 |
skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@; |
30 |
|
31 |
my $s = t::lib::Selenium->new; |
32 |
|
33 |
my $driver = $s->driver; |
34 |
my $base_url = $s->base_url; |
35 |
my $builder = t::lib::TestBuilder->new; |
36 |
|
37 |
our @cleanup; |
38 |
subtest 'OPAC - borrowernumber and branchcode as html attributes' => sub { |
39 |
plan tests => 2; |
40 |
|
41 |
my $patron = $builder->build_object( |
42 |
{ class => 'Koha::Patrons', value => { flags => 1 } } ); |
43 |
my $password = Koha::AuthUtils::generate_password(); |
44 |
my $digest = Koha::AuthUtils::hash_password($password); |
45 |
$patron->update_password( $patron->userid, $digest ); |
46 |
$s->opac_auth( $patron->userid, $password ); |
47 |
my $elt = $driver->find_element('//span[@class="loggedinusername"]'); |
48 |
is( $elt->get_attribute('data-branchcode'), $patron->library->branchcode, |
49 |
"Since bug 20921 span.loggedinusername should contain data-branchcode" |
50 |
); |
51 |
is( $elt->get_attribute('data-borrowernumber'), $patron->borrowernumber, |
52 |
"Since bug 20921 span.loggedinusername should contain data-borrowernumber" |
53 |
); |
54 |
push @cleanup, $patron; |
55 |
push @cleanup, $patron->category; |
56 |
push @cleanup, $patron->library; |
57 |
}; |
58 |
|
59 |
END { |
60 |
$_->delete for @cleanup; |
61 |
}; |