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>
master
3 changed files with 11 additions and 11 deletions
  1. +3
    -3
      C4/RotatingCollections.pm
  2. +1
    -1
      rotating_collections/transferCollection.pl
  3. +7
    -7
      t/db_dependent/RotatingCollections.t

+ 3
- 3
C4/RotatingCollections.pm View File

@@ -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;


+ 1
- 1
rotating_collections/transferCollection.pl View File

@@ -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) {


+ 7
- 7
t/db_dependent/RotatingCollections.t View File

@@ -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