Bug 11779: (follow-up) improve GetLoggedInBranchcode() and add test cases

This patch adjusts the new GetLoggedInBranchcode() template function so
that it returns the empty string rather than undef if there is no
active user environment.  That way, there won't be lots of undefined
value warnings if/when this function gets used in the OPAC.

This patch also adds test cases.

To test:

[1] Verify that there are no regressions in the main test
    plan for this bug.
[2] Verify that prove -v t/db_dependent/Koha_template_plugin_Branches.t
    passes.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 065a3a5efa)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 1b02c031a3 )
This commit is contained in:
Galen Charlton 2014-02-19 16:40:06 +00:00 committed by Kyle M Hall
parent 4fbc168e44
commit e2f4b2e01f
1 changed files with 3 additions and 1 deletions

View File

@ -39,7 +39,9 @@ sub GetName {
sub GetLoggedInBranchcode {
my ($self) = @_;
return C4::Context->userenv->{'branch'} if C4::Context->userenv;
return C4::Context->userenv ?
C4::Context->userenv->{'branch'} :
'';
}
1;