/**
  * @test
  */
 public function addFieldsToAllPalettesOfFieldAddsNewPaletteIfFieldHasNoPaletteYetAndKeepsExistingLabel()
 {
     $GLOBALS['TCA'] = array('aTable' => array('columns' => array('fieldA' => array()), 'types' => array('typeA' => array('showitem' => 'fieldA;labelA'))));
     $expected = array('aTable' => array('columns' => array('fieldA' => array()), 'types' => array('typeA' => array('showitem' => 'fieldA;labelA, --palette--;;generatedFor-fieldA')), 'palettes' => array('generatedFor-fieldA' => array('showitem' => 'newA'))));
     ExtensionManagementUtility::addFieldsToAllPalettesOfField('aTable', 'fieldA', 'newA');
     $this->assertEquals($expected, $GLOBALS['TCA']);
 }
Exemple #2
0
<?php

defined('TYPO3_MODE') or die;
// Prepare new columns for fe_users table
$tempColumns = array('tx_openid_openid' => array('exclude' => 0, 'label' => 'LLL:EXT:openid/locallang_db.xlf:be_users.tx_openid_openid', 'config' => array('type' => 'input', 'size' => '30', 'eval' => 'trim,nospace,uniqueInPid', 'wizards' => array('0' => array('type' => 'popup', 'title' => 'Add OpenID', 'module' => array('name' => 'wizard_openid'), 'icon' => 'EXT:openid/ext_icon_small.png', 'JSopenParams' => ',width=800,height=600,status=0,menubar=0,scrollbars=0')))));
// Add new columns to fe_users table
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('fe_users', $tempColumns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToAllPalettesOfField('fe_users', 'username', 'tx_openid_openid');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('fe_users', 'EXT:openid' . '/locallang_csh.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('_MOD_user_setup', 'EXT:openid/locallang_csh_mod.xlf');
 /**
  * Tests whether fields are added to a new palette that did not exist before.
  *
  * @test
  * @see ExtensionManagementUtility::addFieldsToAllPalettesOfField()
  */
 public function canAddFieldsToAllPalettesOfFieldWithoutPaletteExistingBefore()
 {
     $table = $this->getUniqueId('tx_coretest_table');
     $GLOBALS['TCA'] = $this->generateTCAForTable($table);
     ExtensionManagementUtility::addFieldsToAllPalettesOfField($table, 'fieldA', 'newA, newA, newB, fieldX');
     $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
     $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteB']['showitem']);
     $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteC']['showitem']);
     $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteD']['showitem']);
     $this->assertEquals('newA, newB, fieldX', $GLOBALS['TCA'][$table]['palettes']['generatedFor-fieldA']['showitem']);
 }
Exemple #4
0
	/**
	 * Tests whether fields are added to a new palette that did not exist before.
	 *
	 * @test
	 * @see ExtensionManagementUtility::addFieldsToAllPalettesOfField()
	 */
	public function canAddFieldsToAllPalettesOfFieldWithoutPaletteExistingBefore() {
		$table = $this->getUniqueId('tx_coretest_table');
		$GLOBALS['TCA'] = $this->generateTCAForTable($table);
		ExtensionManagementUtility::addFieldsToAllPalettesOfField($table, 'fieldA', 'newA, newA, newB, fieldX');
		// is palette reference added
		$this->assertSame('fieldA;;generatedFor-fieldA, fieldB, fieldC;labelC;paletteC;specialC, fieldC1, fieldD, fieldD1', $GLOBALS['TCA'][$table]['types']['typeA']['showitem']);
		$this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
		$this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteB']['showitem']);
		$this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteC']['showitem']);
		$this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteD']['showitem']);
		$this->assertEquals('newA, newB, fieldX', $GLOBALS['TCA'][$table]['palettes']['generatedFor-fieldA']['showitem']);
	}