Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
efb29358 CW |
34 | /** |
35 | * Test Signature in TinyMC. | |
6a488035 TO |
36 | */ |
37 | function testTinyMCE() { | |
38 | $this->webtestLogin(); | |
39 | ||
40 | $this->openCiviPage('dashboard', 'reset=1', 'crm-recently-viewed'); | |
41 | $this->click("//div[@id='crm-recently-viewed']/ul/li/a"); | |
42 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
43 | $name = $this->getText("xpath=//div[@class='crm-summary-display_name']"); | |
44 | ||
45 | // Get contact id from url. | |
efb29358 | 46 | $contactId = $this->urlArg('cid'); |
6a488035 TO |
47 | |
48 | // Select Your Editor | |
49 | $this->_selectEditor('TinyMCE'); | |
50 | ||
efb29358 | 51 | $this->openCiviPage("contact/add", "reset=1&action=update&cid=$contactId"); |
6a488035 TO |
52 | |
53 | $this->click("//tr[@id='Email_Block_1']/td[1]/div[2]/div[1]"); | |
54 | // HTML format message | |
55 | $signature = 'Contact Signature in html'; | |
56 | ||
57 | $this->fireEvent('email_1_signature_html', 'focus'); | |
58 | $this->fillRichTextField('email_1_signature_html', $signature, 'TinyMCE'); | |
59 | ||
60 | // TEXT Format Message | |
61 | $this->type('email_1_signature_text', 'Contact Signature in text'); | |
62 | $this->click('_qf_Contact_upload_view-top'); | |
63 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
64 | ||
65 | // Is status message correct? | |
6c5f7368 | 66 | $this->waitForText('crm-notification-container', "Contact Saved"); |
6a488035 TO |
67 | |
68 | // Go for Ckeck Your Editor, Click on Send Mail | |
69 | $this->click("//a[@id='crm-contact-actions-link']/span"); | |
ef72146d RN |
70 | //after clicking on 'Send an Email', wait for the text in tinymce editor to load |
71 | $this->clickLink('link=Send an Email', "xpath=//body[@id='tinymce']/p[2]"); | |
6a488035 TO |
72 | |
73 | $this->click('subject'); | |
efb29358 | 74 | $subject = 'Subject_' . substr(sha1(rand()), 0, 8); |
6a488035 TO |
75 | $this->type('subject', $subject); |
76 | ||
77 | // Is signature correct? in Editor | |
78 | $this->_checkSignature('html_message', $signature, 'TinyMCE'); | |
79 | ||
80 | $this->click('_qf_Email_upload-top'); | |
81 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
82 | ||
83 | // Go for Activity Search | |
84 | $this->_checkActivity($subject, $signature); | |
efb29358 CW |
85 | |
86 | // Set Editor back to default so we don't break other tests | |
87 | $this->_selectEditor('CKEditor'); | |
6a488035 TO |
88 | } |
89 | ||
efb29358 | 90 | /** |
6a488035 TO |
91 | * Test Signature in CKEditor. |
92 | */ | |
93 | function testCKEditor() { | |
94 | $this->webtestLogin(); | |
95 | ||
96 | $this->openCiviPage('dashboard', 'reset=1', 'crm-recently-viewed'); | |
97 | $this->click("//div[@id='crm-recently-viewed']/ul/li/a"); | |
98 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
99 | $name = $this->getText("xpath=//div[@class='crm-summary-display_name']"); | |
100 | ||
101 | // Get contact id from url. | |
a471a3b6 | 102 | $contactId = $this->urlArg('cid'); |
6a488035 TO |
103 | |
104 | // Select Your Editor | |
105 | $this->_selectEditor('CKEditor'); | |
106 | ||
69369531 | 107 | $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}"); |
6a488035 | 108 | $this->click("//tr[@id='Email_Block_1']/td[1]/div[2]/div[1]"); |
efb29358 | 109 | |
6a488035 TO |
110 | // HTML format message |
111 | $signature = 'Contact Signature in html'; | |
112 | $this->fireEvent('email_1_signature_html', 'focus'); | |
113 | $this->fillRichTextField('email_1_signature_html', $signature, 'CKEditor'); | |
114 | ||
115 | // TEXT Format Message | |
116 | $this->type('email_1_signature_text', 'Contact Signature in text'); | |
117 | $this->click('_qf_Contact_upload_view-top'); | |
118 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
119 | ||
120 | // Is status message correct? | |
6c5f7368 | 121 | $this->waitForText('crm-notification-container', "{$name} has been updated."); |
6a488035 TO |
122 | |
123 | // Go for Ckeck Your Editor, Click on Send Mail | |
124 | $this->click("//a[@id='crm-contact-actions-link']/span"); | |
225a8648 | 125 | $this->clickLink('link=Send an Email', 'subject'); |
6a488035 TO |
126 | |
127 | $this->click('subject'); | |
128 | $subject = 'Subject_' . substr(sha1(rand()), 0, 7); | |
129 | $this->type('subject', $subject); | |
130 | ||
131 | // Is signature correct? in Editor | |
132 | $this->_checkSignature('html_message', $signature, 'CKEditor'); | |
133 | ||
134 | $this->click('_qf_Email_upload-top'); | |
135 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
136 | ||
137 | // Go for Activity Search | |
138 | $this->_checkActivity($subject, $signature); | |
139 | } | |
140 | ||
efb29358 | 141 | /** |
6a488035 TO |
142 | * Helper function to select Editor. |
143 | */ | |
144 | function _selectEditor($editor) { | |
69369531 | 145 | $this->openCiviPage('admin/setting/preferences/display', 'reset=1'); |
6a488035 | 146 | |
efb29358 CW |
147 | // Change editor if not already selected |
148 | if ($this->getSelectedLabel('editor_id') != $editor) { | |
149 | $this->click('editor_id'); | |
150 | $this->select('editor_id', "label=$editor"); | |
151 | $this->click('_qf_Display_next-bottom'); | |
152 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
153 | } | |
6a488035 | 154 | } |
efb29358 CW |
155 | |
156 | /** | |
6a488035 TO |
157 | * Helper function for Check Signature in Editor. |
158 | */ | |
159 | function _checkSignature($fieldName, $signature, $editor) { | |
160 | if ($editor == 'CKEditor') { | |
161 | $this->waitForElementPresent("xpath=//div[@id='cke_{$fieldName}']//iframe"); | |
162 | $this->selectFrame("xpath=//div[@id='cke_{$fieldName}']//iframe"); | |
163 | } | |
164 | else { | |
165 | $this->selectFrame("xpath=//iframe[@id='{$fieldName}_ifr']"); | |
166 | } | |
167 | ||
168 | $this->verifyText('//html/body', preg_quote("{$signature}")); | |
169 | $this->selectFrame('relative=top'); | |
170 | } | |
efb29358 CW |
171 | |
172 | /** | |
6a488035 TO |
173 | * Helper function for Check Signature in Activity. |
174 | */ | |
175 | function _checkActivity($subject, $signature) { | |
176 | $this->openCiviPage('activity/search', 'reset=1', '_qf_Search_refresh'); | |
177 | ||
178 | $this->type('activity_subject', $subject); | |
179 | ||
225a8648 | 180 | $this->clickLink('_qf_Search_refresh', 'Search'); |
6a488035 TO |
181 | |
182 | // View your Activity | |
225a8648 | 183 | $this->clickLink("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']", '_qf_ActivityView_next-bottom'); |
6a488035 TO |
184 | |
185 | // Is signature correct? in Activity | |
efb29358 | 186 | $this->assertTextPresent($signature); |
6a488035 TO |
187 | } |
188 | } | |
189 |