Bugzilla – Attachment 3340 Details for
Bug 5880
C4/Koha.pm : adding two functions GetAuthorisedValueByCode and GetKohaImageurlFromAuthorisedValues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Improved unit tests
0001-Follow-up-for-bug-5880-Improved-unit-test.patch (text/plain), 2.42 KB, created by
Julian Maurice
on 2011-03-17 13:32:35 UTC
(
hide
)
Description:
Improved unit tests
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2011-03-17 13:32:35 UTC
Size:
2.42 KB
patch
obsolete
>From 6af6e0e7acdc76550fdb5eb02e3c9af6ab2ac3a9 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 17 Mar 2011 14:26:32 +0100 >Subject: [PATCH] Follow up for bug 5880: Improved unit test > >The unit test Koha.t now skip tests of the two subroutines if the insert >query failed. >--- > t/db_dependent/Koha.t | 22 +++++++++++++++------- > 1 files changed, 15 insertions(+), 7 deletions(-) > >diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t >index bdbb348..016525a 100644 >--- a/t/db_dependent/Koha.t >+++ b/t/db_dependent/Koha.t >@@ -7,7 +7,7 @@ use strict; > use warnings; > use C4::Context; > >-use Test::More tests => 3; >+use Test::More tests => 4; > > BEGIN { > use_ok('C4::Koha'); >@@ -26,14 +26,22 @@ my $dbh = C4::Context->dbh; > # Insert an entry into authorised_value table > my $query = "INSERT INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl) VALUES (?,?,?,?,?);"; > my $sth = $dbh->prepare($query); >-$sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); >+my $insert_success = $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); >+ok($insert_success, "Insert data in database"); >+ > > # Tests >-is ( GetAuthorisedValueByCode($data->{category}, $data->{authorised_value}), $data->{lib}, "GetAuthorisedValueByCode" ); >-is ( GetKohaImageurlFromAuthorisedValues($data->{category}, $data->{lib}), $data->{imageurl}, "GetKohaImageurlFromAuthorisedValues" ); >+SKIP: { >+ skip "INSERT failed", 2 unless $insert_success; >+ >+ is ( GetAuthorisedValueByCode($data->{category}, $data->{authorised_value}), $data->{lib}, "GetAuthorisedValueByCode" ); >+ is ( GetKohaImageurlFromAuthorisedValues($data->{category}, $data->{lib}), $data->{imageurl}, "GetKohaImageurlFromAuthorisedValues" ); >+} > > # Clean up >-$query = "DELETE FROM authorised_values WHERE category=? AND authorised_value=? AND lib=? AND lib_opac=? AND imageurl=?;"; >-$sth = $dbh->prepare($query); >-$sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); >+if($insert_success){ >+ $query = "DELETE FROM authorised_values WHERE category=? AND authorised_value=? AND lib=? AND lib_opac=? AND imageurl=?;"; >+ $sth = $dbh->prepare($query); >+ $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); >+} > >-- >1.7.4.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5880
:
3318
|
3336
| 3340 |
3399