Bug 35628: Add unit tests for Koha::Ticket addition

We add a strings_map method to Koha::Ticket and thus need to have
corresponding unit tests.

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-25 16:33:25 +01:00 committed by Katrin Fischer
parent e968e80dd9
commit 8019b5fdba
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 40 additions and 1 deletions

View File

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 6;
use Test::More tests => 7;
use t::lib::TestBuilder;
use t::lib::Mocks;
@ -227,3 +227,42 @@ subtest 'store() tests' => sub {
$schema->storage->txn_rollback;
};
};
subtest 'strings_map() tests' => sub {
plan tests => 8;
$schema->storage->txn_begin;
my $status_av = $builder->build_object(
{
class => 'Koha::AuthorisedValues',
value => {
authorised_value => 'TEST',
category => 'TICKET_STATUS',
lib => 'internal description',
lib_opac => 'public description',
}
}
);
my $ticket = $builder->build_object(
{
class => 'Koha::Tickets',
value => { status => 'TEST' }
}
);
my $strings = $ticket->strings_map();
ok( exists $strings->{status}, "'status' entry exists" );
is( $strings->{status}->{str}, $status_av->lib, "'str' set to av->lib" );
is( $strings->{status}->{type}, 'av', "'type' is 'av'" );
is( $strings->{status}->{category}, 'TICKET_STATUS', "'category' exists and set to 'TICKET_STATUS'" );
$strings = $ticket->strings_map( { public => 1 } );
ok( exists $strings->{status}, "'status' entry exists when called in public" );
is( $strings->{status}->{str}, $status_av->lib_opac, "'str' set to av->lib_opac when called in public" );
is( $strings->{status}->{type}, 'av', "'type' is 'av'" );
is( $strings->{status}->{category}, 'TICKET_STATUS', "'category' exists and set to 'TICKET_STATUS'" );
$schema->storage->txn_rollback;
};