ActionTest.php 2.42 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
    protected $testExtensionsToLoad = [
39
        'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield',
40
41
    ];

42
43
44
45
46
47
48
49
50
    /**
     * @test
     */
    public function verifyCleanReferenceIndex(): void
    {
        // The test verifies the imported data set has a clean reference index by the check in tearDown()
        self::assertTrue(true);
    }

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

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

74
        self::assertEquals(2, $referenceCount);
75
76
    }
}