‪TYPO3CMS  9.5
ActionHandlerTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
22 class ‪ActionHandlerTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
23 {
27  protected ‪$coreExtensionsToLoad = ['workspaces'];
28 
32  protected function ‪setUp()
33  {
34  parent::setUp();
35  $this->setUpBackendUserFromFixture(1);
37  }
38 
43  {
44  $actionHandler = new \TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler();
45 
46  $this->importDataSet(__DIR__ . '/Fixtures/pages.xml');
47  $this->importDataSet(__DIR__ . '/Fixtures/sys_workspace.xml');
48  $this->importDataSet(__DIR__ . '/Fixtures/tt_content.xml');
49 
50  // Prepare parameter
51  $parameter = new \stdClass();
52  $parameter->additional = '';
53  $parameter->recipients = [];
54  $parameter->comments = '';
55 
56  // Send to LIVE
57  $parameter->affects = new \stdClass();
58  $parameter->affects->nextStage = -20;
59  $parameter->affects->elements = [];
60 
61  // First and only affected element
62  $elementOne = new \stdClass();
63  $elementOne->table = 'tt_content';
64  $elementOne->uid = 2;
65  $elementOne->t3ver_oid = 1;
66  $parameter->affects->elements[] = $elementOne;
67 
68  $recordBeforePublish = ‪BackendUtility::getRecord('tt_content', 2);
69  $this->assertEquals($recordBeforePublish['header'], 'Workspace version of original content');
70 
71  // First publish
72  $result = $actionHandler->sendToSpecificStageExecute($parameter);
73  $this->assertTrue($result['success']);
74  $recordAfterFirstPublish = ‪BackendUtility::getRecord('tt_content', 2);
75 
76  $this->assertEquals($recordAfterFirstPublish['t3ver_wsid'], 0);
77  $this->assertEquals($recordAfterFirstPublish['header'], 'Original content');
78 
79  // Second publish
80  $result = $actionHandler->sendToSpecificStageExecute($parameter);
81  $this->assertTrue($result['success']);
82  $recordAfterSecondPublish = ‪BackendUtility::getRecord('tt_content', 2);
83 
84  // In case of an error, this will again be "Workspace version of original content"
85  $this->assertEquals($recordAfterSecondPublish['t3ver_wsid'], 0);
86  $this->assertEquals($recordAfterSecondPublish['header'], 'Original content');
87  }
88 }
‪TYPO3\CMS\Workspaces\Tests\Functional\ActionHandler\ActionHandlerTest
Definition: ActionHandlerTest.php:23
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:130
‪TYPO3\CMS\Workspaces\Tests\Functional\ActionHandler
Definition: ActionHandlerTest.php:2
‪TYPO3\CMS\Workspaces\Tests\Functional\ActionHandler\ActionHandlerTest\sendToSpecificStageExecuteIgnoresDoublePublishes
‪sendToSpecificStageExecuteIgnoresDoublePublishes()
Definition: ActionHandlerTest.php:41
‪TYPO3\CMS\Workspaces\Tests\Functional\ActionHandler\ActionHandlerTest\setUp
‪setUp()
Definition: ActionHandlerTest.php:31
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static Bootstrap null initializeLanguageObject()
Definition: Bootstrap.php:986
‪TYPO3\CMS\Workspaces\Tests\Functional\ActionHandler\ActionHandlerTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: ActionHandlerTest.php:26