[TASK] Allow TCA display conditions with only one element for AND/OR 10/60310/4
authorMarkus Klein <markus.klein@typo3.org>
Fri, 22 Mar 2019 14:57:00 +0000 (15:57 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Sat, 23 Mar 2019 19:59:56 +0000 (20:59 +0100)
Resolves: #87986
Releases: master, 9.5
Change-Id: I9ccdbcae0c06a00fcd2904a203d1f3072b6e28ea
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60310
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Josef Glatz <josefglatz@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Stephan GroƟberndt <stephan.grossberndt@typo3.org>
Reviewed-by: Josef Glatz <josefglatz@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/Form/FormDataProvider/EvaluateDisplayConditions.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/EvaluateDisplayConditionsTest.php

index 321301b..c15cf78 100644 (file)
@@ -209,12 +209,6 @@ class EvaluateDisplayConditions implements FormDataProviderInterface
                         1481380393
                     );
                 }
-                if (count($groupedDisplayConditions) < 2) {
-                    throw new \RuntimeException(
-                        'With multiple conditions combined by "' . $logicalOperator . '", there must be at least two sub conditions',
-                        1481464101
-                    );
-                }
                 $conditionArray = [
                     'type' => $logicalOperator,
                     'subConditions' => [],
index f55d8db..84015ed 100644 (file)
@@ -76,30 +76,6 @@ class EvaluateDisplayConditionsTest extends UnitTestCase
     /**
      * @test
      */
-    public function addDataThrowsExceptionWithMultipleConditionsCombinedWithAndHavingOnlyOneSubCondition()
-    {
-        $input = [
-            'databaseRow' => [],
-            'processedTca' => [
-                'columns' => [
-                    'field_1' => [
-                        'displayCond' => [
-                            'AND' => [
-                                'condition1',
-                            ],
-                        ],
-                    ],
-                ],
-            ],
-        ];
-        $this->expectException(\RuntimeException::class);
-        $this->expectExceptionCode(1481464101);
-        (new EvaluateDisplayConditions())->addData($input);
-    }
-
-    /**
-     * @test
-     */
     public function addDataThrowsExceptionIfConditionIsNotStringOrArray()
     {
         $input = [
@@ -3807,6 +3783,17 @@ class EvaluateDisplayConditionsTest extends UnitTestCase
                 ],
                 false,
             ],
+            'Single condition with AND compares to TRUE if the one is OK' => [
+                [
+                    'AND' => [
+                        'FIELD:testField:>:9',
+                    ],
+                ],
+                [
+                    'testField' => 10,
+                ],
+                true,
+            ],
             'Multiple conditions with AND compare to TRUE if all are OK' => [
                 [
                     'AND' => [
@@ -3831,6 +3818,17 @@ class EvaluateDisplayConditionsTest extends UnitTestCase
                 ],
                 false,
             ],
+            'Single condition with OR compares to TRUE if the one is OK' => [
+                [
+                    'OR' => [
+                        'FIELD:testField:>:9',
+                    ],
+                ],
+                [
+                    'testField' => 10,
+                ],
+                true,
+            ],
             'Multiple conditions with OR compare to TRUE if one is OK' => [
                 [
                     'OR' => [