[BUGFIX] Incomplete locale backup in unit test
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 26 Jan 2013 20:32:46 +0000 (21:32 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 26 Jan 2013 21:00:14 +0000 (22:00 +0100)
A test from issue #43445 sets some locale categories
but does not properly reset to settings before. This
can kill unit tests running afterwards.

Change-Id: I068f0b85a5a677c5c3ae9a79b845f45d1ee9b590
Fixes: #44835
Related: #43445
Releases: 6.1, 6.0, 4.7, 4.6, 4.5
Reviewed-on: https://review.typo3.org/17735
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SelectViewHelperTest.php

index cf2c764..4aa5027 100644 (file)
@@ -24,15 +24,29 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         */
        protected $viewHelper;
 
+       /**
+        * @var array Backup of current locale, it is manipulated in tests
+        */
+       protected $backupLocales = array();
+
        public function setUp() {
                parent::setUp();
+               // Store all locale categories manipulated in tests for reconstruction in tearDown
+               $this->backupLocales = array(
+                       'LC_COLLATE' => setlocale(LC_COLLATE, 0),
+                       'LC_CTYPE' => setlocale(LC_CTYPE, 0),
+                       'LC_MONETARY' => setlocale(LC_MONETARY, 0),
+                       'LC_TIME' => setlocale(LC_MONETARY, 0),
+               );
                $this->arguments['name'] = '';
                $this->arguments['sortByOptionLabel'] = FALSE;
                $this->viewHelper = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Form\\SelectViewHelper', array('setErrorClassAttribute', 'registerFieldNameForFormTokenGeneration'));
        }
 
        public function tearDown() {
-               setlocale(LC_ALL, '');
+               foreach ($this->backupLocales as $category => $locale) {
+                       setlocale($category, $locale);
+               }
        }
 
        /**