Bug 27857: Start a transaction foreach subtest

There is a random failure

     # Looks like you planned 15 tests but ran 2.

 #   Failed test 'extended_attributes'
 #   at t/db_dependent/Koha/Patron.t line 664.
 Missing mandatory extended attribute (type=B0vCQxlI)# Looks like your test exited with 255 just after 7.
 [17:00:24] t/db_dependent/Koha/Patron.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-04-21 09:44:58 +02:00
parent f964efacb9
commit d667150e16

View file

@ -499,10 +499,14 @@ subtest 'extended_attributes' => sub {
#$limited_value = $patron_1->get_extended_attribute( $attribute_type_limited->code );
#is( $limited_value, undef, );
$schema->storage->txn_rollback;
subtest 'non-repeatable attributes tests' => sub {
plan tests => 3;
$schema->storage->txn_begin;
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
my $attribute_type = $builder->build_object(
{
@ -526,12 +530,17 @@ subtest 'extended_attributes' => sub {
'Exception thrown on non-repeatable attribute';
is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' );
$schema->storage->txn_rollback;
};
subtest 'unique attributes tests' => sub {
plan tests => 5;
$schema->storage->txn_begin;
my $patron_1 = $builder->build_object({ class => 'Koha::Patrons' });
my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' });
@ -573,12 +582,17 @@ subtest 'extended_attributes' => sub {
is( $patron_1->extended_attributes->count, 2, 'Extended attributes stored' );
is( $patron_2->extended_attributes->count, 0, 'Extended attributes storing rolled back' );
$schema->storage->txn_rollback;
};
subtest 'invalid type attributes tests' => sub {
plan tests => 3;
$schema->storage->txn_begin;
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
my $attribute_type_1 = $builder->build_object(
@ -612,12 +626,17 @@ subtest 'extended_attributes' => sub {
'Exception thrown on invalid attribute type';
is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' );
$schema->storage->txn_rollback;
};
subtest 'globally mandatory attributes tests' => sub {
plan tests => 5;
$schema->storage->txn_begin;
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
my $attribute_type_1 = $builder->build_object(
@ -658,7 +677,9 @@ subtest 'extended_attributes' => sub {
);
is( $patron->extended_attributes->count, 1, 'Extended attributes succeeded' );
$schema->storage->txn_rollback;
};
$schema->storage->txn_rollback;
};