diff --git a/t/db_dependent/Koha/Ticket.t b/t/db_dependent/Koha/Ticket.t index 7734f6de67..cc1798ef19 100755 --- a/t/db_dependent/Koha/Ticket.t +++ b/t/db_dependent/Koha/Ticket.t @@ -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; diff --git a/t/db_dependent/Koha/Ticket/Update.t b/t/db_dependent/Koha/Ticket/Update.t index ebd1b4997d..ec33fa89fc 100755 --- a/t/db_dependent/Koha/Ticket/Update.t +++ b/t/db_dependent/Koha/Ticket/Update.t @@ -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;