From 2dddc2376ec85ed083a30a082d386542bf707c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Na=CC=88gler?= <frank.naegler@typo3.org> Date: Mon, 23 Nov 2015 16:54:58 +0100 Subject: [PATCH] [BUGFIX] Fix broken unit tests for system with e.g. german locale Resolves: #71782 Releases: master Change-Id: I0e1626bc15bbcfded8660b81652cbfa241f5ae04 Reviewed-on: https://review.typo3.org/44911 Reviewed-by: Michael Oehlhof <typo3@oehlhof.de> Tested-by: Michael Oehlhof <typo3@oehlhof.de> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> --- .../ContentObjectRendererTest.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php index fcf1a6f7d529..709ee7008b14 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php @@ -27,6 +27,11 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; */ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { + /** + * @var string + */ + protected $currentLocale; + /** * @var array A backup of registered singleton instances */ @@ -81,6 +86,8 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase */ protected function setUp() { + $this->currentLocale = setlocale(LC_NUMERIC, 0); + $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances(); $this->createMockedLoggerAndLogManager(); @@ -110,6 +117,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase protected function tearDown() { + setlocale(LC_NUMERIC, $this->currentLocale); GeneralUtility::resetSingletonInstances($this->singletonInstances); parent::tearDown(); } @@ -2076,6 +2084,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase ), ), '1.21 Ki', + 'en_US.UTF-8' ), 'value 1234 si' => array( '1234', @@ -2086,6 +2095,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase ), ), '1.23 k', + 'en_US.UTF-8' ), 'value 1234 iec' => array( '1234', @@ -2096,6 +2106,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase ), ), '1.21 Ki', + 'en_US.UTF-8' ), 'value 1234 a-i' => array( '1234', @@ -2106,6 +2117,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase ), ), '1.23b', + 'en_US.UTF-8' ), 'value 1234 a-i invalid base' => array( '1234', @@ -2116,6 +2128,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase ), ), '1.21b', + 'en_US.UTF-8' ), 'value 1234567890 default' => array( '1234567890', @@ -2126,6 +2139,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase ), ), '1.15 Gi', + 'en_US.UTF-8' ), ); } @@ -2137,8 +2151,11 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase * @dataProvider stdWrap_bytesDataProvider * @test */ - public function stdWrap_bytes($content, array $configuration, $expected) + public function stdWrap_bytes($content, array $configuration, $expected, $locale) { + if (!setlocale(LC_NUMERIC, $locale)) { + $this->markTestSkipped('Locale ' . $locale . ' is not available.'); + } $result = $this->subject->stdWrap_bytes($content, $configuration); $this->assertSame($expected, $result); } -- GitLab