TYPO3 CMS  TYPO3_7-6
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 
23 {
24  protected $coreExtensionsToLoad = ['version', 'workspaces'];
25 
31  protected function setUp()
32  {
33  parent::setUp();
34  $this->setUpBackendUserFromFixture(1);
35  \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
36  }
37 
42  {
43  $actionHandler = new \TYPO3\CMS\Workspaces\ExtDirect\ActionHandler();
44 
45  $this->importDataSet(__DIR__ . '/Fixtures/pages.xml');
46  $this->importDataSet(__DIR__ . '/Fixtures/sys_workspace.xml');
47  $this->importDataSet(__DIR__ . '/Fixtures/tt_content.xml');
48 
49  // Prepare parameter
50  $parameter = new \stdClass();
51  $parameter->additional = '';
52  $parameter->receipients = [];
53  $parameter->comments = '';
54 
55  // Send to LIVE
56  $parameter->affects = new \stdClass();
57  $parameter->affects->nextStage = -20;
58  $parameter->affects->elements = [];
59 
60  // First and only affected element
61  $elementOne = new \stdClass();
62  $elementOne->table = 'tt_content';
63  $elementOne->uid = 2;
64  $elementOne->t3ver_oid = 1;
65  $parameter->affects->elements[] = $elementOne;
66 
67  $recordBeforePublish = BackendUtility::getRecord('tt_content', 2);
68  $this->assertEquals($recordBeforePublish['header'], 'Workspace version of original content');
69 
70  // First publish
71  $result = $actionHandler->sendToSpecificStageExecute($parameter);
72  $this->assertTrue($result['success']);
73  $recordAfterFirstPublish = BackendUtility::getRecord('tt_content', 2);
74 
75  $this->assertEquals($recordAfterFirstPublish['t3ver_wsid'], 0);
76  $this->assertEquals($recordAfterFirstPublish['header'], 'Original content');
77 
78  // Second publish
79  $result = $actionHandler->sendToSpecificStageExecute($parameter);
80  $this->assertTrue($result['success']);
81  $recordAfterSecondPublish = BackendUtility::getRecord('tt_content', 2);
82 
83  // In case of an error, this will again be "Workspace version of original content"
84  $this->assertEquals($recordAfterSecondPublish['t3ver_wsid'], 0);
85  $this->assertEquals($recordAfterSecondPublish['header'], 'Original content');
86  }
87 }
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)