Bug #88144 » tca-group-test.patch
typo3/sysext/backend/Tests/Functional/Form/FormDataProvider/Fixtures/DataSet/TestTcaGroup.xml | ||
---|---|---|
<?xml version="1.0" encoding="utf-8"?>
|
||
<dataset>
|
||
<pages>
|
||
<uid>1</uid>
|
||
<pid>1</pid>
|
||
<title>visible</title>
|
||
<deleted>0</deleted>
|
||
</pages>
|
||
<pages>
|
||
<uid>2</uid>
|
||
<pid>1</pid>
|
||
<title>deleted</title>
|
||
<deleted>1</deleted>
|
||
</pages>
|
||
<pages>
|
||
<uid>3</uid>
|
||
<pid>1</pid>
|
||
<title>hidden</title>
|
||
<hidden>1</hidden>
|
||
</pages>
|
||
<pages>
|
||
<uid>4</uid>
|
||
<pid>1</pid>
|
||
<title>expired</title>
|
||
<endtime>1262300400</endtime>
|
||
</pages>
|
||
<pages>
|
||
<uid>5</uid>
|
||
<pid>-1</pid>
|
||
<title>deletedInWorkspace</title>
|
||
<t3_origuid>1</t3_origuid>
|
||
<t3ver_oid>1</t3ver_oid>
|
||
<t3ver_wsid>1</t3ver_wsid>
|
||
<t3ver_state>2</t3ver_state>
|
||
</pages>
|
||
</dataset>
|
typo3/sysext/backend/Tests/Functional/Form/FormDataProvider/TcaGroupTest.php | ||
---|---|---|
<?php
|
||
declare(strict_types = 1);
|
||
namespace TYPO3\CMS\Core\Tests\Functional\Database;
|
||
/*
|
||
* This file is part of the TYPO3 CMS project.
|
||
*
|
||
* It is free software; you can redistribute it and/or modify it under
|
||
* the terms of the GNU General Public License, either version 2
|
||
* of the License, or any later version.
|
||
*
|
||
* For the full copyright and license information, please read the
|
||
* LICENSE.txt file that was distributed with this source code.
|
||
*
|
||
* The TYPO3 project - inspiring people to share!
|
||
*/
|
||
use TYPO3\CMS\Backend\Clipboard\Clipboard;
|
||
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaGroup;
|
||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
||
/**
|
||
* Test case
|
||
*/
|
||
class TcaGroupTest extends FunctionalTestCase
|
||
{
|
||
protected $coreExtensionsToLoad = ['workspaces'];
|
||
/**
|
||
* This test checks if TcaGroup respects deleted elements
|
||
*
|
||
* @test
|
||
*/
|
||
public function respectsDeletedElements()
|
||
{
|
||
$this->importDataSet(__DIR__ . '/Fixtures/DataSet/TestTcaGroup.xml');
|
||
$aFieldConfig = [
|
||
'type' => 'group',
|
||
'internal_type' => 'db',
|
||
'allowed' => 'pages',
|
||
'maxitems' => 99999,
|
||
];
|
||
$input = [
|
||
'tableName' => 'aTable',
|
||
'databaseRow' => [
|
||
'uid' => 42,
|
||
'aField' => '1,2,3,4',
|
||
],
|
||
'processedTca' => [
|
||
'columns' => [
|
||
'aField' => [
|
||
'config' => $aFieldConfig,
|
||
],
|
||
],
|
||
],
|
||
];
|
||
$backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
|
||
$GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
|
||
$clipboardProphecy = $this->prophesize(Clipboard::class);
|
||
GeneralUtility::addInstance(Clipboard::class, $clipboardProphecy->reveal());
|
||
$clipboardProphecy->initializeClipboard()->shouldBeCalled();
|
||
$clipboardProphecy->elFromTable('pages')->shouldBeCalled()->willReturn([]);
|
||
$result = (new TcaGroup)->addData($input);
|
||
static::assertIsArray($result['databaseRow']['aField'], 'TcaGroup did not load items');
|
||
$loadedUids = array_column($result['databaseRow']['aField'], 'uid');
|
||
static::assertEquals($loadedUids, [1, 3, 4], 'TcaGroup did not load the correct items');
|
||
}
|
||
/**
|
||
* This test checks if TcaGroup respects deleted elements in a workspace
|
||
*
|
||
* @test
|
||
*/
|
||
public function respectsDeletedElementsInWorkspace()
|
||
{
|
||
$this->importDataSet(__DIR__ . '/Fixtures/DataSet/TestTcaGroup.xml');
|
||
$aFieldConfig = [
|
||
'type' => 'group',
|
||
'internal_type' => 'db',
|
||
'allowed' => 'pages',
|
||
'maxitems' => 99999,
|
||
];
|
||
$input = [
|
||
'tableName' => 'aTable',
|
||
'databaseRow' => [
|
||
'uid' => 42,
|
||
'aField' => '1,2,3,4',
|
||
],
|
||
'processedTca' => [
|
||
'columns' => [
|
||
'aField' => [
|
||
'config' => $aFieldConfig,
|
||
],
|
||
],
|
||
],
|
||
];
|
||
$backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
|
||
$backendUserProphecy->workspace = 1;
|
||
$GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
|
||
$clipboardProphecy = $this->prophesize(Clipboard::class);
|
||
GeneralUtility::addInstance(Clipboard::class, $clipboardProphecy->reveal());
|
||
$clipboardProphecy->initializeClipboard()->shouldBeCalled();
|
||
$clipboardProphecy->elFromTable('pages')->shouldBeCalled()->willReturn([]);
|
||
$result = (new TcaGroup)->addData($input);
|
||
static::assertIsArray($result['databaseRow']['aField'], 'TcaGroup did not load items in a workspace');
|
||
$loadedUids = array_column($result['databaseRow']['aField'], 'uid');
|
||
static::assertEquals($loadedUids, [3, 4], 'TcaGroup did not load the correct items in a workspace');
|
||
}
|
||
}
|