[TASK] Add basic unit test for IRRE form rendering
authorOliver Hader <oliver@typo3.org>
Mon, 5 Nov 2012 15:53:44 +0000 (16:53 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 5 Nov 2012 15:55:54 +0000 (16:55 +0100)
The basic information in IRRE are the repeatable triples of
table-uid-field. This test ensures to have a working separation
of stable and unstable segments available.

Change-Id: Ie0a0e87faf4c4e7a41fb6aed01af6610f12b1c7f
Resolves: #42702
Releases: 6.0
Reviewed-on: http://review.typo3.org/16209
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/backend/Tests/Unit/Form/Element/InlineElementTest.php [new file with mode: 0644]

diff --git a/typo3/sysext/backend/Tests/Unit/Form/Element/InlineElementTest.php b/typo3/sysext/backend/Tests/Unit/Form/Element/InlineElementTest.php
new file mode 100644 (file)
index 0000000..3e22e27
--- /dev/null
@@ -0,0 +1,209 @@
+<?php
+namespace TYPO3\CMS\Backend\Tests\Unit\Form\Element;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Oliver Hader <oliver.hader@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Tests for Inline Relational Record Editing form rendering.
+ *
+ * @author Oliver Hader <oliver.hader@typo3.org>
+ */
+class InlineElementTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+       /**
+        * @var \TYPO3\CMS\Backend\Form\Element\InlineElement
+        */
+       protected $fixture;
+
+       /**
+        * Sets up this test case.
+        */
+       protected function setUp() {
+               // @todo Use $this->buildAccessibleProxy() if properties are protected
+               $this->fixture = new \TYPO3\CMS\Backend\Form\Element\InlineElement();
+       }
+
+       /**
+        * Tears down this test case.
+        */
+       protected function tearDown() {
+               unset($this->fixture);
+       }
+
+       /**
+        * @param string $string
+        * @param array $expectedInlineStructure
+        * @dataProvider structureStringIsParsedDataProvider
+        * @test
+        */
+       public function structureStringIsParsed($string, array $expectedInlineStructure) {
+               $this->fixture->parseStructureString($string, FALSE);
+
+               $this->assertEquals('pageId', $this->fixture->inlineFirstPid);
+               $this->assertEquals($expectedInlineStructure, $this->fixture->inlineStructure);
+       }
+
+       public function structureStringIsParsedDataProvider() {
+               return array(
+                       'simple 1-level table structure' => array(
+                               'data-pageId-childTable',
+                               array(
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                       ),
+                               ),
+                       ),
+                       'simple 1-level table-uid structure' => array(
+                               'data-pageId-childTable-childUid',
+                               array(
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                               'uid' => 'childUid',
+                                       ),
+                               ),
+                       ),
+                       'simple 1-level table-uid-field structure' => array(
+                               'data-pageId-childTable-childUid-childField',
+                               array(
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                               'uid' => 'childUid',
+                                               'field' => 'childField',
+                                       ),
+                               ),
+                       ),
+                       'simple 2-level table structure' => array(
+                               'data-pageId-parentTable-parentUid-parentField-childTable',
+                               array(
+                                       'stable' => array(
+                                               array(
+                                                       'table' => 'parentTable',
+                                                       'uid' => 'parentUid',
+                                                       'field' => 'parentField',
+                                               ),
+                                       ),
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                       ),
+                               ),
+                       ),
+                       'simple 2-level table-uid structure' => array(
+                               'data-pageId-parentTable-parentUid-parentField-childTable-childUid',
+                               array(
+                                       'stable' => array(
+                                               array(
+                                                       'table' => 'parentTable',
+                                                       'uid' => 'parentUid',
+                                                       'field' => 'parentField',
+                                               ),
+                                       ),
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                               'uid' => 'childUid',
+                                       ),
+                               ),
+                       ),
+                       'simple 2-level table-uid-field structure' => array(
+                               'data-pageId-parentTable-parentUid-parentField-childTable-childUid-childField',
+                               array(
+                                       'stable' => array(
+                                               array(
+                                                       'table' => 'parentTable',
+                                                       'uid' => 'parentUid',
+                                                       'field' => 'parentField',
+                                               ),
+                                       ),
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                               'uid' => 'childUid',
+                                               'field' => 'childField',
+                                       ),
+                               ),
+                       ),
+                       'simple 3-level table structure' => array(
+                               'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable',
+                               array(
+                                       'stable' => array(
+                                               array(
+                                                       'table' => 'grandParentTable',
+                                                       'uid' => 'grandParentUid',
+                                                       'field' => 'grandParentField',
+                                               ),
+                                               array(
+                                                       'table' => 'parentTable',
+                                                       'uid' => 'parentUid',
+                                                       'field' => 'parentField',
+                                               ),
+                                       ),
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                       ),
+                               ),
+                       ),
+                       'simple 3-level table-uid structure' => array(
+                               'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid',
+                               array(
+                                       'stable' => array(
+                                               array(
+                                                       'table' => 'grandParentTable',
+                                                       'uid' => 'grandParentUid',
+                                                       'field' => 'grandParentField',
+                                               ),
+                                               array(
+                                                       'table' => 'parentTable',
+                                                       'uid' => 'parentUid',
+                                                       'field' => 'parentField',
+                                               ),
+                                       ),
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                               'uid' => 'childUid',
+                                       ),
+                               ),
+                       ),
+                       'simple 3-level table-uid-field structure' => array(
+                               'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField-childTable-childUid-childField',
+                               array(
+                                       'stable' => array(
+                                               array(
+                                                       'table' => 'grandParentTable',
+                                                       'uid' => 'grandParentUid',
+                                                       'field' => 'grandParentField',
+                                               ),
+                                               array(
+                                                       'table' => 'parentTable',
+                                                       'uid' => 'parentUid',
+                                                       'field' => 'parentField',
+                                               ),
+                                       ),
+                                       'unstable' => array(
+                                               'table' => 'childTable',
+                                               'uid' => 'childUid',
+                                               'field' => 'childField',
+                                       ),
+                               ),
+                       ),
+               );
+       }
+}
+?>
\ No newline at end of file