ActionTest.php 2.39 KB
Newer Older
1
<?php
2

3
4
declare(strict_types=1);

5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 * 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!
 */

18
19
namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\FlexformIrre;

20
21
22
use TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase;

class ActionTest extends AbstractDataHandlerActionTestCase
23
{
24
    protected $coreExtensionsToLoad = ['workspaces'];
25

26
27
28
    /**
     * @var array
     */
29
    protected $pathsToLinkInTestInstance = [
30
        'typo3/sysext/core/Tests/Functional/DataHandling/FlexformIrre/Fixtures/fileadmin' => 'fileadmin/fixture',
31
    ];
32
33
34
35
36
37

    /**
     * @var string
     */
    protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/FlexformIrre/DataSet/';

38
39
40
41
42
43
    /**
     * @var bool
     * @todo: Test setup should be updated to have true here
     */
    protected $assertCleanReferenceIndex = false;

44
    protected $testExtensionsToLoad = [
45
        'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield',
46
47
    ];

48
49
50
    /**
     * @test
     */
51
    public function newVersionOfFileRelationInFlexformFieldIsCreatedOnSave(): void
52
    {
53
54
        $this->importScenarioDataSet('LiveDefaultPages');
        $this->importScenarioDataSet('LiveDefaultElements');
55
        $this->setWorkspaceId(1);
56
57
        $this->getActionService()->modifyRecords(1, [
            //'sys_file_reference' => ['uid' => 10, 'hidden' => 0],
58
            'tt_content' => ['uid' => 100, 'header' => 'Content #1 (WS)'],
59
60
61
        ]);

        // there should be one relation in the live WS and one in the draft WS pointing to the file field.
62
63
64
65
66
67
        $queryBuilder = $this->getConnectionPool()
            ->getQueryBuilderForTable('sys_file_reference');
        $queryBuilder->getRestrictions()->removeAll();
        $referenceCount = $queryBuilder
            ->count('uid')
            ->from('sys_file_reference')
68
            ->where($queryBuilder->expr()->eq('uid_local', $queryBuilder->createNamedParameter(20, \PDO::PARAM_INT)))
69
            ->execute()
70
            ->fetchOne();
71

72
        self::assertEquals(2, $referenceCount);
73
74
    }
}