Follow-up to feature #9897: Extended unit tests for adding fields in t3lib_extMgm
authorOliver Hader <oliver.hader@typo3.org>
Mon, 31 Aug 2009 16:14:34 +0000 (16:14 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 31 Aug 2009 16:14:34 +0000 (16:14 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5858 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/t3lib/t3lib_extmgm_testcase.php

index 57e5e9a..6334f82 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
 
        * Cleanup: Set SVN properties and tags
        * Follow-up to feature #9897: Added unit tests for addFieldsToPalette() and addToAllTCAtypes() in t3lib_extMgm
+       * Follow-up to feature #9897: Extended unit tests for adding fields in t3lib_extMgm
 
 2009-08-31  Ingo Renner  <ingo@typo3.org>
 
index be4dca7..d5109bf 100644 (file)
@@ -74,7 +74,7 @@ class t3lib_extmgm_testcase extends tx_phpunit_testcase {
                $table = uniqid('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
 
-               t3lib_extMgm::addToAllTCAtypes($table, 'newA, newB, fieldA', '', 'before:fieldD');
+               t3lib_extMgm::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', '', 'before:fieldD');
 
                        // Checking typeA:
                $this->assertEquals(
@@ -97,7 +97,7 @@ class t3lib_extmgm_testcase extends tx_phpunit_testcase {
                $table = uniqid('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
 
-               t3lib_extMgm::addToAllTCAtypes($table, 'newA, newB, fieldA', '', 'after:fieldC');
+               t3lib_extMgm::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', '', 'after:fieldC');
 
                        // Checking typeA:
                $this->assertEquals(
@@ -120,7 +120,7 @@ class t3lib_extmgm_testcase extends tx_phpunit_testcase {
                $table = uniqid('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
 
-               t3lib_extMgm::addToAllTCAtypes($table, 'newA, newB, fieldA', 'typeA', 'before:fieldD');
+               t3lib_extMgm::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', 'typeA', 'before:fieldD');
 
                        // Checking typeA:
                $this->assertEquals(
@@ -143,7 +143,7 @@ class t3lib_extmgm_testcase extends tx_phpunit_testcase {
                $table = uniqid('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
 
-               t3lib_extMgm::addToAllTCAtypes($table, 'newA, newB, fieldA', 'typeA', 'after:fieldC');
+               t3lib_extMgm::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', 'typeA', 'after:fieldC');
 
                        // Checking typeA:
                $this->assertEquals(
@@ -166,7 +166,7 @@ class t3lib_extmgm_testcase extends tx_phpunit_testcase {
                $table = uniqid('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
 
-               t3lib_extMgm::addFieldsToPalette($table, 'paletteA', 'newA, newB, fieldX', 'before:fieldY');
+               t3lib_extMgm::addFieldsToPalette($table, 'paletteA', 'newA, newA, newB, fieldX', 'before:fieldY');
 
                $this->assertEquals(
                        'fieldX, newA, newB, fieldY',
@@ -183,7 +183,7 @@ class t3lib_extmgm_testcase extends tx_phpunit_testcase {
                $table = uniqid('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
 
-               t3lib_extMgm::addFieldsToPalette($table, 'paletteA', 'newA, newB, fieldX', 'after:fieldX');
+               t3lib_extMgm::addFieldsToPalette($table, 'paletteA', 'newA, newA, newB, fieldX', 'after:fieldX');
 
                $this->assertEquals(
                        'fieldX, newA, newB, fieldY',
@@ -191,6 +191,56 @@ class t3lib_extmgm_testcase extends tx_phpunit_testcase {
                );
        }
 
+       /**
+        * Tests whether fields can be added to all palettes of a regular field before existing ones.
+        * @test
+        * @see t3lib_extMgm::addFieldsToAllPalettesOfField()
+        */
+       public function canAddFieldsToAllPalettesOfFieldBeforeExistingOnes() {
+               $table = uniqid('tx_coretest_table');
+               $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+
+               t3lib_extMgm::addFieldsToAllPalettesOfField($table, 'fieldC', 'newA, newA, newB, fieldX', 'before:fieldY');
+
+               $this->assertEquals(
+                       'fieldX, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']
+               );
+               $this->assertEquals(
+                       'fieldX, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteB']['showitem']
+               );
+               $this->assertEquals(
+                       'fieldX, newA, newB, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteC']['showitem']
+               );
+               $this->assertEquals(
+                       'fieldX, newA, newB, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteD']['showitem']
+               );
+       }
+
+       /**
+        * Tests whether fields can be added to all palettes of a regular field before existing ones.
+        * @test
+        * @see t3lib_extMgm::addFieldsToAllPalettesOfField()
+        */
+       public function canAddFieldsToAllPalettesOfFieldAfterExistingOnes() {
+               $table = uniqid('tx_coretest_table');
+               $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+
+               t3lib_extMgm::addFieldsToAllPalettesOfField($table, 'fieldC', 'newA, newB, fieldX', 'after:fieldX');
+
+               $this->assertEquals(
+                       'fieldX, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']
+               );
+               $this->assertEquals(
+                       'fieldX, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteB']['showitem']
+               );
+               $this->assertEquals(
+                       'fieldX, newA, newB, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteC']['showitem']
+               );
+               $this->assertEquals(
+                       'fieldX, newA, newB, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteD']['showitem']
+               );
+       }
+
        public function tearDown() {
                foreach ($this->globals as $key => $value) {
                        $GLOBALS[$key] = unserialize($value);
@@ -206,13 +256,17 @@ class t3lib_extmgm_testcase extends tx_phpunit_testcase {
        private function generateTCAForTable($table) {
                $tca = array();
                $tca[$table] = array();
+               $tca[$table]['columns']['fieldC'] = array();
                $tca[$table]['types'] = array(
                        'typeA' => array('showitem' => 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, fieldD'),
                        'typeB' => array('showitem' => 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, fieldD'),
+                       'typeC' => array('showitem' => 'fieldC;;paletteD'),
                );
                $tca[$table]['palettes'] = array(
                        'paletteA' => array('showitem' => 'fieldX, fieldY'),
                        'paletteB' => array('showitem' => 'fieldX, fieldY'),
+                       'paletteC' => array('showitem' => 'fieldX, fieldY'),
+                       'paletteD' => array('showitem' => 'fieldX, fieldY'),
                );
 
                return $tca;