Bug 39721: Add test for accepter

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 344d66e4d4)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Baptiste Wojtkowski 2026-01-23 13:22:14 +00:00 committed by Jacob O'Mara
parent 4b0b94bb0d
commit f0dd777cae
No known key found for this signature in database
1 changed files with 19 additions and 2 deletions

View File

@ -272,8 +272,8 @@ subtest 'constraints' => sub {
$schema->storage->txn_rollback;
};
subtest 'manager, suggester, rejecter, last_modifier' => sub {
plan tests => 8;
subtest 'manager, suggester, accepter, rejecter, last_modifier' => sub {
plan tests => 11;
$schema->storage->txn_begin;
my $suggestion = $builder->build_object( { class => 'Koha::Suggestions' } );
@ -288,6 +288,11 @@ subtest 'manager, suggester, rejecter, last_modifier' => sub {
'Koha::Patron',
'->rejecter should have returned a Koha::Patron object'
);
is(
ref( $suggestion->accepter ),
'Koha::Patron',
'->accepter should have returned a Koha::Patron object'
);
is(
ref( $suggestion->suggester ),
'Koha::Patron',
@ -303,6 +308,7 @@ subtest 'manager, suggester, rejecter, last_modifier' => sub {
{
managedby => undef,
rejectedby => undef,
acceptedby => undef,
suggestedby => undef,
lastmodificationby => undef
}
@ -316,6 +322,10 @@ subtest 'manager, suggester, rejecter, last_modifier' => sub {
$suggestion->rejecter, undef,
'->rejecter should have returned undef if no rejecter set'
);
is(
$suggestion->accepter, undef,
'->accepter should have returned undef if no rejecter set'
);
is(
$suggestion->suggester, undef,
'->suggester should have returned undef if no suggester set'
@ -326,6 +336,13 @@ subtest 'manager, suggester, rejecter, last_modifier' => sub {
'->last_modifier should have returned undef if no last_modifier set'
);
my $accepter = $builder->build_object( { class => 'Koha::Patrons' } );
$suggestion->set(
{
acceptedby => $accepter->id,
}
);
is( $suggestion->accepter->id, $accepter->id, 'Accepter correctly retrieved' );
$schema->storage->txn_rollback;
};