[BUGFIX] Sections not properly handled by record collector 92/35692/3
authorBernhard Kraft <kraft@webconsulting.at>
Wed, 31 Dec 2014 14:12:57 +0000 (15:12 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 31 Jan 2015 13:55:07 +0000 (14:55 +0100)
When using the Unit-Test framework frontend record collector the
resulting response is not correct.

Instead of adding records only to the specific section (configured via
TypoScript) the records pile up in $this->records and get added to
every section. The reason this only true for $this->records of the
Collector is, that for the other class variables (like $this->structure)
there are appropriate array keys used anyways.

Solution is to reset the internal member variables used for collecting
record information each time after attaching a section.

Resolves: #64066
Releases: master
Change-Id: I7a1ff945e0d267f1e0c6608637479ea0cc28fe70
Reviewed-on: http://review.typo3.org/35692
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Mateusz WojtuƂa <matw88@gmail.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Tests/Functional/Framework/Frontend/Collector.php

index 2339425..3d5f956 100644 (file)
@@ -132,6 +132,7 @@ class Collector implements \TYPO3\CMS\Core\SingletonInterface {
 
                $as = (!empty($configuration['as']) ? $configuration['as'] : NULL);
                $this->getRenderer()->addSection($section, $as);
+               $this->reset();
        }
 
        /**
@@ -177,4 +178,15 @@ class Collector implements \TYPO3\CMS\Core\SingletonInterface {
                return $GLOBALS['TSFE'];
        }
 
+       /**
+        * Collector needs to be reset after attaching a section, otherwise records will pile up.
+        *
+        * @return void
+        */
+       protected function reset() {
+               $this->structure = array();
+               $this->structurePaths = array();
+               $this->records = array();
+       }
+
 }