‪TYPO3CMS  10.4
ClipboardTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
24 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
25 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
26 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
27 
31 class ‪ClipboardTest extends FunctionalTestCase
32 {
34 
38  protected ‪$coreExtensionsToLoad = ['workspaces'];
39 
43  private ‪$subject;
44 
48  private ‪$backendUser;
49 
50  public static function ‪setUpBeforeClass(): void
51  {
52  parent::setUpBeforeClass();
53  static::initializeDatabaseSnapshot();
54  }
55 
56  public static function ‪tearDownAfterClass(): void
57  {
58  static::destroyDatabaseSnapshot();
59  parent::tearDownAfterClass();
60  }
61 
62  protected function ‪setUp(): void
63  {
64  parent::setUp();
65 
66  $this->subject = GeneralUtility::makeInstance(Clipboard::class);
67  $this->backendUser = $this->setUpBackendUserFromFixture(1);
68 
69  $this->withDatabaseSnapshot(function () {
70  $this->‪setUpDatabase();
71  });
72  }
73 
74  protected function ‪tearDown(): void
75  {
76  unset($this->subject, $this->backendUser);
77  parent::tearDown();
78  }
79 
80  protected function ‪setUpDatabase()
81  {
83 
84  $scenarioFile = __DIR__ . '/../Fixtures/CommonScenario.yaml';
85  $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
86  $writer = DataHandlerWriter::withBackendUser($this->backendUser);
87  $writer->invokeFactory($factory);
88  static::failIfArrayIsNotEmpty(
89  $writer->getErrors()
90  );
91  }
92 
96  public function ‪localizationsAreResolvedDataProvider(): array
97  {
98  return [
99  'live workspace with live & version localizations' => [
100  1100,
101  0,
102  [
103  'FR: Welcome',
104  'FR-CA: Welcome',
105  ]
106  ],
107  'draft workspace with live & version localizations' => [
108  1100,
109  1,
110  [
111  'FR: Welcome',
112  'FR-CA: Welcome',
113  'ES: Bienvenido',
114  ]
115  ],
116  'live workspace with live localizations only' => [
117  1400,
118  0,
119  [
120  'FR: ACME in your Region',
121  'FR-CA: ACME in your Region',
122  ]
123  ],
124  'draft workspace with live localizations only' => [
125  1400,
126  1,
127  [
128  'FR: ACME in your Region',
129  'FR-CA: ACME in your Region',
130  ]
131  ],
132  'live workspace with version localizations only' => [
133  1500,
134  0,
135  []
136  ],
137  'draft workspace with version localizations only' => [
138  1500,
139  1,
140  [
141  'FR: Interne',
142  ]
143  ],
144  ];
145  }
146 
155  public function ‪localizationsAreResolved(int $pageId, int $workspaceId, array $expectation)
156  {
157  $this->backendUser->workspace = $workspaceId;
158  $record = ‪BackendUtility::getRecordWSOL('pages', $pageId);
159  $actualResult = array_column(
160  $this->subject->getLocalizations('pages', $record),
161  'title'
162  );
163  self::assertEqualsCanonicalizing($expectation, $actualResult);
164  }
165 }
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\$backendUser
‪BackendUserAuthentication $backendUser
Definition: ClipboardTest.php:44
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard
Definition: ClipboardTest.php:16
‪TYPO3\CMS\Backend\Clipboard\Clipboard
Definition: Clipboard.php:43
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\localizationsAreResolvedDataProvider
‪array localizationsAreResolvedDataProvider()
Definition: ClipboardTest.php:92
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\setUpDatabase
‪setUpDatabase()
Definition: ClipboardTest.php:76
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\$coreExtensionsToLoad
‪string[] $coreExtensionsToLoad
Definition: ClipboardTest.php:36
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:36
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\$subject
‪Clipboard $subject
Definition: ClipboardTest.php:40
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\setUp
‪setUp()
Definition: ClipboardTest.php:58
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:617
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\setUpBeforeClass
‪static setUpBeforeClass()
Definition: ClipboardTest.php:46
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordWSOL
‪static array getRecordWSOL( $table, $uid, $fields=' *', $where='', $useDeleteClause=true, $unsetMovePointers=false)
Definition: BackendUtility.php:139
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\localizationsAreResolved
‪localizationsAreResolved(int $pageId, int $workspaceId, array $expectation)
Definition: ClipboardTest.php:151
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\tearDownAfterClass
‪static tearDownAfterClass()
Definition: ClipboardTest.php:52
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest
Definition: ClipboardTest.php:32
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Tests\Functional\Clipboard\ClipboardTest\tearDown
‪tearDown()
Definition: ClipboardTest.php:70