Bugzilla – Attachment 33374 Details for
Bug 8836
Resurrect Rotating Collections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8836: (RM followup) unit tests should use the new API
Bug-8836-RM-followup-unit-tests-should-use-the-new.patch (text/plain), 8.25 KB, created by
Tomás Cohen Arazi (tcohen)
on 2014-11-07 14:24:41 UTC
(
hide
)
Description:
Bug 8836: (RM followup) unit tests should use the new API
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2014-11-07 14:24:41 UTC
Size:
8.25 KB
patch
obsolete
>From 1cabaa32b40f225dedfc969db02af596d7d22994 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Fri, 7 Nov 2014 11:09:14 -0300 >Subject: [PATCH] Bug 8836: (RM followup) unit tests should use the new API > >Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> >--- > t/db_dependent/RotatingCollections.t | 130 ++++++++++++++++++++++------------- > 1 file changed, 81 insertions(+), 49 deletions(-) > >diff --git a/t/db_dependent/RotatingCollections.t b/t/db_dependent/RotatingCollections.t >index 87a6ad4..125dddc 100644 >--- a/t/db_dependent/RotatingCollections.t >+++ b/t/db_dependent/RotatingCollections.t >@@ -1,8 +1,23 @@ > #!/usr/bin/perl > >+# This file is part of Koha. >+# >+# 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 Test::More tests => 41; >+use Test::More tests => 52; > use C4::Context; > use C4::Branch; > use C4::Biblio; >@@ -48,34 +63,43 @@ $dbh->do(q|DELETE FROM branchcategories|); > my $collections = GetCollections(); > my $countcollection = scalar(@$collections); > >-is( CreateCollection( 'Collection1', 'Description1' ), >- 1, "All parameters have been given - Collection 1 added" ); >+my ($success,$errorCode,$errorMessage); >+ >+($success,$errorCode,$errorMessage) = CreateCollection( 'Collection1', 'Description1' ); >+is( $success, 1, "All parameters have been given - Collection 1 added" ); >+ok( !defined $errorCode && !defined $errorMessage, >+ "Collection added, no error code or message"); > my $collection_id1 = $dbh->last_insert_id( undef, undef, 'collections', undef ); >-is( CreateCollection( 'Collection2', 'Description2' ), >- 1, "All parameters have been given - Collection 2 added" ); >+ >+($success,$errorCode,$errorMessage) = CreateCollection( 'Collection2', 'Description2' ); >+is( $success, 1, "All parameters have been given - Collection 2 added" ); >+ok( !defined $errorCode && !defined $errorMessage, >+ "Collection added, no error code or message"); > my $collection_id2 = $dbh->last_insert_id( undef, undef, 'collections', undef ); >+ > $collections = GetCollections(); >-is( >- scalar(@$collections), >- $countcollection + 2, >- "Collection1 and Collection2 have been added" >-); >-my $collection = CreateCollection('Collection'); >-is( $collection, 'No Description Given', "The field description is missing" ); >-$collection = CreateCollection(); >-is( >- $collection, >- 'No Title Given', >- "The field description and title is missing" >-); >+is( scalar(@$collections), $countcollection + 2, >+ "Collection1 and Collection2 have been added" ); >+ >+($success,$errorCode,$errorMessage) = CreateCollection('Collection3'); >+is( $success, 1, "Collections can be created without description" ); >+ok( !defined $errorCode && !defined $errorMessage, >+ "Collection added, no error code or message"); >+my $collection_id3 = $dbh->last_insert_id( undef, undef, 'collections', undef ); >+ >+($success,$errorCode,$errorMessage) = CreateCollection(); >+is( $success, 0, "Title missing, fails to create collection" ); >+is( $errorCode, 1, "Title missing, error code is 1" ); >+is( $errorMessage, 'NO_TITLE', "Title missing, error message is NO_TITLE" ); >+ > $collections = GetCollections(); >-is( scalar(@$collections), $countcollection + 2, "No collection added" ); >+is( scalar(@$collections), $countcollection + 3, "Only one collection added" ); > > #FIXME, as the id is auto incremented, two similar Collections (same title /same description) can be created > #$collection1 = CreateCollection('Collection1','Description1'); > > #Test GetCollections >-$collection = GetCollections(); >+my $collection = GetCollections(); > is_deeply( > $collections, > [ >@@ -90,37 +114,36 @@ is_deeply( > colTitle => 'Collection2', > colDesc => 'Description2', > colBranchcode => undef >+ }, >+ { >+ colId => $collection_id3, >+ colTitle => 'Collection3', >+ colDesc => '', >+ colBranchcode => undef > } >+ > ], > 'All Collections' > ); > > #Test UpdateCollection >-is( >- UpdateCollection( >- $collection_id2, >- 'Collection2 modified', >- 'Description2 modified' >- ), >- 1, >- "Collection2 has been modified" >-); >+($success,$errorCode,$errorMessage) = >+ UpdateCollection( $collection_id2, 'Collection2bis', undef ); >+is( $success, 1, "UpdateCollection succeeds without description"); > >-#FIXME : The following test should pass, currently, with a wrong id UpdateCollection returns 1 even if nothing has been modified >-#is(UpdateCollection(-1,'Collection2 modified','Description2 modified'), >-# 0, >-# "UpdateCollection with a wrong id"); >-is( >- UpdateCollection( 'Collection', 'Description' ), >- 'No Description Given', >- "UpdateCollection without description" >-); >-is( >- UpdateCollection( 'Description' ), >- 'No Title Given', >- "UpdateCollection without title" >-); >-is( UpdateCollection(), 'No Id Given', "UpdateCollection without params" ); >+($success,$errorCode,$errorMessage) = >+ UpdateCollection( $collection_id2, 'Collection2 modified', 'Description2 modified' ); >+is( $success, 1, "Collection2 has been modified" ); >+ok( !defined $errorCode && !defined $errorMessage, >+ "Collection2 modified, no error code or message"); >+ >+($success,$errorCode,$errorMessage) = >+ UpdateCollection( $collection_id2, undef, 'Description' ), >+ok( !$success, "UpdateCollection fails without title" ); >+is( $errorCode, 2, "Title missing, error code is 2"); >+is( $errorMessage, 'NO_TITLE', "Title missing, error message is NO_TITLE"); >+ >+is( UpdateCollection(), 'NO_ID', "UpdateCollection without params" ); > > #Test GetCollection > my @collection1 = GetCollection($collection_id1); >@@ -181,10 +204,10 @@ is_deeply( > ], > "Collection1 belongs to the sample branch (SAB)" > ); >-is( TransferCollection, "No Id Given", "TransferCollection without ID" ); >+is( TransferCollection, "NO_ID", "TransferCollection without ID" ); > is( > TransferCollection($collection_id1), >- "No Branchcode Given", >+ 'NO_BRANCHCODE', > "TransferCollection without branchcode" > ); > >@@ -224,7 +247,8 @@ is( AddItemToCollection( $collection_id1, $item_id2 ), > 1, "Sampleitem2 has been added to Collection1" ); > > #Test GetItemsInCollection >-my $itemsincollection1 = GetItemsInCollection($collection_id1); >+my $itemsincollection1; >+($itemsincollection1,$success,$errorCode,$errorMessage) = GetItemsInCollection($collection_id1); > is( scalar @$itemsincollection1, 2, "Collection1 has 2 items" ); > is_deeply( > $itemsincollection1, >@@ -232,16 +256,22 @@ is_deeply( > { > title => undef, > itemcallnumber => 'callnumber1', >+ biblionumber => $biblionumber, > barcode => 1 > }, > { > title => undef, > itemcallnumber => 'callnumber2', >+ biblionumber => $biblionumber, > barcode => 2 > } > ], > "Collection1 has Item1 and Item2" > ); >+($itemsincollection1,$success,$errorCode,$errorMessage) = GetItemsInCollection(); >+ok( !$success, "GetItemsInCollection fails without a collection ID" ); >+is( $errorCode, 1, "Title missing, error code is 2"); >+is( $errorMessage, 'NO_ID', "Collection ID missing, error message is NO_ID"); > > #Test RemoveItemFromCollection > is( RemoveItemFromCollection( $collection_id1, $item_id2 ), >@@ -293,15 +323,17 @@ is( DeleteCollection($collection_id2), 1, "Collection2 deleted" ); > is( DeleteCollection($collection_id1), 1, "Collection1 deleted" ); > is( > DeleteCollection(), >- 'No Collection Id Given', >+ 'NO_ID', > "DeleteCollection without id" > ); > $collections = GetCollections(); > is( > scalar(@$collections), >- $countcollection + 0, >+ $countcollection + 1, > "Two Collections have been deleted" > ); > > #End transaction > $dbh->rollback; >+ >+1; >-- >1.9.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 8836
:
12560
|
16746
|
19118
|
19119
|
19337
|
19339
|
21008
|
21009
|
21010
|
21011
|
23966
|
23967
|
23968
|
23969
|
23970
|
23971
|
23976
|
28140
|
28141
|
30838
|
30921
|
31087
|
32361
|
32362
|
32588
|
32589
|
32690
|
32691
|
32693
|
32773
|
32774
|
32973
|
32974
|
32975
|
32976
|
32994
|
32999
|
33000
|
33001
|
33002
|
33045
|
33046
|
33047
|
33048
|
33050
|
33051
|
33058
|
33059
|
33060
|
33061
|
33062
|
33063
|
33064
|
33065
|
33066
|
33068
|
33070
|
33095
|
33096
|
33097
|
33098
|
33099
|
33100
|
33101
|
33102
|
33103
|
33330
|
33331
| 33374