‪TYPO3CMS  ‪main
ActionTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\Test;
23 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\ActionService;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 final class ‪ActionTest extends FunctionalTestCase
27 {
28  protected array ‪$coreExtensionsToLoad = ['workspaces'];
29 
30  protected array ‪$pathsToLinkInTestInstance = [
31  'typo3/sysext/core/Tests/Functional/DataHandling/FlexformIrre/Fixtures/fileadmin' => 'fileadmin/fixture',
32  ];
33 
34  protected array ‪$testExtensionsToLoad = [
35  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield',
36  ];
37 
38  #[Test]
40  {
41  $this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefault.csv');
42  $this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users_admin.csv');
43  $backendUser = $this->setUpBackendUser(1);
44  ‪$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->createFromUserPreferences($backendUser);
45  $backendUser->workspace = 1;
46  $actionService = new ActionService();
47  $actionService->modifyRecords(1, [
48  'tt_content' => ['uid' => 100, 'header' => 'Content #1 (WS)'],
49  ]);
50  // there should be one relation in the live WS and one in the draft WS pointing to the file field.
51  $queryBuilder = $this->getConnectionPool()->getQueryBuilderForTable('sys_file_reference');
52  $queryBuilder->getRestrictions()->removeAll();
53  $referenceCount = $queryBuilder
54  ->count('uid')
55  ->from('sys_file_reference')
56  ->where($queryBuilder->expr()->eq('uid_local', $queryBuilder->createNamedParameter(20, ‪Connection::PARAM_INT)))
57  ->executeQuery()
58  ->fetchOne();
59  self::assertEquals(2, $referenceCount);
60  }
61 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FlexformIrre\ActionTest\newVersionOfFileRelationInFlexformFieldIsCreatedOnSave
‪newVersionOfFileRelationInFlexformFieldIsCreatedOnSave()
Definition: ActionTest.php:39
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FlexformIrre\ActionTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: ActionTest.php:30
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:52
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FlexformIrre\ActionTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: ActionTest.php:28
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FlexformIrre\ActionTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: ActionTest.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FlexformIrre
Definition: ActionTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FlexformIrre\ActionTest
Definition: ActionTest.php:27