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/ManyToMany/Publish/DataSet/';
28 
37  public function addCategoryRelation() {
38  parent::addCategoryRelation();
39  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
40  $this->assertAssertionDataSet('addCategoryRelation');
41 
42  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
43  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
44  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
45  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B', 'Category A.A'));
46  }
47 
52  public function deleteCategoryRelation() {
53  parent::deleteCategoryRelation();
54  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
55  $this->assertAssertionDataSet('deleteCategoryRelation');
56 
57  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
58  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
59  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
60  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
61  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
62  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
63  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
64  }
65 
70  public function changeCategoryRelationSorting() {
71  parent::changeCategoryRelationSorting();
72  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
73  $this->assertAssertionDataSet('changeCategoryRelationSorting');
74 
75  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
76  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
77  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
78  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
79  }
80 
85  public function createContentAndAddRelation() {
86  parent::createContentAndAddRelation();
87  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
88  $this->assertAssertionDataSet('createContentNAddRelation');
89 
90  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
91  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
92  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
93  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
94  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
95  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B'));
96  }
97 
102  public function createCategoryAndAddRelation() {
103  parent::createCategoryAndAddRelation();
104  $this->actionService->publishRecord(self::TABLE_Category, $this->recordIds['newCategoryId']);
105  $this->assertAssertionDataSet('createCategoryNAddRelation');
106 
107  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
108  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
109  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
110  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
111  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
112  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
113  }
114 
119  public function createContentAndCreateRelation() {
120  parent::createContentAndCreateRelation();
121  $this->actionService->publishRecords(
122  array(
123  self::TABLE_Category => array($this->recordIds['newCategoryId']),
124  self::TABLE_Content => array($this->recordIds['newContentId']),
125  )
126  );
127  $this->assertAssertionDataSet('createContentNCreateRelation');
128 
129  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
130  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
131  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
132  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
133  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
134  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
135  }
136 
142  parent::createCategoryAndCreateRelation();
143  $this->actionService->publishRecords(
144  array(
145  self::TABLE_Content => array($this->recordIds['newContentId']),
146  self::TABLE_Category => array($this->recordIds['newCategoryId']),
147  )
148  );
149  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
150  $this->assertAssertionDataSet('createCategoryNCreateRelation');
151  }
152 
157  public function modifyCategoryOfRelation() {
158  parent::modifyCategoryOfRelation();
159  $this->actionService->publishRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
160  $this->assertAssertionDataSet('modifyCategoryOfRelation');
161 
162  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
163  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
164  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
165  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
166  }
167 
172  public function modifyContentOfRelation() {
173  parent::modifyContentOfRelation();
174  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
175  $this->assertAssertionDataSet('modifyContentOfRelation');
176 
177  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
178  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
179  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
180  }
181 
186  public function modifyBothsOfRelation() {
187  parent::modifyBothsOfRelation();
188  $this->actionService->publishRecords(
189  array(
190  self::TABLE_Content => array(self::VALUE_ContentIdFirst),
191  self::TABLE_Category => array(self::VALUE_CategoryIdFirst),
192  )
193  );
194  $this->assertAssertionDataSet('modifyBothsOfRelation');
195 
196  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
197  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
198  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
199  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
200  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
201  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
202  }
203 
208  public function deleteContentOfRelation() {
209  parent::deleteContentOfRelation();
210  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
211  $this->assertAssertionDataSet('deleteContentOfRelation');
212 
213  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
214  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
215  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
216  }
217 
222  public function deleteCategoryOfRelation() {
223  parent::deleteCategoryOfRelation();
224  $this->actionService->publishRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
225  $this->assertAssertionDataSet('deleteCategoryOfRelation');
226 
227  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
228  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
229  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
230  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
231  }
232 
237  public function copyContentOfRelation() {
238  parent::copyContentOfRelation();
239  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
240  $this->assertAssertionDataSet('copyContentOfRelation');
241 
242  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
243  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
244  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
245  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
246  }
247 
252  public function copyCategoryOfRelation() {
253  parent::copyCategoryOfRelation();
254  $this->actionService->publishRecord(self::TABLE_Category, $this->recordIds['newCategoryId']);
255  $this->assertAssertionDataSet('copyCategoryOfRelation');
256 
257  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
258  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
259  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
260  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category A (copy 1)'));
261  }
262 
267  public function localizeContentOfRelation() {
268  parent::localizeContentOfRelation();
269  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
270  $this->assertAssertionDataSet('localizeContentOfRelation');
271 
272  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
273  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
274  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
275  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
276  }
277 
282  public function localizeCategoryOfRelation() {
283  parent::localizeCategoryOfRelation();
284  $this->actionService->publishRecord(self::TABLE_Category, $this->recordIds['localizedCategoryId']);
285  $this->assertAssertionDataSet('localizeCategoryOfRelation');
286 
287  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
288  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
289  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
290  ->setTable(self::TABLE_Category)->setField('title')->setValues('[Translate to Dansk:] Category A', 'Category B'));
291  }
292 
298  parent::moveContentOfRelationToDifferentPage();
299  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
300  $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
301 
302  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
303  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
304  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
305  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
306  }
307 
312  public function copyPage() {
313  parent::copyPage();
314  $this->actionService->publishRecords(
315  array(
316  self::TABLE_Page => array($this->recordIds['newPageId']),
317  self::TABLE_Content => array($this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']),
318  )
319  );
320  $this->assertAssertionDataSet('copyPage');
321 
322  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseSections();
323  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
324  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
325  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
326  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
327  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
328  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'])->setRecordField('categories')
329  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
330  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
331  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'])->setRecordField('categories')
332  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
333  }
334 
335 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=TRUE)