Browse Source

Bug 26618: (QA follow-up) Fix unit test for TranferCollection change

We update TransferCollection to use the settled upon standard for
passing error messages back from a method. This patch updates the
corresponding unit test.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Martin Renvoize 3 years ago
committed by Jonathan Druart
parent
commit
138212f856
  1. 6
      C4/RotatingCollections.pm
  2. 2
      rotating_collections/transferCollection.pl
  3. 14
      t/db_dependent/RotatingCollections.t

6
C4/RotatingCollections.pm

@ -399,7 +399,7 @@ sub RemoveItemFromCollection {
=head2 TransferCollection
( $success, $errorcode, $errormessage ) = TransferCollection( $colId, $colBranchcode );
( $success, $messages ) = TransferCollection( $colId, $colBranchcode );
Transfers a collection to another branch
@ -418,10 +418,10 @@ sub TransferCollection {
## Check for all necessary parameters
if ( !$colId ) {
return ( 0, 1, "NO_ID" );
return ( 0, [{ type => 'error', code => 'NO_ID' }] );
}
if ( !$colBranchcode ) {
return ( 0, 2, "NO_BRANCHCODE" );
return ( 0, [{ type => 'error', code => 'NO_BRANCHCODE' }] );
}
my $dbh = C4::Context->dbh;

2
rotating_collections/transferCollection.pl

@ -43,7 +43,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
## Transfer collection
my ( $success, $messages );
if ($toBranch) {
( $success, $messages) =
( $success, $messages ) =
TransferCollection( $colId, $toBranch );
if ($success) {

14
t/db_dependent/RotatingCollections.t

@ -194,7 +194,8 @@ my $samplebranch = {
opac_info => 'sample opac',
};
Koha::Library->new($samplebranch)->store;
is( TransferCollection( $collection_id1, $samplebranch->{branchcode} ),
my ( $transferred, $messages ) = TransferCollection( $collection_id1, $samplebranch->{branchcode} );
is( $transferred,
1, "Collection1 has been transfered in the branch SAB" );
@collection1 = GetCollection($collection_id1);
is_deeply(
@ -205,12 +206,11 @@ is_deeply(
],
"Collection1 belongs to the sample branch (SAB)"
);
is( TransferCollection, "NO_ID", "TransferCollection without ID" );
is(
TransferCollection($collection_id1),
'NO_BRANCHCODE',
"TransferCollection without branchcode"
);
( $transferred, $messages ) = TransferCollection();
is( $messages->[0]->{code}, "NO_ID", "TransferCollection without ID" );
( $transferred, $messages ) = TransferCollection($collection_id1);
is( $messages->[0]->{code},
'NO_BRANCHCODE', "TransferCollection without branchcode" );
#Test AddItemToCollection
my $record = MARC::Record->new();

Loading…
Cancel
Save