From 0d24b616cdb7336b978e6ecd0c1f845c1804f85f Mon Sep 17 00:00:00 2001
From: Michael Hamann <michael@content-space.de>
Date: Wed, 25 Jul 2012 18:26:35 +0200
Subject: [PATCH] Disable some parser and renderer caches during tests FS#2564

This disables some caches which use static variables in order to prevent
parsing or rendering of the same page more than once during a run and
also disables the cache of parser modes. This means we can no longer
test this behavior but at least it fixes syntax plugin tests and tests
which change pages in order to test certain caching behaviors.
---
 inc/parserutils.php | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/inc/parserutils.php b/inc/parserutils.php
index 55b451c76..bbe0db1c0 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -212,7 +212,7 @@ function p_cached_instructions($file,$cacheonly=false,$id='') {
 
     $cache = new cache_instructions($id, $file);
 
-    if ($cacheonly || $cache->useCache() || isset($run[$file])) {
+    if ($cacheonly || $cache->useCache() || (isset($run[$file]) && !defined('DOKU_UNITTEST'))) {
         return $cache->retrieveCache();
     } else if (@file_exists($file)) {
         // no cache - do some work
@@ -311,8 +311,10 @@ function p_get_metadata($id, $key='', $render=METADATA_RENDER_USING_CACHE){
             }
         }
         if ($do_render) {
-            ++$render_count;
-            $rendered_pages[$id] = true;
+            if (!defined('DOKU_UNITTEST')) {
+                ++$render_count;
+                $rendered_pages[$id] = true;
+            }
             $old_meta = $meta;
             $meta = p_render_metadata($id, $meta);
             // only update the file when the metadata has been changed
@@ -547,7 +549,7 @@ function p_get_parsermodes(){
 
     //reuse old data
     static $modes = null;
-    if($modes != null){
+    if($modes != null && !defined('DOKU_UNITTEST')){
         return $modes;
     }
 
-- 
GitLab