‪TYPO3CMS  11.5
DataHandlerHookTest.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 
25 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\ActionService;
26 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
27 
31 class ‪DataHandlerHookTest extends FunctionalTestCase
32 {
33  protected ‪$coreExtensionsToLoad = ['workspaces'];
34 
36  protected ActionService ‪$actionService;
37 
38  protected function ‪setUp(): void
39  {
40  parent::setUp();
41  $this->backendUser = $this->setUpBackendUserFromFixture(1);
43  $this->actionService = new ActionService();
44  $this->‪setWorkspaceId(0);
45  }
46 
47  protected function ‪tearDown(): void
48  {
49  unset($this->actionService, $this->backendUser);
50  parent::tearDown();
51  }
52 
53  protected function ‪setWorkspaceId(int $workspaceId): void
54  {
55  $this->backendUser->workspace = $workspaceId;
56  GeneralUtility::makeInstance(Context::class)->setAspect('workspace', new ‪WorkspaceAspect($workspaceId));
57  }
58 
63  {
64  $this->importCSVDataSet(__DIR__ . '/DataSet/deletingSysWorkspaceDeletesWorkspaceRecords.csv');
65 
66  $this->‪setWorkspaceId(1);
67  // Create a pages move placeholder uid:93 and a versioned record uid:94 - both should be fully deleted after deleting ws1
68  $this->actionService->moveRecord('pages', 92, -1);
69  // Create a versioned record uid:311 - should be fully deleted after deleting ws1
70  $this->actionService->createNewRecord('tt_content', 89, ['header' => 'Testing #1']);
71  // Create a versioned record of a translated record uid:313 - should be fully deleted after deleting ws1
72  $this->actionService->modifyRecord('tt_content', 301, ['header' => '[Translate to Dansk:] Regular Element #1 Changed']);
73  // Create a delete placeholder uid:314 - should be fully deleted after deleting ws1
74  $this->actionService->deleteRecord('tt_content', 310);
75 
76  $this->‪setWorkspaceId(2);
77  // Create a versioned record uid:314 in ws2 - should be kept after deleting ws1
78  $this->actionService->modifyRecord('tt_content', 301, ['header' => '[Translate to Dansk:] Regular Element #1 Changed in ws2']);
79 
80  // Switch to live and delete sys_workspace record 1
81  $this->‪setWorkspaceId(0);
82  $this->actionService->deleteRecord('sys_workspace', 1);
83 
84  $this->assertCSVDataSet(__DIR__ . '/DataSet/deletingSysWorkspaceDeletesWorkspaceRecordsResult.csv');
85  }
86 }
‪TYPO3\CMS\Core\Context\WorkspaceAspect
Definition: WorkspaceAspect.php:31
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook
Definition: DataHandlerHookTest.php:18
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook\DataHandlerHookTest
Definition: DataHandlerHookTest.php:32
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook\DataHandlerHookTest\$coreExtensionsToLoad
‪$coreExtensionsToLoad
Definition: DataHandlerHookTest.php:33
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook\DataHandlerHookTest\setUp
‪setUp()
Definition: DataHandlerHookTest.php:38
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:598
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook\DataHandlerHookTest\$actionService
‪ActionService $actionService
Definition: DataHandlerHookTest.php:36
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook\DataHandlerHookTest\$backendUser
‪BackendUserAuthentication $backendUser
Definition: DataHandlerHookTest.php:35
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:70
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook\DataHandlerHookTest\deletingSysWorkspaceDeletesWorkspaceRecords
‪deletingSysWorkspaceDeletesWorkspaceRecords()
Definition: DataHandlerHookTest.php:62
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook\DataHandlerHookTest\tearDown
‪tearDown()
Definition: DataHandlerHookTest.php:47
‪TYPO3\CMS\Workspaces\Tests\Functional\Hook\DataHandlerHookTest\setWorkspaceId
‪setWorkspaceId(int $workspaceId)
Definition: DataHandlerHookTest.php:53
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50