Bug 25765: (QA follow-up) Save a DB hit

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Martin Renvoize 2020-07-21 15:58:02 +01:00 committed by Jonathan Druart
parent cbd8655157
commit 83d63d2302
2 changed files with 2 additions and 3 deletions

View File

@ -43,8 +43,7 @@ sub GetLoggedInBranchcode {
sub GetLoggedInBranchname {
my ($self) = @_;
my $code = $self->GetLoggedInBranchcode;
return $code ? $self->GetName($code) : q{};
return C4::Context->userenv ? C4::Context->userenv->{'branchname'} : q{};
}
sub GetURL {

View File

@ -71,7 +71,7 @@ subtest 'all() tests' => sub {
is($plugin->GetLoggedInBranchcode(), '', 'no active library code if there is no active user session');
is($plugin->GetLoggedInBranchname(), '', 'no active library name if there is no active user session');
t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY' });
t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY', branchname => 'My sweet library' });
is($plugin->GetLoggedInBranchcode(), 'MYLIBRARY', 'GetLoggedInBranchcode() returns active library code');
is($plugin->GetLoggedInBranchname(), 'My sweet library', 'GetLoggedInBranchname() returns active library name');