Bugzilla – Attachment 29645 Details for
Bug 12417
Koha::Borrower::Files.pm needs unit tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 12417: adding the units tests of the module Koha::Borrower::Files.pm
PASSED-QA-Bug-12417-adding-the-units-tests-of-the-.patch (text/plain), 4.93 KB, created by
Kyle M Hall (khall)
on 2014-07-11 15:29:50 UTC
(
hide
)
Description:
[PASSED QA] Bug 12417: adding the units tests of the module Koha::Borrower::Files.pm
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-07-11 15:29:50 UTC
Size:
4.93 KB
patch
obsolete
>From 4706c9b1557642c1aa8974bee4ceb65298651afa Mon Sep 17 00:00:00 2001 >From: Yohann Dufour <dufour.yohann@gmail.com> >Date: Mon, 16 Jun 2014 13:46:24 +0200 >Subject: [PATCH] [PASSED QA] Bug 12417: adding the units tests of the module Koha::Borrower::Files.pm > >The module Koha::Borrower::Files.pm was not tested > >To test: >1/ Execute the command: prove t/db_dependent/Borrower_Files.t >2/ The command has to print: >t/db_dependent/Borrower_Files.t .. ok >All tests successful. >Files=1, Tests=23, 2 wallclock secs ( 0.04 usr 0.01 sys + 1.47 cusr 0.08 csys = 1.60 CPU) >Result: PASS > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Squashed patches. >Now test pass >No koha-qa errors > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Borrower_Files.t | 122 +++++++++++++++++++++++++++++++++++++++ > 1 files changed, 122 insertions(+), 0 deletions(-) > create mode 100644 t/db_dependent/Borrower_Files.t > >diff --git a/t/db_dependent/Borrower_Files.t b/t/db_dependent/Borrower_Files.t >new file mode 100644 >index 0000000..281cefd >--- /dev/null >+++ b/t/db_dependent/Borrower_Files.t >@@ -0,0 +1,122 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2014 Biblibre SARL >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use C4::Context; >+use C4::Members; >+ >+use Test::More tests => 23; >+ >+use_ok('Koha::Borrower::Files'); >+ >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+$dbh->do(q|DELETE FROM issues|); >+$dbh->do(q|DELETE FROM borrowers|); >+$dbh->do(q|DELETE FROM borrower_files|); >+ >+my $borrowernumber = AddMember( >+ firstname => 'my firstname', >+ surname => 'my surname', >+ categorycode => 'S', >+ branchcode => 'CPL', >+); >+ >+my $bf = Koha::Borrower::Files->new( >+ borrowernumber => $borrowernumber, >+); >+ >+ >+my $addFile = $bf->AddFile( >+ name => 'my filename', >+ type => 'text/plain', >+); >+is( $addFile, undef, 'AddFile without the required parameter content returns undef' ); >+my $files = $bf->GetFilesInfo(); >+is( @$files, 0, 'AddFile does not add a file without the parameter content' ); >+ >+$addFile = $bf->AddFile( >+ type => 'text/plain', >+ content => 'my filecontent', >+); >+is( $addFile, undef, 'AddFile without the required parameter name returns undef' ); >+$files = $bf->GetFilesInfo(); >+is( @$files, 0, 'AddFile does not add a file without the parameter name' ); >+ >+ >+my $file1 = { >+ name => 'my filename1', >+ type => 'text/plain', >+ content => 'my filecontent1', >+}; >+$addFile = $bf->AddFile(%$file1); >+is( $addFile, 1, 'AddFile with the required parameters returns 1' ); >+$files = $bf->GetFilesInfo(); >+is( @$files, 1, 'GetFilesInfo returns 1 file' ); >+is( $files->[0]->{file_name}, $file1->{name}, 'Correctly stored name' ); >+is( $files->[0]->{file_type}, $file1->{type}, 'Correctly stored type' ); >+ >+ >+my $file2 = { >+ name => 'my filename2', >+ type => 'text/html', >+ description => 'my filedescription2', >+ content => 'my filecontent2', >+}; >+$addFile = $bf->AddFile(%$file2); >+is( $addFile, 1, 'AddFile with the required parameters returns 1' ); >+$files = $bf->GetFilesInfo(); >+is( @$files, 2, "GetFilesInfo returns 2 files" ); >+is( $files->[1]->{file_name}, $file2->{name}, 'Correctly stored name' ); >+is( $files->[1]->{file_type}, $file2->{type}, 'Correctly stored type' ); >+is( $files->[1]->{file_description}, $file2->{description}, 'Correctly stored description' ); >+ >+my $file = $bf->GetFile(); >+is( $file, undef, 'GetFile without parameters returns undef' ); >+ >+$file = $bf->GetFile( >+ id => $files->[1]->{file_id}, >+); >+is( $file->{file_name}, $files->[1]->{file_name}, 'GetFile returns the correct name' ); >+is( $file->{file_type}, $files->[1]->{file_type}, 'GetFile returns the correct type' ); >+is( $file->{file_description}, $files->[1]->{file_description}, 'GetFile returns the correct description' ); >+ >+ >+$bf->DelFile(); >+$files = $bf->GetFilesInfo(); >+is( @$files, 2, 'DelFile without parameters does not delete a file' ); >+ >+$bf->DelFile( >+ id => $files->[1]->{file_id}, >+); >+$files = $bf->GetFilesInfo(); >+is( @$files, 1, 'DelFile delete a file' ); >+is( $files->[0]->{file_name}, $file1->{name}, 'DelFile delete the correct entry' ); >+is( $files->[0]->{file_type}, $file1->{type}, 'DelFile delete the correct entry' ); >+ >+$bf->DelFile( >+ id => $files->[0]->{file_id}, >+); >+$files = $bf->GetFilesInfo(); >+is( @$files, 0, 'DelFile delete a file' ); >+ >+$dbh->rollback; >-- >1.7.2.5
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 12417
:
28864
|
29152
|
29188
|
29588
| 29645