Bug 32435: Unit tests for Ticket/Ticket::Update change

We add a fallback to allow TICKET_RESOLUTIONS to be returned in the
strings_map as additional TICKET_STATUS states.

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:58:34 +01:00 committed by Katrin Fischer
parent eec197565c
commit bc59661f14
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 64 additions and 2 deletions

View file

@ -229,7 +229,7 @@ subtest 'store() tests' => sub {
};
subtest 'strings_map() tests' => sub {
plan tests => 8;
plan tests => 16;
$schema->storage->txn_begin;
@ -264,5 +264,36 @@ subtest 'strings_map() tests' => sub {
is( $strings->{status}->{type}, 'av', "'type' is 'av'" );
is( $strings->{status}->{category}, 'TICKET_STATUS', "'category' exists and set to 'TICKET_STATUS'" );
my $resolution_av = $builder->build_object(
{
class => 'Koha::AuthorisedValues',
value => {
authorised_value => 'RES_TEST',
category => 'TICKET_RESOLUTION',
lib => 'internal resolution description',
lib_opac => 'public resolution description',
}
}
);
$ticket = $builder->build_object(
{
class => 'Koha::Tickets',
value => { status => 'RES_TEST' }
}
);
$strings = $ticket->strings_map();
ok( exists $strings->{status}, "'status' entry exists for resolution fallthrough" );
is( $strings->{status}->{str}, $resolution_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 for resolution fallthrough when called in public" );
is( $strings->{status}->{str}, $resolution_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;
};

View file

@ -74,7 +74,7 @@ subtest 'user() tests' => sub {
};
subtest 'strings_map() tests' => sub {
plan tests => 8;
plan tests => 16;
$schema->storage->txn_begin;
@ -109,5 +109,36 @@ subtest 'strings_map() tests' => sub {
is( $strings->{status}->{type}, 'av', "'type' is 'av'" );
is( $strings->{status}->{category}, 'TICKET_STATUS', "'category' exists and set to 'TICKET_STATUS'" );
my $resolution_av = $builder->build_object(
{
class => 'Koha::AuthorisedValues',
value => {
authorised_value => 'RES_TEST',
category => 'TICKET_RESOLUTION',
lib => 'internal resolution description',
lib_opac => 'public resolution description',
}
}
);
$ticket_update = $builder->build_object(
{
class => 'Koha::Ticket::Updates',
value => { status => 'RES_TEST' }
}
);
$strings = $ticket_update->strings_map();
ok( exists $strings->{status}, "'status' entry exists for resolution fallthrough" );
is( $strings->{status}->{str}, $resolution_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_update->strings_map( { public => 1 } );
ok( exists $strings->{status}, "'status' entry exists for resolution fallthrough when called in public" );
is( $strings->{status}->{str}, $resolution_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;
};