Bug 19489: Koha::Account::Line->issue method and Unit test
[koha.git] / t / Output.t
index 4474d18..279ce06 100755 (executable)
@@ -3,7 +3,8 @@
 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More tests => 6;
+use Test::Warn;
 use CGI qw ( -utf8 );
 
 BEGIN {
@@ -28,3 +29,15 @@ my $output = 'foobarbaz';
     like($stdout, qr/Cache-control: no-cache[^,]/, 'not using force_no_caching sets Cache-control as desired');
     unlike($stdout, qr/Expires: /, 'force_no_caching does not set an Expires header');
 }
+
+subtest 'parametrized_url' => sub {
+    plan tests => 2;
+
+    my $url = 'https://somesite.com/search?q={TITLE}&author={AUTHOR}{SUFFIX}';
+    my $subs = { TITLE => '_title_', AUTHOR => undef, ISBN => '123456789' };
+    my $res;
+    warning_is { $res = C4::Output::parametrized_url( $url, $subs ) }
+        q{}, 'No warning expected on undefined author';
+    is( $res, 'https://somesite.com/search?q=_title_&author=',
+        'Title replaced, author empty and SUFFIX removed' );
+};