[TASK] Change namespace of testing framework
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Template / TemplateCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Template;
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
17 use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
18
19 /**
20 * Template tests
21 */
22 class TemplateCest
23 {
24 /**
25 * @param Admin $I
26 * @return void
27 */
28 public function _before(Admin $I)
29 {
30 $I->useExistingSession();
31 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
32 $I->switchToIFrame('list_frame');
33 $I->waitForText('Web Content Management System');
34 $I->switchToIFrame();
35
36 $I->see('Template');
37 $I->click('Template');
38
39 // switch to content iframe
40 $I->switchToIFrame('list_frame');
41 $I->waitForElementVisible('#ts-overview');
42 $I->see('Template tools');
43 }
44
45 /**
46 * @param Admin $I
47 * @return void
48 */
49 public function pagesWithNoTemplateShouldShowButtonsToCreateTemplates(Admin $I)
50 {
51 $I->wantTo('show templates overview on root page (uid = 0)');
52 $I->switchToIFrame();
53 // click on root page
54 $I->click('#extdd-1');
55 $I->switchToIFrame('list_frame');
56 $I->waitForElementVisible('#ts-overview');
57 $I->see('This is an overview of the pages in the database containing one or more template records. Click a page title to go to the page.');
58
59 $I->wantTo('show templates overview on website root page (uid = 1 and pid = 0)');
60 $I->switchToIFrame();
61 // click on website root page
62 $I->click('#extdd-3');
63 $I->switchToIFrame('list_frame');
64 $I->waitForElement('#TypoScriptTemplateModuleController');
65 $I->see('No template');
66 $I->see('There was no template on this page!');
67 $I->see('You need to create a template record below in order to edit your configuration.');
68
69 // @todo These input fields should be changed to buttons. Shoult be changed to propper HTML.
70 $I->seeInFormFields(
71 '#TypoScriptTemplateModuleController',
72 [
73 'newWebsite' => 'Create template for a new site',
74 'createExtension' => 'Click here to create an extension template.',
75 ]
76 );
77 }
78
79 /**
80 * @param Admin $I
81 * @return void
82 */
83 public function addANewSiteTemplate(Admin $I)
84 {
85 $I->wantTo('create a new site template');
86 $I->switchToIFrame();
87 $I->click('#extdd-3');
88 $I->switchToIFrame('list_frame');
89 $I->waitForElement('#TypoScriptTemplateModuleController');
90 $I->click("//input[@name='newWebsite']");
91 $I->waitForElement('#TypoScriptTemplateModuleController');
92 $I->see('Edit constants for template');
93
94 $I->wantTo('change to Info/Modify and see the template overview table');
95 $I->selectOption('.t3-js-jumpMenuBox', 'Info/Modify');
96 $I->waitForElement('.table-fit');
97 $I->see('Title');
98 $I->see('Sitetitle');
99 $I->see('Description');
100 $I->see('Constants');
101 $I->see('Setup');
102 $I->see('Edit the whole template record');
103 $I->click('Edit the whole template record');
104
105 $I->wantTo('change the title and save the template');
106 $I->waitForElement('#EditDocumentController');
107 // fill title input field
108 $I->fillField('//input[@data-formengine-input-name="data[sys_template][1][title]"]', 'Acceptance Test Site');
109 $I->click("//button[@name='_savedok']");
110 $I->waitForElement('#EditDocumentController');
111
112 $I->wantTo('change the setup, save the template and close the form');
113 // grap and fill setup textarea
114 $config = $I->grabTextFrom('//textarea[@data-formengine-input-name="data[sys_template][1][config]"]');
115 $config = str_replace('HELLO WORLD!', 'Hello Acceptance Test!', $config);
116 $I->fillField('//textarea[@data-formengine-input-name="data[sys_template][1][config]"]', $config);
117 $I->click('.btn-toolbar .btn-group.t3js-splitbutton button.btn:nth-child(2)');
118 $I->click('//a[@data-name="_saveandclosedok"]');
119
120 $I->wantTo('see the changed title');
121 $I->waitForElement('.table-fit');
122 $I->see('Acceptance Test Site');
123
124 $I->wantTo('change the template within the TypoScript Object Browser');
125 $I->selectOption('.t3-js-jumpMenuBox', 'TypoScript Object Browser');
126 $I->waitForElement('#TypoScriptTemplateModuleController');
127 $I->see('Current template');
128 $I->see('CONSTANTS ROOT');
129 $I->selectOption('//select[@name="SET[ts_browser_type]"]', 'Setup');
130 $I->waitForElement('#TypoScriptTemplateModuleController');
131 $I->see('SETUP ROOT');
132 // find and open [page] in tree
133 $I->see('[page] = PAGE');
134 $I->click('//span[@class="list-tree-label"]/a[text()=\'page\']/../../../a');
135 $I->waitForElement('#TypoScriptTemplateModuleController');
136 // find and open [page][10] in tree
137 $I->see('[10] = TEXT');
138 $I->click('//span[@class="list-tree-label"]/a[text()=\'page\']/../../../ul//span[@class="list-tree-label"]/a[text()=\'10\']/../../../a');
139 $I->waitForElement('#TypoScriptTemplateModuleController');
140 // find and edit [page][10][value] in tree
141 $I->see('[value] = Hello Acceptance Test!');
142 $I->click('//span[@class="list-tree-label"]/a[text()=\'10\']/../../../ul//span[@class="list-tree-label"]/a[text()=\'value\']');
143 $I->waitForElement('#TypoScriptTemplateModuleController');
144 $I->see('page.10.value =');
145 $I->fillField('//input[@name="data[page.10.value][value]"]', 'HELLO WORLD!');
146 $I->click('//input[@name="update_value"]');
147 $I->waitForElement('#TypoScriptTemplateModuleController');
148 $I->see('Value updated');
149 $I->see('page.10.value = HELLO WORLD!');
150 $I->see('[value] = HELLO WORLD!');
151 }
152 }