[TASK] Add functional test for exclude field mixup in FormEngine 26/20026/9
authorAlexander Stehlik <alexander.stehlik@gmail.com>
Mon, 15 Jun 2015 19:50:15 +0000 (21:50 +0200)
committerBenjamin Mack <benni@typo3.org>
Mon, 29 Jun 2015 21:59:24 +0000 (23:59 +0200)
This patch introduces a functional test that makes sure that the
exclude field mechanism works correctly with inline elements.

Since the problem was already solved by the FormEngine rewrite
no functional changes are made.

The actual bugfix will be added in the TYPO3 6.2 backport.

Resolves: #47359
Releases: master, 6.2
Change-Id: I5a7a2de16d767f854b4d3f89d599deec28266092
Reviewed-on: http://review.typo3.org/20026
Reviewed-by: Jan Helke <typo3@helke.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/Configuration/TCA/tx_inlinetest_inline.php [new file with mode: 0644]
typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/Configuration/TCA/tx_inlinetest_record.php [new file with mode: 0644]
typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/ext_emconf.php [new file with mode: 0644]
typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/ext_tables.sql [new file with mode: 0644]
typo3/sysext/backend/Tests/Functional/Fixtures/inlinetest.xml [new file with mode: 0644]
typo3/sysext/backend/Tests/Functional/Form/FormEngineInlineTest.php [new file with mode: 0644]

diff --git a/typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/Configuration/TCA/tx_inlinetest_inline.php b/typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/Configuration/TCA/tx_inlinetest_inline.php
new file mode 100644 (file)
index 0000000..33179bd
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+return [
+       'ctrl' => [
+               'label' => 'text',
+               'title' => 'Subtype test record - inline',
+       ],
+       'interface' => [
+               'showRecordFieldList' => ''
+       ],
+       'columns' => [
+               'text' => [
+                       'label' => 'Dummy text',
+                       'config' => [
+                               'type' => 'input',
+                       ]
+               ],
+       ],
+       'types' => [
+               '0' => ['showitem' => 'text'],
+       ],
+];
\ No newline at end of file
diff --git a/typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/Configuration/TCA/tx_inlinetest_record.php b/typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/Configuration/TCA/tx_inlinetest_record.php
new file mode 100644 (file)
index 0000000..cbf9f7f
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+return [
+       'ctrl' => [
+               'label' => 'text',
+               'title' => 'Subtype test record',
+               'requestUpdate' => 'subtypeswitch'
+       ],
+       'columns' => [
+               'subtypeswitch' => [
+                       'label' => 'Subtype switch',
+                       'config' => [
+                               'type' => 'select',
+                               'items' => [
+                                       ['All fields visible', 'fieldsvisible'],
+                                       ['Excluded fields', 'fieldsexcluded'],
+                               ],
+                       ],
+               ],
+               'beforeinline' => [
+                       'label' => 'Before inline',
+                       'config' => [
+                               'type' => 'input',
+                       ]
+               ],
+               'children' => [
+                       'label' => 'Children',
+                       'config' => [
+                               'type' => 'inline',
+                               'foreign_table' => 'tx_inlinetest_inline',
+                               'foreign_field' => 'parent_uid',
+                               'appearance' => [
+                                       'collapseAll' => FALSE,
+                               ],
+                       ]
+               ],
+               'afterinline' => [
+                       'label' => 'After inline',
+                       'config' => [
+                               'type' => 'input',
+                       ]
+               ],
+       ],
+       'types' => [
+               0 => [
+                       'showitem' => '--palette--;;testsettings',
+                       'subtype_value_field' => 'subtypeswitch',
+                       'subtypes_excludelist' => [
+                               'fieldsexcluded' => 'beforeinline,afterinline'
+                       ],
+               ],
+       ],
+       'palettes' => [
+               'testsettings' => [
+                       'showitem' => 'subtypeswitch, --linebreak--, beforeinline, --linebreak--, children, --linebreak--, afterinline',
+                       'canNotCollapse' => 1,
+               ],
+       ],
+];
\ No newline at end of file
diff --git a/typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/ext_emconf.php b/typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/ext_emconf.php
new file mode 100644 (file)
index 0000000..b8d5a81
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+$EM_CONF[$_EXTKEY] = [
+       'title' => 'subtypes_exclude_list test',
+       'description' => 'Extension for testing the issue with the TCA setting "subtypes_exclude_list described in #47359',
+       'category' => 'example',
+       'version' => '1.0.0',
+       'state' => 'stable',
+       'uploadfolder' => 0,
+       'createDirs' => '',
+       'clearcacheonload' => 0,
+       'author' => 'Alexander Stehlik',
+       'author_email' => 'alexander.stehlik.deleteme@gmail.com',
+       'author_company' => '',
+       'constraints' => [
+               'depends' => [
+                       'typo3' => '6.2.1-0.0.0',
+               ],
+               'conflicts' => [],
+               'suggests' => [],
+       ],
+];
\ No newline at end of file
diff --git a/typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/ext_tables.sql b/typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest/ext_tables.sql
new file mode 100644 (file)
index 0000000..e46c6af
--- /dev/null
@@ -0,0 +1,28 @@
+
+#
+# Table structure for table 'tx_inlinetest_record'
+#
+CREATE TABLE tx_inlinetest_record (
+       uid int(11) unsigned NOT NULL auto_increment,
+       pid int(11) unsigned DEFAULT '0' NOT NULL,
+       typeswitch varchar(255) DEFAULT '' NOT NULL,
+       subtypeswitch varchar(255) DEFAULT '' NOT NULL,
+       beforeinline varchar(255) DEFAULT '' NOT NULL,
+       children varchar(255) DEFAULT '' NOT NULL,
+       afterinline int(11) unsigned DEFAULT '0' NOT NULL,
+       PRIMARY KEY (uid),
+       KEY parent (pid)
+);
+
+#
+# Table structure for table 'tx_inlinetest_inline'
+#
+CREATE TABLE tx_inlinetest_inline (
+       uid int(11) unsigned NOT NULL auto_increment,
+       pid int(11) unsigned DEFAULT '0' NOT NULL,
+       parent_uid int(11) unsigned DEFAULT '0' NOT NULL,
+       text text,
+       PRIMARY KEY (uid),
+       KEY parent (pid),
+       KEY parent_node (parent_uid)
+);
diff --git a/typo3/sysext/backend/Tests/Functional/Fixtures/inlinetest.xml b/typo3/sysext/backend/Tests/Functional/Fixtures/inlinetest.xml
new file mode 100644 (file)
index 0000000..6dd7815
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<dataset>
+       <tx_inlinetest_record>
+               <uid>1</uid>
+               <pid>1</pid>
+               <subtypeswitch>fieldsexcluded</subtypeswitch>
+               <children>1</children>
+       </tx_inlinetest_record>
+       <tx_inlinetest_inline>
+               <uid>1</uid>
+               <pid>1</pid>
+               <parent_uid>1</parent_uid>
+       </tx_inlinetest_inline>
+</dataset>
\ No newline at end of file
diff --git a/typo3/sysext/backend/Tests/Functional/Form/FormEngineInlineTest.php b/typo3/sysext/backend/Tests/Functional/Form/FormEngineInlineTest.php
new file mode 100644 (file)
index 0000000..e1d1560
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+namespace TYPO3\CMS\Backend\Tests\Functional\Form;
+
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Form\FormEngine;
+use TYPO3\CMS\Core\Tests\FunctionalTestCase;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+
+/**
+ * Test case
+ */
+class FormEngineInlineTest extends FunctionalTestCase {
+
+       protected $testExtensionsToLoad = array(
+               'typo3/sysext/backend/Tests/Functional/Fixtures/Extensions/inlinetest'
+       );
+
+       /**
+        * @var \TYPO3\CMS\Backend\Form\FormEngine|\PHPUnit_Framework_MockObject_MockObject
+        */
+       protected $subject;
+
+       /**
+        * Sets up this test case.
+        */
+       public function setUp() {
+               parent::setUp();
+               $this->setUpBackendUserFromFixture(1);
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Fixtures/inlinetest.xml');
+               $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
+               $GLOBALS['LANG']->init('default');
+               $this->subject = GeneralUtility::makeInstance(FormEngine::class);
+       }
+
+       /**
+        * Make sure that the exclude field configuration is still valid after
+        * the rendering of an inline element.
+        *
+        * @test
+        */
+       public function excludeElementsAreNotOverwrittenByInlineField() {
+               $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'tx_inlinetest_record', 'uid=1');
+               $mainFields = $this->subject->getMainFields('tx_inlinetest_record', $rows[0]);
+               $this->assertNotContains('afterinline', $mainFields);
+       }
+}