TYPO3 CMS  TYPO3_6-2
ActionTest.php
Go to the documentation of this file.
1 <?php
3 
17 require_once dirname(dirname(__FILE__)) . '/AbstractActionTestCase.php';
18 
23 
27  protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/FAL/Publish/DataSet/';
28 
37  public function modifyContent() {
38  parent::modifyContent();
39  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
40  $this->assertAssertionDataSet('modifyContent');
41 
42  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
43  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
44  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
45  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
46  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
47  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(TRUE));
48  }
49 
54  public function deleteContent() {
55  parent::deleteContent();
56  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
57  $this->assertAssertionDataSet('deleteContent');
58 
59  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
60  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
61  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
62  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
63  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
64  }
65 
70  public function copyContent() {
71  parent::copyContent();
72  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
73  $this->assertAssertionDataSet('copyContent');
74 
75  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
76  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
77  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
78  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
79  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentImage)
80  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(TRUE));
81  }
82 
87  public function localizeContent() {
88  parent::localizeContent();
89  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
90  $this->assertAssertionDataSet('localizeContent');
91 
92  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
93  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
94  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
95 
96  // @todo Values in sys_file_reference are not copied during localization...
97  /*
98  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
99  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
100  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(TRUE));
101  */
102  }
103 
108  public function changeContentSorting() {
109  parent::changeContentSorting();
110  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
111  $this->assertAssertionDataSet('changeContentSorting');
112 
113  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
114  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
115  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
116  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
117  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
118  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
119  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
120  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
121  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(TRUE));
122  }
123 
128  public function moveContentToDifferentPage() {
129  parent::moveContentToDifferentPage();
130  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
131  $this->assertAssertionDataSet('moveContentToDifferentPage');
132 
133  $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
134  $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
135  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
136  $this->assertThat($responseSectionsSource, $this->getRequestSectionStructureHasRecordConstraint()
137  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
138  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(TRUE));
139  $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
140  $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
141  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
142  $this->assertThat($responseSectionsTarget, $this->getRequestSectionStructureHasRecordConstraint()
143  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
144  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(TRUE));
145  }
146 
152  parent::moveContentToDifferentPageAndChangeSorting();
153  $this->actionService->publishRecords(
154  array(
155  self::TABLE_Content => array(self::VALUE_ContentIdFirst, self::VALUE_ContentIdLast),
156  )
157  );
158  $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
159 
160  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
161  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
162  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
163  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
164  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
165  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(TRUE));
166  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
167  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
168  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(TRUE));
169  }
170 
179  public function createContentWithFileReference() {
180  parent::createContentWithFileReference();
181  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
182  $this->assertAssertionDataSet('createContentWFileReference');
183 
184  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
185  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
186  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
187  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
188  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
189  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1')->setStrict(TRUE));
190  }
191 
196  public function modifyContentWithFileReference() {
197  parent::modifyContentWithFileReference();
198  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
199  $this->assertAssertionDataSet('modifyContentWFileReference');
200 
201  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
202  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
203  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
204  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
205  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
206  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1')->setStrict(TRUE));
207  }
208 
214  parent::modifyContentAndAddFileReference();
215  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
216  $this->assertAssertionDataSet('modifyContentNAddFileReference');
217 
218  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
219  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
220  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
221  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3')->setStrict(TRUE));
222  }
223 
229  parent::modifyContentAndDeleteFileReference();
230  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
231  $this->assertAssertionDataSet('modifyContentNDeleteFileReference');
232 
233  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
234  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
235  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
236  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper')->setStrict(TRUE));
237  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
238  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
239  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
240  }
241 
247  parent::modifyContentAndDeleteAllFileReference();
248  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
249  $this->assertAssertionDataSet('modifyContentNDeleteAllFileReference');
250 
251  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
252  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
253  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
254  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
255  }
256 
257 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=TRUE)