Bugzilla – Attachment 29832 Details for
Bug 12493
The module C4::Acquisition.pm contains subroutines which belong to C4::Contract.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 12493: unit tests for the module C4::Contract.pm
PASSED-QA-Bug-12493-unit-tests-for-the-module-C4Co.patch (text/plain), 7.70 KB, created by
Kyle M Hall (khall)
on 2014-07-18 13:26:14 UTC
(
hide
)
Description:
[PASSED QA] Bug 12493: unit tests for the module C4::Contract.pm
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-07-18 13:26:14 UTC
Size:
7.70 KB
patch
obsolete
>From 8422b699cfcceade1425df55b4bf6ebd6987d947 Mon Sep 17 00:00:00 2001 >From: Yohann Dufour <dufour.yohann@gmail.com> >Date: Mon, 30 Jun 2014 10:02:01 +0200 >Subject: [PATCH] [PASSED QA] Bug 12493: unit tests for the module C4::Contract.pm > >This patch are the unit tests of the previous patch > >Test plan : >Same as the previous patch > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Comments on previous patch > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Contract.t | 136 +++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 136 insertions(+), 0 deletions(-) > create mode 100644 t/db_dependent/Contract.t > >diff --git a/t/db_dependent/Contract.t b/t/db_dependent/Contract.t >new file mode 100644 >index 0000000..0f348a7 >--- /dev/null >+++ b/t/db_dependent/Contract.t >@@ -0,0 +1,136 @@ >+#!/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::Bookseller; >+ >+use Test::More tests => 40; >+ >+BEGIN { >+ use_ok('C4::Contract'); >+} >+ >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+$dbh->do(q|DELETE FROM aqbasket|); >+$dbh->do(q|DELETE FROM aqcontract|); >+$dbh->do(q|DELETE FROM aqbooksellers|); >+ >+ >+my $bookseller_id1 = C4::Bookseller::AddBookseller( { name => 'My first bookseller' } ); >+isnt( $bookseller_id1, undef, 'AddBookseller does not return undef' ); >+my $bookseller_id2 = C4::Bookseller::AddBookseller( { name => 'My second bookseller' } ); >+isnt( $bookseller_id2, undef, 'AddBookseller does not return undef' ); >+my $contracts = GetContracts(); >+is( @$contracts, 0, 'GetContracts returns the correct number of contracts' ); >+ >+my $my_contract1 = { >+ contractstartdate => '2014-06-01', >+ contractenddate => '2014-06-30', >+ contractname => 'My contract name', >+ contractdescription => 'My contract description', >+ booksellerid => $bookseller_id1, >+}; >+my $my_contract_id1 = AddContract($my_contract1); >+isnt( $my_contract_id1, undef, 'AddContract does not return undef' ); >+$contracts = GetContracts(); >+is( @$contracts, 1, 'AddContract adds a contract' ); >+my $contract = GetContract( { contractnumber => $my_contract_id1 } ); >+is( $contract->{contractstartdate}, $my_contract1->{contractstartdate}, 'AddContract stores the contract start date correctly.' ); >+is( $contract->{contractenddate}, $my_contract1->{contractenddate}, 'AddContract stores the contract end date correctly.' ); >+is( $contract->{contractname}, $my_contract1->{contractname}, 'AddContract stores the contract name correctly.' ); >+is( $contract->{contractdescription}, $my_contract1->{contractdescription}, 'AddContract stores the contract description correctly.' ); >+is( $contract->{booksellerid}, $my_contract1->{booksellerid}, 'AddContract stores the bookseller id correctly.' ); >+ >+ >+$my_contract1 = { >+ contractstartdate => '2015-07-02', >+ contractenddate => '2015-07-31', >+ contractname => 'My modified contract name', >+ contractdescription => 'My modified contract description', >+ booksellerid => $bookseller_id2, >+}; >+my $mod_status = ModContract($my_contract1); >+is( $mod_status, '0E0', 'ModContract without the contract number returns 0E0' ); >+ >+$my_contract1->{contractnumber} = $my_contract_id1; >+$mod_status = ModContract($my_contract1); >+is( $mod_status, 1, 'ModContract returns true' ); >+$contracts = GetContracts(); >+is( @$contracts, 1, 'ModContract does not modify the number of contracts' ); >+$contract = GetContract( { contractnumber => $my_contract_id1 } ); >+is( $contract->{contractstartdate}, $my_contract1->{contractstartdate}, 'ModContract updates the contract start date correctly.' ); >+is( $contract->{contractenddate}, $my_contract1->{contractenddate}, 'ModContract updates the contract end date correctly.' ); >+is( $contract->{contractname}, $my_contract1->{contractname}, 'ModContract updates the contract name correctly.' ); >+is( $contract->{contractdescription}, $my_contract1->{contractdescription}, 'ModContract updates the contract description correctly.' ); >+is( $contract->{booksellerid}, $my_contract1->{booksellerid}, 'ModContract updates the bookseller id correctly.' ); >+ >+ >+my $my_contract2 = { >+ contractstartdate => '2013-08-05', >+ contractenddate => '2013-09-25', >+ contractname => 'My other contract name', >+ contractdescription => 'My other description contract name', >+ booksellerid => $bookseller_id1, >+}; >+my $my_contract_id2 = AddContract($my_contract2); >+$contracts = GetContracts( { booksellerid => $bookseller_id1 } ); >+is( @$contracts, 1, 'GetContracts returns the correct number of contracts' ); >+$contracts = GetContracts({ >+ booksellerid => $bookseller_id1, >+ activeonly => 1 >+}); >+is( @$contracts, 0, 'GetContracts with active only returns only current contracts' ); >+$contracts = GetContracts( { booksellerid => $bookseller_id2 } ); >+is( @$contracts, 1, 'GetContracts returns the correct number of contracts' ); >+$contracts = GetContracts(); >+is( @$contracts, 2, 'GetContracts returns the correct number of contracts' ); >+ >+is( $contracts->[0]->{contractnumber}, $my_contract_id1, 'GetContracts returns the contract number correctly' ); >+is( $contracts->[0]->{contractstartdate}, $my_contract1->{contractstartdate}, 'GetContracts returns the contract start date correctly.' ); >+is( $contracts->[0]->{contractenddate}, $my_contract1->{contractenddate}, 'GetContracts returns the contract end date correctly.' ); >+is( $contracts->[0]->{contractname}, $my_contract1->{contractname}, 'GetContracts returns the contract name correctly.' ); >+is( $contracts->[0]->{contractdescription}, $my_contract1->{contractdescription}, 'GetContracts returns the contract description correctly.' ); >+is( $contracts->[0]->{booksellerid}, $my_contract1->{booksellerid}, 'GetContracts returns the bookseller id correctly.' ); >+ >+is( $contracts->[1]->{contractnumber}, $my_contract_id2, 'GetContracts returns the contract number correctly' ); >+is( $contracts->[1]->{contractstartdate}, $my_contract2->{contractstartdate}, 'GetContracts returns the contract start date correctly.' ); >+is( $contracts->[1]->{contractenddate}, $my_contract2->{contractenddate}, 'GetContracts returns the contract end date correctly.' ); >+is( $contracts->[1]->{contractname}, $my_contract2->{contractname}, 'GetContracts returns the contract name correctly.' ); >+is( $contracts->[1]->{contractdescription}, $my_contract2->{contractdescription}, 'GetContracts returns the contract description correctly.' ); >+is( $contracts->[1]->{booksellerid}, $my_contract2->{booksellerid}, 'GetContracts returns the bookseller id correctly.' ); >+ >+ >+my $del_status = DelContract(); >+is( $del_status, undef, 'DelContract without contract number returns undef' ); >+ >+$del_status = DelContract( { contractnumber => $my_contract_id1 } ); >+is( $del_status, 1, 'DelContract returns true' ); >+$contracts = GetContracts(); >+is( @$contracts, 1, 'DelContract deletes a contract' ); >+ >+$del_status = DelContract( { contractnumber => $my_contract_id2 } ); >+is( $del_status, 1, 'DelContract returns true' ); >+$contracts = GetContracts(); >+is( @$contracts, 0, 'DelContract deletes a contract' ); >+ >+$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 12493
:
29329
|
29353
|
29494
|
29495
|
29568
|
29831
| 29832 |
29833