From 139a864b8c0936a31020c6ac3e52ec6f16bcb45e Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 17 Aug 2017 11:44:18 +0200 Subject: [PATCH] Bug 19096: Restructure MarcSubfieldStructures.t first Content-Type: text/plain; charset=utf-8 Before adding more tests, move all current tests in one subtest. Test plan: Run t/db_dependent/Koha/MarcSubfieldStructures.t Signed-off-by: Josef Moravec --- t/db_dependent/Koha/MarcSubfieldStructures.t | 43 +++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/t/db_dependent/Koha/MarcSubfieldStructures.t b/t/db_dependent/Koha/MarcSubfieldStructures.t index b7ff454..d65f4cc 100644 --- a/t/db_dependent/Koha/MarcSubfieldStructures.t +++ b/t/db_dependent/Koha/MarcSubfieldStructures.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 3; +use Test::More tests => 1; use Koha::MarcSubfieldStructure; use Koha::MarcSubfieldStructures; @@ -30,27 +30,30 @@ use t::lib::TestBuilder; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; -my $builder = t::lib::TestBuilder->new; -my $nb_of_fields = Koha::MarcSubfieldStructures->search->count; -my $framework = $builder->build({ source => 'BiblioFramework' }); -my $new_field_1 = Koha::MarcSubfieldStructure->new({ - frameworkcode => $framework->{frameworkcode}, - tagfield => 200, - tagsubfield => 'a', -})->store; -my $new_field_2 = Koha::MarcSubfieldStructure->new({ - frameworkcode => $framework->{frameworkcode}, - tagfield => 245, - tagsubfield => 'a', -})->store; +subtest 'Trivial tests' => sub { + plan tests => 3; -is( Koha::MarcSubfieldStructures->search->count, $nb_of_fields + 2, 'The 2 fields should have been added' ); + my $builder = t::lib::TestBuilder->new; + my $nb_of_fields = Koha::MarcSubfieldStructures->search->count; + my $framework = $builder->build({ source => 'BiblioFramework' }); + my $new_field_1 = Koha::MarcSubfieldStructure->new({ + frameworkcode => $framework->{frameworkcode}, + tagfield => 200, + tagsubfield => 'a', + })->store; + my $new_field_2 = Koha::MarcSubfieldStructure->new({ + frameworkcode => $framework->{frameworkcode}, + tagfield => 245, + tagsubfield => 'a', + })->store; -my $retrieved_fields = Koha::MarcSubfieldStructures->search({ frameworkcode => $framework->{frameworkcode}, tagfield => 200, tagsubfield => 'a' }); -is( $retrieved_fields->count, 1, 'Search for a field by frameworkcode, tagfield and tagsubfield should return the field' ); + is( Koha::MarcSubfieldStructures->search->count, $nb_of_fields + 2, 'The 2 fields should have been added' ); -$retrieved_fields->next->delete; -is( Koha::MarcSubfieldStructures->search->count, $nb_of_fields + 1, 'Delete should have deleted the field' ); + my $retrieved_fields = Koha::MarcSubfieldStructures->search({ frameworkcode => $framework->{frameworkcode}, tagfield => 200, tagsubfield => 'a' }); + is( $retrieved_fields->count, 1, 'Search for a field by frameworkcode, tagfield and tagsubfield should return the field' ); -$schema->storage->txn_rollback; + $retrieved_fields->next->delete; + is( Koha::MarcSubfieldStructures->search->count, $nb_of_fields + 1, 'Delete should have deleted the field' ); +}; +$schema->storage->txn_rollback; -- 2.1.4