Bug 35657: Unit tests for relation accessor additions

This patch adds the unit tests for the new 'assignee' relation accessors
added to Koha::Ticket and Koha::Ticket::Update classes.

Signed-off-by: Paul Derscheid <paulderscheid@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-04-26 14:24:08 +01:00 committed by Katrin Fischer
parent e70f9979c5
commit 9bbdbb50e0
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 44 additions and 2 deletions

View File

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 7;
use Test::More tests => 8;
use t::lib::TestBuilder;
use t::lib::Mocks;
@ -51,6 +51,27 @@ subtest 'reporter() tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'assignee() tests' => sub {
plan tests => 2;
$schema->storage->txn_begin;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
my $ticket = $builder->build_object(
{
class => 'Koha::Tickets',
value => { assignee_id => $patron->id }
}
);
my $assignee = $ticket->assignee;
is( ref($assignee), 'Koha::Patron', 'Koha::Ticket->assignee returns a Koha::Patron object' );
is( $assignee->id, $patron->id, 'Koha::Ticket->assignee returns the right Koha::Patron' );
$schema->storage->txn_rollback;
};
subtest 'resolver() tests' => sub {
plan tests => 2;

View File

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 3;
use Test::More tests => 4;
use t::lib::TestBuilder;
use Koha::Database;
@ -73,6 +73,27 @@ subtest 'user() tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'assignee() tests' => sub {
plan tests => 2;
$schema->storage->txn_begin;
my $assignee = $builder->build_object( { class => 'Koha::Patrons' } );
my $update = $builder->build_object(
{
class => 'Koha::Ticket::Updates',
value => { assignee_id => $assignee->id }
}
);
my $linked_assignee = $update->assignee;
is( ref($linked_assignee), 'Koha::Patron', 'Koha::Ticket::Update->assignee returns a Koha::Patron object' );
is( $linked_assignee->id, $assignee->id, 'Koha::Ticket::Update->assignee returns the right Koha::Patron' );
$schema->storage->txn_rollback;
};
subtest 'strings_map() tests' => sub {
plan tests => 16;