Commit 07c8cdab authored by Oliver Hader's avatar Oliver Hader Committed by Oliver Hader
Browse files

[TASK] Add functional tests for TCA types select and group/db

The tests for TCA types 'select' and 'group' include for each
* Modify in live
* Modify in workspace
* Publish in workspace
* PublihAll in workspace

Resolves: #56707
Releases: 6.2
Change-Id: I4bd8584f01122d0c4a974618d00e126b91270589
Reviewed-on: https://review.typo3.org/27823
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
parent 34fcdead
<?php
namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Group;
/***************************************************************
* Copyright notice
*
* (c) 2014 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!
***************************************************************/
require_once dirname(dirname(__FILE__)) . '/AbstractDataHandlerActionTestCase.php';
/**
* Functional test for the DataHandler
*/
abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase {
const VALUE_PageId = 89;
const VALUE_PageIdTarget = 90;
const VALUE_ContentIdFirst = 297;
const VALUE_ContentIdLast = 298;
const VALUE_LanguageId = 1;
const VALUE_ElementIdFirst = 1;
const VALUE_ElementIdSecond = 2;
const VALUE_ElementIdThird = 3;
const TABLE_Content = 'tt_content';
const TABLE_Element = 'tx_testdatahandler_element';
const FIELD_ContentElement = 'tx_testdatahandler_group';
/**
* @var string
*/
protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Group/DataSet/';
public function setUp() {
$this->testExtensionsToLoad[] = 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler';
parent::setUp();
$this->importScenarioDataSet('LiveDefaultPages');
$this->importScenarioDataSet('LiveDefaultElements');
$this->importScenarioDataSet('ReferenceIndex');
$this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
}
/**
* Relations
*/
/**
* @test
* @see DataSet/addElementRelation.csv
*/
public function addElementRelation() {
$this->actionService->modifyReferences(
self::TABLE_Content, self::VALUE_ContentIdFirst, self::FIELD_ContentElement, array(self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird)
);
}
/**
* @test
* @see DataSet/deleteElementRelation.csv
*/
public function deleteElementRelation() {
$this->actionService->modifyReferences(
self::TABLE_Content, self::VALUE_ContentIdFirst, self::FIELD_ContentElement, array(self::VALUE_ElementIdFirst)
);
}
/**
* @test
* @see DataSet/changeElementSorting.csv
*/
public function changeElementSorting() {
$this->actionService->moveRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, -self::VALUE_ElementIdSecond);
}
/**
* @test
* @see DataSet/changeElementRelationSorting.csv
*/
public function changeElementRelationSorting() {
$this->actionService->modifyReferences(
self::TABLE_Content, self::VALUE_ContentIdFirst, self::FIELD_ContentElement, array(self::VALUE_ElementIdSecond, self::VALUE_ElementIdFirst)
);
}
/**
* @test
* @see DataSet/createContentNAddRelation.csv
*/
public function createContentAndAddElementRelation() {
$newTableIds = $this->actionService->createNewRecord(
self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1', self::FIELD_ContentElement => self::VALUE_ElementIdFirst)
);
$this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
}
/**
* @test
* @see DataSet/createContentNCreateRelation.csv
*/
public function createContentAndCreateElementRelation() {
$newElementIds = $this->actionService->createNewRecord(self::TABLE_Element, self::VALUE_PageId, array('title' => 'Testing #1'));
$this->recordIds['newElementId'] = $newElementIds[self::TABLE_Element][0];
// It's not possible to use "NEW..." values for the TCA type 'group'
$newContentIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1', self::FIELD_ContentElement => $this->recordIds['newElementId']));
$this->recordIds['newContentId'] = $newContentIds[self::TABLE_Content][0];
}
/**
* @test
* @see DataSet/modifyElementOfRelation.csv
*/
public function modifyElementOfRelation() {
$this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, array('title' => 'Testing #1'));
}
/**
* @test
* @see DataSet/modifyContentOfRelation.csv
*/
public function modifyContentOfRelation() {
$this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('header' => 'Testing #1'));
}
/**
* @test
* @see DataSet/modifyBothSidesOfRelation.csv
*/
public function modifyBothSidesOfRelation() {
$this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, array('title' => 'Testing #1'));
$this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('header' => 'Testing #1'));
}
/**
* @test
* @see DataSet/deleteContentOfRelation.csv
*/
public function deleteContentOfRelation() {
$this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
}
/**
* @test
* @see DataSet/deleteElementOfRelation.csv
*/
public function deleteElementOfRelation() {
$this->actionService->deleteRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
}
/**
* @test
* @see DataSet/copyContentOfRelation.csv
*/
public function copyContentOfRelation() {
$newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
$this->recordIds['copiedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
}
/**
* @test
* @see DataSet/copyElementOfRelation.csv
*/
public function copyElementOfRelation() {
$newTableIds = $this->actionService->copyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_PageId);
$this->recordIds['copiedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
}
/**
* @test
* @see DataSet/localizeContentOfRelation.csv
*/
public function localizeContentOfRelation() {
$newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
$this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
}
/**
* @test
* @see DataSet/localizeElementOfRelation.csv
*/
public function localizeElementOfRelation() {
$newTableIds = $this->actionService->localizeRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
$this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
}
/**
* @test
* @see DataSet/moveContentOfRelationToDifferentPage.csv
*/
public function moveContentOfRelationToDifferentPage() {
$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
}
}
"sys_language"
,"uid","pid","hidden","title","flag"
,1,0,0,"Dansk","dk"
,2,0,0,"Deutsch","de"
tt_content
,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,tx_testdatahandler_group
,297,89,256,0,0,0,0,0,0,0,0,"Regular Element #1","1,2"
,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2","2,3"
tx_testdatahandler_element
,uid,pid,sorting,deleted,sys_language_uid,l10n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title
,1,89,256,0,0,0,0,0,0,0,0,"Element #1"
,2,89,512,0,0,0,0,0,0,0,0,"Element #2"
,3,89,768,0,0,0,0,0,0,0,0,"Element #3"
pages
,uid,pid,sorting,deleted,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title
,1,0,256,0,0,0,0,0,0,FunctionalTest
,88,1,256,0,0,0,0,0,0,DataHandlerTest
,89,88,256,0,0,0,0,0,0,Relations
,90,88,512,0,0,0,0,0,0,Target
sys_refindex
,hash,tablename,recuid,field,flexpointer,softref_key,softref_id,sorting,deleted,ref_table,ref_uid,ref_string
,0c81d9b3f27460380a2e442fdfa0649d,tt_content,298,tx_testdatahandler_group,,,,0,0,tx_testdatahandler_element,2,
,8f3d6a0de293045066188fc790f4805f,tt_content,298,tx_testdatahandler_group,,,,1,0,tx_testdatahandler_element,3,
,70386199b2e7d7e3be07ec7b501f411d,tt_content,297,tx_testdatahandler_group,,,,0,0,tx_testdatahandler_element,1,
,3f113b20cdf1b3be96048a257872a178,tt_content,297,tx_testdatahandler_group,,,,1,0,tx_testdatahandler_element,2,
<?php
namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\Modify;
/***************************************************************
* Copyright notice
*
* (c) 2014 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!
***************************************************************/
require_once dirname(dirname(__FILE__)) . '/AbstractActionTestCase.php';
/**
* Functional test for the DataHandler
*/
class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase {
/**
* @var string
*/
protected $assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Group/Modify/DataSet/';
/**
* Relations
*/
/**
* @test
* @see DataSet/addElementRelation.csv
*/
public function addElementRelation() {
parent::addElementRelation();
$this->assertAssertionDataSet('addElementRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #1', 'Element #2', 'Element #3')
);
}
/**
* @test
* @see DataSet/deleteElementRelation.csv
*/
public function deleteElementRelation() {
parent::deleteElementRelation();
$this->assertAssertionDataSet('deleteElementRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #1')
);
$this->assertResponseContentStructureDoesNotHaveRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #2', 'Element #3')
);
}
/**
* @test
* @see DataSet/changeElementSorting.csv
*/
public function changeElementSorting() {
parent::changeElementSorting();
$this->assertAssertionDataSet('changeElementSorting');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #1', 'Element #2')
);
}
/**
* @test
* @see DataSet/changeElementRelationSorting.csv
*/
public function changeElementRelationSorting() {
parent::changeElementRelationSorting();
$this->assertAssertionDataSet('changeElementRelationSorting');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #1', 'Element #2')
);
}
/**
* @test
* @see DataSet/createContentNAddRelation.csv
*/
public function createContentAndAddElementRelation() {
parent::createContentAndAddElementRelation();
$this->assertAssertionDataSet('createContentNAddRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentElement,
self::TABLE_Element, 'title', 'Element #1'
);
}
/**
* @test
* @see DataSet/createContentNCreateRelation.csv
*/
public function createContentAndCreateElementRelation() {
parent::createContentAndCreateElementRelation();
$this->assertAssertionDataSet('createContentNCreateRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentElement,
self::TABLE_Element, 'title', 'Testing #1'
);
}
/**
* @test
* @see DataSet/modifyElementOfRelation.csv
*/
public function modifyElementOfRelation() {
parent::modifyElementOfRelation();
$this->assertAssertionDataSet('modifyElementOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Testing #1', 'Element #2')
);
}
/**
* @test
* @see DataSet/modifyContentOfRelation.csv
*/
public function modifyContentOfRelation() {
parent::modifyContentOfRelation();
$this->assertAssertionDataSet('modifyContentOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
}
/**
* @test
* @see DataSet/modifyBothSidesOfRelation.csv
*/
public function modifyBothSidesOfRelation() {
parent::modifyBothSidesOfRelation();
$this->assertAssertionDataSet('modifyBothSidesOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Testing #1', 'Element #2')
);
$this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
}
/**
* @test
* @see DataSet/deleteContentOfRelation.csv
*/
public function deleteContentOfRelation() {
parent::deleteContentOfRelation();
$this->assertAssertionDataSet('deleteContentOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
}
/**
* @test
* @see DataSet/deleteElementOfRelation.csv
*/
public function deleteElementOfRelation() {
parent::deleteElementOfRelation();
$this->assertAssertionDataSet('deleteElementOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentStructureDoesNotHaveRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #1')
);
}
/**
* @test
* @see DataSet/copyContentOfRelation.csv
*/
public function copyContentOfRelation() {
parent::copyContentOfRelation();
$this->assertAssertionDataSet('copyContentOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
// Referenced elements are not copied with the "parent", which is expected and correct
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . $this->recordIds['copiedContentId'], self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #2', 'Element #3')
);
}
/**
* @test
* @see DataSet/copyElementOfRelation.csv
*/
public function copyElementOfRelation() {
parent::copyElementOfRelation();
$this->assertAssertionDataSet('copyElementOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #1')
);
// Referenced elements are not updated at the "parent", which is expected and correct
$this->assertResponseContentStructureDoesNotHaveRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #1 (copy 1)')
);
}
/**
* @test
* @see DataSet/localizeContentOfRelation.csv
*/
public function localizeContentOfRelation() {
parent::localizeContentOfRelation();
$this->assertAssertionDataSet('localizeContentOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #2', 'Element #3')
);
}
/**
* @test
* @see DataSet/localizeElementOfRelation.csv
*/
public function localizeElementOfRelation() {
parent::localizeElementOfRelation();
$this->assertAssertionDataSet('localizeElementOfRelation');
$responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('[Translate to Dansk:] Element #1', 'Element #2')
);
}
/**
* @test
* @see DataSet/moveContentOfRelationToDifferentPage.csv
*/
public function moveContentOfRelationToDifferentPage() {
parent::moveContentOfRelationToDifferentPage();
$this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
$responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
$this->assertResponseContentStructureHasRecords(
$responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentElement,
self::TABLE_Element, 'title', array('Element #2', 'Element #3')
);
}
}
sys_refindex
,hash,tablename,recuid,field,flexpointer,softref_key,softref_id,sorting,deleted,ref_table,ref_uid,ref_string
,0c81d9b3f27460380a2e442fdfa0649d,tt_content,298,tx_testdatahandler_group,,,,0,0,tx_testdatahandler_element,2,
,8f3d6a0de293045066188fc790f4805f,tt_content,298,tx_testdatahandler_group,,,,1,0,tx_testdatahandler_element,3,
,70386199b2e7d7e3be07ec7b501f411d,tt_content,297,tx_testdatahandler_group,,,,0,0,tx_testdatahandler_element,1,
,3f113b20cdf1b3be96048a257872a178,tt_content,297,tx_testdatahandler_group,,,,1,0,tx_testdatahandler_element,2,
pages
,uid,pid,sorting,deleted,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title
,1,0,256,0,0,0,0,0,0,FunctionalTest
,88,1,256,0,0,0,0,0,0,DataHandlerTest
,89,88,256,0,0,0,0,0,0,Relations
,90,88,512,0,0,0,0,0,0,Target
tt_content
,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,tx_testdatahandler_group
,297,89,256,0,0,0,0,0,0,0,0,"Regular Element #1","1,2,3"
,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2","2,3"
tx_testdatahandler_element
,uid,pid,sorting,deleted,sys_language_uid,l10n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title
,1,89,256,0,0,0,0,0,0,0,0,"Element #1"
,2,89,512,0,0,0,0,0,0,0,0,"Element #2"
,3,89,768,0,0,0,0,0,0,0,0,"Element #3"
pages
,uid,pid,sorting,deleted,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title
,1,0,256,0,0,0,0,0,0,FunctionalTest
,88,1,256,0,0,0,0,0,0,DataHandlerTest
,89,88,256,0,0,0,0,0,0,Relations
,90,88,512,0,0,0,0,0,0,Target
tt_content
,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,tx_testdatahandler_group
,297,89,256,0,0,0,0,0,0,0,0,"Regular Element #1","2,1"
,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2","2,3"
tx_testdatahandler_element
,uid,pid,sorting,deleted,sys_language_uid,l10n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title
,1,89,256,0,0,0,0,0,0,0,0,"Element #1"
,2,89,512,0,0,0,0,0,0,0,0,"Element #2"
,3,89,768,0,0,0,0,0,0,0,0,"Element #3"