Bug 30920: (follow-up) Manually flush caches in tests
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 10 Mar 2023 16:34:26 +0000 (16:34 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 13 Mar 2023 18:11:54 +0000 (15:11 -0300)
We can't rely on our cache flushing in either 'store' or 'delete'
triggers as t/lib/TestBuilder::build_object skips the Koha::Object store
and uses direct DB inserts in preference.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
t/db_dependent/Koha/Item.t

index f42f8b0..bd56d19 100755 (executable)
@@ -1358,6 +1358,10 @@ subtest 'columns_to_str' => sub {
     $cache->clear_from_cache("MarcStructure-0-");
     $cache->clear_from_cache("MarcStructure-1-");
     $cache->clear_from_cache("MarcSubfieldStructure-");
+    $cache->clear_from_cache("libraries:name");
+    $cache->clear_from_cache("itemtype:description:en");
+    $cache->clear_from_cache("cn_sources:description");
+    $cache->clear_from_cache("AV_descriptions:LOST");
 
     # Creating subfields 'é', 'è' that are not linked with a kohafield
     Koha::MarcSubfieldStructures->search(
@@ -1436,9 +1440,12 @@ subtest 'columns_to_str' => sub {
     $cache->clear_from_cache("MarcStructure-0-");
     $cache->clear_from_cache("MarcStructure-1-");
     $cache->clear_from_cache("MarcSubfieldStructure-");
+    $cache->clear_from_cache("libraries:name");
+    $cache->clear_from_cache("itemtype:description:en");
+    $cache->clear_from_cache("cn_sources:description");
+    $cache->clear_from_cache("AV_descriptions:LOST");
 
     $schema->storage->txn_rollback;
-
 };
 
 subtest 'strings_map() tests' => sub {
@@ -1453,6 +1460,9 @@ subtest 'strings_map() tests' => sub {
     $cache->clear_from_cache("MarcStructure-0-");
     $cache->clear_from_cache("MarcStructure-1-");
     $cache->clear_from_cache("MarcSubfieldStructure-");
+    $cache->clear_from_cache("libraries:name");
+    $cache->clear_from_cache("itemtype:description:en");
+    $cache->clear_from_cache("cn_sources:description");
 
     # Recreating subfields just to be sure tests will be ok
     # 1 => av (LOST)
@@ -1561,7 +1571,7 @@ subtest 'strings_map() tests' => sub {
                 class_split_rule => $class_split_rule->class_split_rule,
             }
         }
-    );
+    )->store();
 
     $item->set(
         {
@@ -1633,6 +1643,9 @@ subtest 'strings_map() tests' => sub {
     $cache->clear_from_cache("MarcStructure-0-");
     $cache->clear_from_cache("MarcStructure-1-");
     $cache->clear_from_cache("MarcSubfieldStructure-");
+    $cache->clear_from_cache("libraries:name");
+    $cache->clear_from_cache("itemtype:description:en");
+    $cache->clear_from_cache("cn_sources:description");
 
     $schema->storage->txn_rollback;
 };