From 138212f856f760427cf9d0f50bce357620576ebe Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 22 Feb 2021 12:15:44 +0000 Subject: [PATCH] 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 --- C4/RotatingCollections.pm | 6 +++--- rotating_collections/transferCollection.pl | 2 +- t/db_dependent/RotatingCollections.t | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm index e8e814f455..b7a7bb3a74 100644 --- a/C4/RotatingCollections.pm +++ b/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; diff --git a/rotating_collections/transferCollection.pl b/rotating_collections/transferCollection.pl index 6c1bcde1ff..f489135407 100755 --- a/rotating_collections/transferCollection.pl +++ b/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) { diff --git a/t/db_dependent/RotatingCollections.t b/t/db_dependent/RotatingCollections.t index 4bc5ffa932..7ea21c4c7b 100755 --- a/t/db_dependent/RotatingCollections.t +++ b/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(); -- 2.39.5