);
}
+ /**
+ * Tests whether fields can be add to all TCA types and duplicate fields are considered.
+ * @test
+ * @see t3lib_extMgm::addToAllTCAtypes()
+ */
+ public function canAddFieldsToAllTCATypesBeforeExistingOnes() {
+ $table = uniqid('tx_coretest_table');
+ $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+
+ t3lib_extMgm::addToAllTCAtypes($table, 'newA, newB, fieldA', '', 'before:fieldD');
+
+ // Checking typeA:
+ $this->assertEquals(
+ 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, newA, newB, fieldD',
+ $GLOBALS['TCA'][$table]['types']['typeA']['showitem']
+ );
+ // Checking typeB:
+ $this->assertEquals(
+ 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, newA, newB, fieldD',
+ $GLOBALS['TCA'][$table]['types']['typeB']['showitem']
+ );
+ }
+
+ /**
+ * Tests whether fields can be add to all TCA types and duplicate fields are considered.
+ * @test
+ * @see t3lib_extMgm::addToAllTCAtypes()
+ */
+ public function canAddFieldsToAllTCATypesAfterExistingOnes() {
+ $table = uniqid('tx_coretest_table');
+ $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+
+ t3lib_extMgm::addToAllTCAtypes($table, 'newA, newB, fieldA', '', 'after:fieldC');
+
+ // Checking typeA:
+ $this->assertEquals(
+ 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, newA, newB, fieldD',
+ $GLOBALS['TCA'][$table]['types']['typeA']['showitem']
+ );
+ // Checking typeB:
+ $this->assertEquals(
+ 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, newA, newB, fieldD',
+ $GLOBALS['TCA'][$table]['types']['typeB']['showitem']
+ );
+ }
+
+ /**
+ * Tests whether fields can be add to a TCA type before existing ones
+ * @test
+ * @see t3lib_extMgm::addToAllTCAtypes()
+ */
+ public function canAddFieldsToTCATypeBeforeExistingOnes() {
+ $table = uniqid('tx_coretest_table');
+ $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+
+ t3lib_extMgm::addToAllTCAtypes($table, 'newA, newB, fieldA', 'typeA', 'before:fieldD');
+
+ // Checking typeA:
+ $this->assertEquals(
+ 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, newA, newB, fieldD',
+ $GLOBALS['TCA'][$table]['types']['typeA']['showitem']
+ );
+ // Checking typeB:
+ $this->assertEquals(
+ 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, fieldD',
+ $GLOBALS['TCA'][$table]['types']['typeB']['showitem']
+ );
+ }
+
+ /**
+ * Tests whether fields can be add to a TCA type after existing ones
+ * @test
+ * @see t3lib_extMgm::addToAllTCAtypes()
+ */
+ public function canAddFieldsToTCATypeAfterExistingOnes() {
+ $table = uniqid('tx_coretest_table');
+ $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+
+ t3lib_extMgm::addToAllTCAtypes($table, 'newA, newB, fieldA', 'typeA', 'after:fieldC');
+
+ // Checking typeA:
+ $this->assertEquals(
+ 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, newA, newB, fieldD',
+ $GLOBALS['TCA'][$table]['types']['typeA']['showitem']
+ );
+ // Checking typeB:
+ $this->assertEquals(
+ 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, fieldD',
+ $GLOBALS['TCA'][$table]['types']['typeB']['showitem']
+ );
+ }
+
+ /**
+ * Tests whether fields can be added to a palette before existing elements.
+ * @test
+ * @see t3lib_extMgm::addFieldsToPalette()
+ */
+ public function canAddFieldsToPaletteBeforeExistingOnes() {
+ $table = uniqid('tx_coretest_table');
+ $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+
+ t3lib_extMgm::addFieldsToPalette($table, 'paletteA', 'newA, newB, fieldX', 'before:fieldY');
+
+ $this->assertEquals(
+ 'fieldX, newA, newB, fieldY',
+ $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']
+ );
+ }
+
+ /**
+ * Tests whether fields can be added to a palette after existing elements.
+ * @test
+ * @see t3lib_extMgm::addFieldsToPalette()
+ */
+ public function canAddFieldsToPaletteAfterExistingOnes() {
+ $table = uniqid('tx_coretest_table');
+ $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+
+ t3lib_extMgm::addFieldsToPalette($table, 'paletteA', 'newA, newB, fieldX', 'after:fieldX');
+
+ $this->assertEquals(
+ 'fieldX, newA, newB, fieldY',
+ $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']
+ );
+ }
+
public function tearDown() {
foreach ($this->globals as $key => $value) {
$GLOBALS[$key] = unserialize($value);
}
}
+
+ /**
+ * Generates a basic TCA for a given table.
+ *
+ * @param string $table: Name of the table
+ * @return array Generated TCA for the given table
+ */
+ private function generateTCAForTable($table) {
+ $tca = array();
+ $tca[$table] = 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'),
+ );
+ $tca[$table]['palettes'] = array(
+ 'paletteA' => array('showitem' => 'fieldX, fieldY'),
+ 'paletteB' => array('showitem' => 'fieldX, fieldY'),
+ );
+
+ return $tca;
+ }
}
?>
\ No newline at end of file