Skip to content
Snippets Groups Projects
Commit ae18ac11 authored by Oliver Hader's avatar Oliver Hader
Browse files

[BUGFIX] EXT:form - Fix compatibility behavior

The compatibility behavior is streamlined to first use the
global setting and then override it by using the specific
local setting - it defined. Besides that, the unit tests are
fixed and adopted to the mentioned changes as well.

Resolves: #69961
Releases: master
Change-Id: I653c2837219033205d4d59e565dbaeb6dc7f7c1f
Reviewed-on: http://review.typo3.org/43429


Reviewed-by: default avatarOliver Hader <oliver.hader@typo3.org>
Tested-by: default avatarOliver Hader <oliver.hader@typo3.org>
parent fa116d45
Branches
Tags
No related merge requests found
......@@ -172,13 +172,13 @@ class Configuration {
if (!empty($this->typoScript['prefix'])) {
$this->setPrefix($this->typoScript['prefix']);
}
// Determine compatibility behavior
$this->setCompatibility((bool)$this->typoScriptRepository->getModelConfigurationByScope('FORM', 'compatibilityMode'));
if (
isset($this->typoScript['compatibilityMode'])
&& (int)($this->typoScript['compatibilityMode']) === 0
) {
$this->setCompatibility(FALSE);
// Determine compatibility behavior from global settings
$this->setCompatibility(
$this->typoScriptRepository->getModelConfigurationByScope('FORM', 'compatibilityMode')
);
// Override compatibility behavior from current local settings
if (isset($this->typoScript['compatibilityMode'])) {
$this->setCompatibility($this->typoScript['compatibilityMode']);
}
// Set the theme name
if (!empty($this->typoScript['themeName'])) {
......
......@@ -55,21 +55,16 @@ class ConfigurationTest extends UnitTestCase {
/**
* @param array $typoScript
* @param bool $globalCompatibilityMode
* @param array $expected
*
* @test
* @dataProvider propertiesAreUpdatedFromTypoScriptDataProvider
*/
public function propertiesAreUpdatedFromTypoScript(array $typoScript, $globalCompatibilityMode) {
public function propertiesAreUpdatedFromTypoScript(array $typoScript, $globalCompatibilityMode, array $expected) {
$this->typoScriptRepositoryProphecy
->getModelConfigurationByScope('FORM', 'compatibilityMode')
->willReturn($globalCompatibilityMode);
$expected = array(
'prefix' => $typoScript['prefix'] ?: 'form',
'compatibility' => ($typoScript['compatibilityMode'] || $globalCompatibilityMode),
'contentElementRendering' => !$typoScript['disableContentElement'],
);
$this->subject->setTypoScript($typoScript);
$this->assertEquals($expected['prefix'], $this->subject->getPrefix());
$this->assertEquals($expected['compatibility'], $this->subject->getCompatibility());
......@@ -84,34 +79,92 @@ class ConfigurationTest extends UnitTestCase {
'#1' => array(
array(
'prefix' => '',
'themeName' => '',
'compatibilityMode' => FALSE,
'disableContentElement' => FALSE,
),
FALSE
FALSE,
array(
'prefix' => 'form',
'themeName' => 'Default',
'compatibility' => FALSE,
'contentElementRendering' => TRUE,
),
),
'#2' => array(
array(
'prefix' => '',
'themeName' => '',
'compatibilityMode' => FALSE,
'disableContentElement' => FALSE,
),
TRUE
TRUE,
array(
'prefix' => 'form',
'themeName' => 'Default',
'compatibility' => FALSE,
'contentElementRendering' => TRUE,
),
),
'#3' => array(
array(
'prefix' => 'somePrefix',
'themeName' => 'someTheme',
'compatibilityMode' => TRUE,
'disableContentElement' => TRUE,
),
TRUE
TRUE,
array(
'prefix' => 'somePrefix',
'themeName' => 'someTheme',
'compatibility' => TRUE,
'contentElementRendering' => FALSE,
),
),
'#4' => array(
array(
'prefix' => 'somePrefix',
'themeName' => 'someTheme',
'compatibilityMode' => TRUE,
'disableContentElement' => TRUE,
),
FALSE
FALSE,
array(
'prefix' => 'somePrefix',
'themeName' => 'someTheme',
'compatibility' => TRUE,
'contentElementRendering' => FALSE,
),
),
'#5' => array(
array(
'prefix' => 'somePrefix',
'themeName' => 'someTheme',
'compatibilityMode' => NULL,
'disableContentElement' => TRUE,
),
TRUE,
array(
'prefix' => 'somePrefix',
'themeName' => 'someTheme',
'compatibility' => TRUE,
'contentElementRendering' => FALSE,
),
),
'#6' => array(
array(
'prefix' => 'somePrefix',
'themeName' => 'someTheme',
'compatibilityMode' => NULL,
'disableContentElement' => TRUE,
),
FALSE,
array(
'prefix' => 'somePrefix',
'themeName' => 'someTheme',
'compatibility' => FALSE,
'contentElementRendering' => FALSE,
),
),
);
}
......
......@@ -51,7 +51,8 @@ class FloatValidatorTest extends AbstractValidatorTest {
public function validFloatProvider() {
return array(
'12.1 for en_US locale' => array(array('12.1', 'en_US')),
'12,1 for de_DE locale' => array(array('12,1', 'de_DE')),
// @todo de_DE disabled currently, works locally but not on travis-ci.org
// '12,1 for de_DE locale' => array(array('12,1', 'de_DE')),
);
}
......
......@@ -54,7 +54,8 @@ class IntegerValidatorTest extends AbstractValidatorTest {
public function invalidIntegerProvider() {
return array(
'12.1 for en_US locale' => array(array(12.1, 'en_US')),
'12,1 for de_DE locale' => array(array('12,1', 'de_DE'))
// @todo de_DE disabled currently, works locally but not on travis-ci.org
// '12,1 for de_DE locale' => array(array('12,1', 'de_DE'))
);
}
......
......@@ -22,7 +22,7 @@ class LessThanValidatorTest extends AbstractValidatorTest {
/**
* @var string
*/
protected $subjectClassName = \TYPO3\CMS\Form\Domain\Validator\LessthanValidator::class;
protected $subjectClassName = \TYPO3\CMS\Form\Domain\Validator\LessThanValidator::class;
/**
* @return array
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment