$GLOBALS['TSFE']->fe_user->user['uid'] = 999;
- $GLOBALS['TSFE']->id = 42;
+ $GLOBALS['TSFE']->id = 42;
}
public function setupTCA() {
* @test
*/
public function columnMapIsInitializedWithManyToManyRelationOfTypeSelect() {
- $columnConfiguration = array(
- 'type' => 'select',
- 'foreign_class' => 'Tx_MyExtension_Class',
- 'foreign_table' => 'tx_myextension_table',
- 'foreign_table_where' => 'WHERE 1=1',
- 'MM' => 'tx_myextension_mm',
- 'MM_match_fields' => array('match_field' => 'value'),
- // 'MM_insert_fields' => array('insert_field' => 'value'),
- 'MM_table_where' => 'WHERE 2=2',
- // 'MM_opposite_field' => 'opposite_field'
+ $leftColumnsDefinition = array(
+ 'rights' => array(
+ 'type' => 'select',
+ 'foreign_class' => 'Tx_MyExtension_RightClass',
+ 'foreign_table' => 'tx_myextension_righttable',
+ 'foreign_table_where' => 'WHERE 1=1',
+ 'MM' => 'tx_myextension_mm',
+ 'MM_table_where' => 'WHERE 2=2',
+ ),
);
$mockColumnMap = $this->getMock('Tx_Extbase_Persistence_Mapper_ColumnMap', array(), array(), '', FALSE);
$mockColumnMap->expects($this->once())->method('setTypeOfRelation')->with($this->equalTo(Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY));
- $mockColumnMap->expects($this->once())->method('setChildClassName')->with($this->equalTo('Tx_MyExtension_Class'));
- $mockColumnMap->expects($this->once())->method('setChildTableName')->with($this->equalTo('tx_myextension_table'));
+ $mockColumnMap->expects($this->once())->method('setChildClassName')->with($this->equalTo('Tx_MyExtension_RightClass'));
+ $mockColumnMap->expects($this->once())->method('setChildTableName')->with($this->equalTo('tx_myextension_righttable'));
$mockColumnMap->expects($this->once())->method('setChildTableWhereStatement')->with($this->equalTo('WHERE 1=1'));
$mockColumnMap->expects($this->once())->method('setChildSortbyFieldName')->with($this->equalTo('sorting'));
$mockColumnMap->expects($this->once())->method('setParentKeyFieldName')->with($this->equalTo('uid_local'));
$mockColumnMap->expects($this->never())->method('setParentTableFieldName');
- $mockColumnMap->expects($this->once())->method('setRelationTableMatchFields')->with($this->equalTo(array('match_field' => 'value')));
+ $mockColumnMap->expects($this->never())->method('setRelationTableMatchFields');
$mockColumnMap->expects($this->never())->method('setRelationTableInsertFields');
$mockDataMap = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Persistence_Mapper_DataMap'), array('dummy'), array(), '', FALSE);
- $mockDataMap->_callRef('setManyToManyRelation', $mockColumnMap, $columnConfiguration);
+ $mockDataMap->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']);
}
- // /**
- // * @test
- // */
- // public function columnMapIsInitializedWithManyToManyRelationOfTypeInline() {
- // $parentColumnConfiguration = array(
- // 'type' => 'inline',
- // 'foreign_table' => 'tx_myextension_mm',
- // 'foreign_field' => 'uid_local',
- // 'foreign_label' => 'uid_foreign'
- // );
- // $relationTableColumnsDefiniton = array(
- // 'uid_local' => array(
- // 'foreign_class' => 'Tx_MyExtension_ParentClass',
- // 'foreign_table' => 'tx_myextension_parenttable'
- // ),
- // 'uid_foreign' => array(
- // 'foreign_class' => 'Tx_MyExtension_ChildClass',
- // 'foreign_table' => 'tx_myextension_childtable'
- // )
- // );
- // $childColumnsDefinition = array(
- // array(
- // 'uid_local' => array(
- // 'type' => 'inline',
- // 'foreign_table' => 'tx_myextension_mm',
- // 'foreign_field' => 'uid_local',
- // 'foreign_label' => 'uid_foreign'
- // )
- // )
- // );
- // $mockColumnMap = $this->getMock('Tx_Extbase_Persistence_Mapper_ColumnMap', array(), array(), '', FALSE);
- // $mockColumnMap->expects($this->once())->method('setTypeOfRelation')->with($this->equalTo(Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY));
- // $mockColumnMap->expects($this->once())->method('setChildClassName')->with($this->equalTo('Tx_MyExtension_Class'));
- // $mockColumnMap->expects($this->once())->method('setChildTableName')->with($this->equalTo('tx_myextension_table'));
- // $mockColumnMap->expects($this->never())->method('setChildTableWhereStatement');
- // $mockColumnMap->expects($this->once())->method('setChildSortbyFieldName')->with($this->equalTo('sorting'));
- // $mockColumnMap->expects($this->once())->method('setParentKeyFieldName')->with($this->equalTo('uid_local'));
- // $mockColumnMap->expects($this->never())->method('setParentTableFieldName');
- // $mockColumnMap->expects($this->never())->method('setRelationTableMatchFields');
- // $mockColumnMap->expects($this->never())->method('setRelationTableInsertFields');
- //
- // $mockDataMap = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Persistence_Mapper_DataMap'), array('getColumnsDefinition', 'determineChildClassName'), array(), '', FALSE);
- // $mockDataMap->expects($this->once())->method('getColumnsDefinition')->with($this->equalTo('tx_myextension_mm'))->will($this->returnValue($relationTableColumnsDefiniton));
- // $mockDataMap->expects($this->once())->method('determineChildClassName')->with($this->equalTo($relationTableColumnsDefiniton))->will($this->returnValue('Tx_MyExtension_Class'));
- // $mockDataMap->_callRef('setManyToManyRelation', $mockColumnMap, $parentColumnConfiguration);
- // }
+ /**
+ * @test
+ */
+ public function columnMapIsInitializedWithOppositeManyToManyRelationOfTypeSelect() {
+ $rightColumnsDefinition = array(
+ 'lefts' => array(
+ 'type' => 'select',
+ 'foreign_class' => 'Tx_MyExtension_LeftClass',
+ 'foreign_table' => 'tx_myextension_lefttable',
+ 'MM' => 'tx_myextension_mm',
+ 'MM_opposite_field' => 'rights'
+ ),
+ );
+ $leftColumnsDefinition['rights']['MM_opposite_field'] = 'opposite_field';
+ $mockColumnMap = $this->getMock('Tx_Extbase_Persistence_Mapper_ColumnMap', array(), array(), '', FALSE);
+ $mockColumnMap->expects($this->once())->method('setTypeOfRelation')->with($this->equalTo(Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY));
+ $mockColumnMap->expects($this->once())->method('setChildClassName')->with($this->equalTo('Tx_MyExtension_LeftClass'));
+ $mockColumnMap->expects($this->once())->method('setChildTableName')->with($this->equalTo('tx_myextension_lefttable'));
+ $mockColumnMap->expects($this->once())->method('setChildTableWhereStatement')->with(NULL);
+ $mockColumnMap->expects($this->once())->method('setChildSortbyFieldName')->with($this->equalTo('sorting_foreign'));
+ $mockColumnMap->expects($this->once())->method('setParentKeyFieldName')->with($this->equalTo('uid_foreign'));
+ $mockColumnMap->expects($this->never())->method('setParentTableFieldName');
+ $mockColumnMap->expects($this->never())->method('setRelationTableMatchFields');
+ $mockColumnMap->expects($this->never())->method('setRelationTableInsertFields');
+
+ $mockDataMap = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Persistence_Mapper_DataMap'), array('dummy'), array(), '', FALSE);
+ $mockDataMap->_callRef('setManyToManyRelation', $mockColumnMap, $rightColumnsDefinition['lefts']);
+ }
+
+ /**
+ * @test
+ */
+ public function columnMapIsInitializedWithManyToManyRelationOfTypeInline() {
+ $leftColumnsDefinition = array(
+ 'rights' => array(
+ 'type' => 'inline',
+ 'foreign_table' => 'tx_myextension_mm',
+ 'foreign_field' => 'uid_local',
+ 'foreign_label' => 'uid_foreign',
+ 'foreign_sortby' => 'sorting'
+ )
+ );
+ $relationTableColumnsDefiniton = array(
+ 'uid_local' => array(
+ 'foreign_class' => 'Tx_MyExtension_LocalClass',
+ 'foreign_table' => 'tx_myextension_localtable'
+ ),
+ 'uid_foreign' => array(
+ 'foreign_class' => 'Tx_MyExtension_RightClass',
+ 'foreign_table' => 'tx_myextension_righttable'
+ )
+ );
+ $rightColumnsDefinition = array(
+ 'lefts' => array(
+ 'type' => 'inline',
+ 'foreign_table' => 'tx_myextension_mm',
+ 'foreign_field' => 'uid_foreign',
+ 'foreign_label' => 'uid_local',
+ 'foreign_sortby' => 'sorting_foreign'
+ )
+ );
+ $mockColumnMap = $this->getMock('Tx_Extbase_Persistence_Mapper_ColumnMap', array(), array(), '', FALSE);
+ $mockColumnMap->expects($this->once())->method('setTypeOfRelation')->with($this->equalTo(Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY));
+ $mockColumnMap->expects($this->once())->method('setChildClassName')->with($this->equalTo('Tx_MyExtension_RightClass'));
+ $mockColumnMap->expects($this->once())->method('setChildTableName')->with($this->equalTo('tx_myextension_righttable'));
+ $mockColumnMap->expects($this->never())->method('setChildTableWhereStatement');
+ $mockColumnMap->expects($this->once())->method('setChildSortbyFieldName')->with($this->equalTo('sorting'));
+ $mockColumnMap->expects($this->once())->method('setParentKeyFieldName')->with($this->equalTo('uid_local'));
+ $mockColumnMap->expects($this->never())->method('setParentTableFieldName');
+ $mockColumnMap->expects($this->never())->method('setRelationTableMatchFields');
+ $mockColumnMap->expects($this->never())->method('setRelationTableInsertFields');
+
+ $mockDataMap = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Persistence_Mapper_DataMap'), array('getColumnsDefinition', 'determineChildClassName'), array(), '', FALSE);
+ $mockDataMap->expects($this->once())->method('getColumnsDefinition')->with($this->equalTo('tx_myextension_mm'))->will($this->returnValue($relationTableColumnsDefiniton));
+ $mockDataMap->expects($this->once())->method('determineChildClassName')->with($this->equalTo($relationTableColumnsDefiniton['uid_foreign']))->will($this->returnValue('Tx_MyExtension_RightClass'));
+ $mockDataMap->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']);
+ }
}
?>
\ No newline at end of file