use C4::Context;
-use Test::More tests => 5;
+use Test::More tests => 6;
use Test::MockModule;
use C4::Context;
C4::Context->set_preference('AudioAlerts', '1');
our @cleanup;
-subtest 'OPAC - borrowernumber and branchcode as html attributes' => sub {
- plan tests => 2;
+subtest 'OPAC - borrowernumber, branchcode and categorycode as html attributes' => sub {
+ plan tests => 3;
my $patron = $builder->build_object(
{ class => 'Koha::Patrons', value => { flags => 1 } } );
$patron->set_password({ password => $password });
$s->opac_auth( $patron->userid, $password );
my $elt = $driver->find_element('//span[@class="loggedinusername"]');
- is( $elt->get_attribute('data-branchcode'), $patron->library->branchcode,
+ is( $elt->get_attribute('data-branchcode', 1), $patron->library->branchcode,
"Since bug 20921 span.loggedinusername should contain data-branchcode"
+ # No idea why we need the second param of get_attribute(). As
+ # data-branchcode is still there after page finished loading.
);
- is( $elt->get_attribute('data-borrowernumber'), $patron->borrowernumber,
+ is( $elt->get_attribute('data-borrowernumber', 1), $patron->borrowernumber,
"Since bug 20921 span.loggedinusername should contain data-borrowernumber"
);
+ is( $elt->get_attribute('data-categorycode', 1), $patron->categorycode,
+"Since bug 26847 span.loggedinusername should contain data-categorycode"
+ );
push @cleanup, $patron, $patron->category, $patron->library;
};
+subtest 'OPAC - Bibliographic record detail page must contain the data-biblionumber' => sub {
+ plan tests => 1;
+
+ my $builder = t::lib::TestBuilder->new;
+
+ my ( $biblionumber, $biblioitemnumber ) = add_biblio();
+ my $biblio = Koha::Biblios->find($biblionumber);
+
+ $driver->get( $opac_base_url . "opac-detail.pl?biblionumber=$biblionumber" );
+
+ my $elt = $driver->find_element('//div[@id="catalogue_detail_biblio"]');
+ is( $elt->get_attribute( 'data-biblionumber', 1 ),
+ $biblionumber, "#catalogue_detail_biblio contains data-biblionumber" );
+
+ push @cleanup, $biblio;
+ };
+
subtest 'OPAC - Remove from cart' => sub {
plan tests => 4;
my @thead_th = $driver->find_elements('//table[@id="issues-table"]/thead/tr/th');
my $thead_length = 0;
- $thead_length += $_->get_attribute('colspan') || 0 for @thead_th;
+ $thead_length += $_->get_attribute('colspan', 1) || 0 for @thead_th;
my @tfoot_td = $driver->find_elements('//table[@id="issues-table"]/tfoot/tr/td');
my $tfoot_length = 0;
- $tfoot_length += $_->get_attribute('colspan') || 0 for @tfoot_td;
+ $tfoot_length += $_->get_attribute('colspan', 1) || 0 for @tfoot_td;
my @tbody_td = $driver->find_elements('//table[@id="issues-table"]/tbody/tr[2]/td');
my $tbody_length = 0;
like( $second_page->get_attribute('href'), qr{category=2%22%3E%3Cscript%3Ealert%28%27booh%21%27%29%3C%2Fscript%3E}, 'The second page should display the variables and attributes correctly URI escaped' );
push @cleanup, $patron, $patron->category, $patron->library;
+
+ $driver->quit();
};
END {