From 787035e523bc752822a67a642999e47e032126f0 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Fri, 10 Mar 2017 03:14:58 +0000 Subject: [PATCH] Bug 18212 - Added a successful unit test for GetAuthValues() function --- t/db_dependent/AuthorisedValues.t | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t index 6d44a72..e7403ff 100644 --- a/t/db_dependent/AuthorisedValues.t +++ b/t/db_dependent/AuthorisedValues.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 15; +use Test::More tests => 16; use C4::Context; use Koha::AuthorisedValue; @@ -225,3 +225,40 @@ subtest 'search_by_*_field + find_by_koha_field + get_description' => sub { ); }; }; + sub GetAuthValues { + require Test::More; + my $dbh = C4::Context->dbh; + my ($self, $authcat) = @_; + my $query = qq{ SELECT * FROM authorised_values WHERE category=? order by lib }; + my $sth = $dbh->prepare($query); + $sth->execute($authcat); + my $AuthValue = 0; + if ($sth->rows > 0) { + $AuthValue = 1; + } + return $AuthValue; + }; + my $AuthValues = GetAuthValues('av_for_testing'); + is ( $AuthValues,0, 'Does not exist in the database: Test successful'); + + sub GetDistinctCat { + require Test::More; + my $dbh = C4::Context->dbh; + my ($self, $dbh) = @_; + my $sth = $dbh->prepare("select distinct category from authorised_values where category like 'A%' "); + $sth->execute; + return $sth; + my $DistAuth = 0; + if ($sth->rows > 0){ + $DistAuth = 1; + } + return $DistAuth; + }; + my $DistAuth = GetDistinctCat(); + is ( $DistAuth, 0, 'Does not exist in the database successful'); + + + + + + -- 2.1.4