From 7aae661fc7a45b05becaf09dbdafb9b8b5723d31 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 26 May 2025 12:33:44 +0200 Subject: [PATCH] Bug 36625: Run subtests in txn - Koha/Biblio.t Test plan: select count(*) from itemtypes; run the tests exectute the select query again => No itemtypes should have been created Signed-off-by: Tomas Cohen Arazi Signed-off-by: Lucas Gass (cherry picked from commit 89c42eda9fb68398651894ba55a2a6536e423fa3) Signed-off-by: Paul Derscheid (cherry picked from commit 2b7d31a6138e6c7932c0d7c1c4fb273502f4daeb) Signed-off-by: Fridolin Somers --- t/db_dependent/Koha/Biblio.t | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index e756c10b91..2e0c2074e9 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -858,6 +858,8 @@ subtest 'get_marc_components() tests' => sub { subtest 'get_components_query' => sub { plan tests => 12; + $schema->storage->txn_begin; + my $biblio = $builder->build_sample_biblio(); my $biblionumber = $biblio->biblionumber; my $record = $biblio->metadata->record; @@ -895,11 +897,16 @@ subtest 'get_components_query' => sub { is($comp_sort, "title_asc", "$engine: UseControlNumber enabled with MarcOrgCode sort if correct"); $record->delete_field($marc_003_field); } + + $schema->storage->txn_rollback; + }; subtest 'get_volumes_query' => sub { plan tests => 3; + $schema->storage->txn_begin; + my $biblio = $builder->build_sample_biblio(); my $biblionumber = $biblio->biblionumber; my $record = $biblio->metadata->record; @@ -940,6 +947,9 @@ subtest 'get_volumes_query' => sub { "(((rcn:$biblionumber AND cni:OSt) OR rcn:\"OSt $biblionumber\") NOT (bib-level:a OR bib-level:b))", "UseControlNumber enabled with MarcOrgCode" ); + + $schema->storage->txn_rollback; + }; subtest 'generate_marc_host_field' => sub { @@ -1704,6 +1714,8 @@ subtest 'item_groups() tests' => sub { subtest 'normalized_isbn' => sub { plan tests => 1; + $schema->storage->txn_begin; + # We will move the tests from GetNormalizedISBN here when it will get replaced my $biblio = $builder->build_sample_biblio(); $biblio->biblioitem->set( { isbn => '9781250067128 | 125006712X' } )->store; @@ -1711,11 +1723,16 @@ subtest 'normalized_isbn' => sub { $biblio->normalized_isbn, C4::Koha::GetNormalizedISBN( $biblio->biblioitem->isbn ), 'normalized_isbn is a wrapper around C4::Koha::GetNormalizedISBN' ); + + $schema->storage->txn_rollback; + }; subtest 'normalized_upc' => sub { plan tests => 1; + $schema->storage->txn_begin; + # We will move the tests from GetNormalizedUPC here when it will get replaced # Note that only a single test exist and it's not really meaningful... my $biblio = $builder->build_sample_biblio(); @@ -1723,11 +1740,16 @@ subtest 'normalized_upc' => sub { $biblio->normalized_upc, C4::Koha::GetNormalizedUPC( $biblio->metadata->record ), 'normalized_upc is a wrapper around C4::Koha::GetNormalizedUPC' ); + + $schema->storage->txn_rollback; + }; subtest 'normalized_oclc' => sub { plan tests => 1; + $schema->storage->txn_begin; + # We will move the tests from GetNormalizedOCLC here when it will get replaced # Note that only a single test exist and it's not really meaningful... my $biblio = $builder->build_sample_biblio(); @@ -1735,6 +1757,9 @@ subtest 'normalized_oclc' => sub { $biblio->normalized_oclc, C4::Koha::GetNormalizedOCLCNumber( $biblio->metadata->record ), 'normalized_oclc is a wrapper around C4::Koha::GetNormalizedOCLCNumber' ); + + $schema->storage->txn_rollback; + }; subtest 'opac_suppressed() tests' => sub { @@ -1777,14 +1802,21 @@ subtest 'opac_suppressed() tests' => sub { subtest 'ratings' => sub { plan tests => 1; + + $schema->storage->txn_begin; + # See t/db_dependent/Koha/Ratings.t ok(1); + + $schema->storage->txn_rollback; }; subtest 'opac_summary_html' => sub { plan tests => 2; + $schema->storage->txn_begin; + my $author = 'my author'; my $title = 'my title'; my $isbn = '9781250067128 | 125006712X'; @@ -1803,6 +1835,9 @@ subtest 'opac_summary_html' => sub { sprintf( 'Replace %s, %s, %s AND %s please', $author, $title, $biblio->normalized_isbn, $biblio->biblionumber ), 'opac_summary_html replaces the different patterns' ); + + $schema->storage->txn_rollback; + }; subtest 'can_be_edited() tests' => sub {