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 | 52 | |
44c45561 | 53 | $this->click("//tr[@id='Email_Block_1']/td[1]/div[3]/div[1]"); |
6a488035 TO |
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 | 70 | //after clicking on 'Send an Email', wait for the text in tinymce editor to load |
44c45561 | 71 | $this->clickLink('link=Send an Email', "xpath=//body[@id='tinymce']/p[2]", FALSE); |
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'); | |
6a488035 TO |
81 | |
82 | // Go for Activity Search | |
83 | $this->_checkActivity($subject, $signature); | |
efb29358 CW |
84 | |
85 | // Set Editor back to default so we don't break other tests | |
86 | $this->_selectEditor('CKEditor'); | |
6a488035 TO |
87 | } |
88 | ||
efb29358 | 89 | /** |
6a488035 TO |
90 | * Test Signature in CKEditor. |
91 | */ | |
92 | function testCKEditor() { | |
93 | $this->webtestLogin(); | |
94 | ||
95 | $this->openCiviPage('dashboard', 'reset=1', 'crm-recently-viewed'); | |
96 | $this->click("//div[@id='crm-recently-viewed']/ul/li/a"); | |
97 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
98 | $name = $this->getText("xpath=//div[@class='crm-summary-display_name']"); | |
99 | ||
100 | // Get contact id from url. | |
a471a3b6 | 101 | $contactId = $this->urlArg('cid'); |
6a488035 TO |
102 | |
103 | // Select Your Editor | |
104 | $this->_selectEditor('CKEditor'); | |
105 | ||
69369531 | 106 | $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}"); |
44c45561 | 107 | $this->click("//tr[@id='Email_Block_1']/td[1]/div[3]/div[1]"); |
efb29358 | 108 | |
6a488035 TO |
109 | // HTML format message |
110 | $signature = 'Contact Signature in html'; | |
111 | $this->fireEvent('email_1_signature_html', 'focus'); | |
112 | $this->fillRichTextField('email_1_signature_html', $signature, 'CKEditor'); | |
113 | ||
114 | // TEXT Format Message | |
115 | $this->type('email_1_signature_text', 'Contact Signature in text'); | |
116 | $this->click('_qf_Contact_upload_view-top'); | |
117 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
118 | ||
119 | // Is status message correct? | |
6c5f7368 | 120 | $this->waitForText('crm-notification-container', "{$name} has been updated."); |
6a488035 TO |
121 | |
122 | // Go for Ckeck Your Editor, Click on Send Mail | |
123 | $this->click("//a[@id='crm-contact-actions-link']/span"); | |
44c45561 | 124 | $this->clickLink('link=Send an Email', 'subject', FALSE); |
6a488035 TO |
125 | |
126 | $this->click('subject'); | |
127 | $subject = 'Subject_' . substr(sha1(rand()), 0, 7); | |
128 | $this->type('subject', $subject); | |
129 | ||
130 | // Is signature correct? in Editor | |
131 | $this->_checkSignature('html_message', $signature, 'CKEditor'); | |
132 | ||
133 | $this->click('_qf_Email_upload-top'); | |
44c45561 | 134 | $this->waitForElementPresent("//a[@id='crm-contact-actions-link']/span"); |
6a488035 TO |
135 | |
136 | // Go for Activity Search | |
137 | $this->_checkActivity($subject, $signature); | |
138 | } | |
139 | ||
efb29358 | 140 | /** |
6a488035 TO |
141 | * Helper function to select Editor. |
142 | */ | |
143 | function _selectEditor($editor) { | |
69369531 | 144 | $this->openCiviPage('admin/setting/preferences/display', 'reset=1'); |
6a488035 | 145 | |
efb29358 CW |
146 | // Change editor if not already selected |
147 | if ($this->getSelectedLabel('editor_id') != $editor) { | |
148 | $this->click('editor_id'); | |
149 | $this->select('editor_id', "label=$editor"); | |
150 | $this->click('_qf_Display_next-bottom'); | |
151 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
152 | } | |
6a488035 | 153 | } |
efb29358 CW |
154 | |
155 | /** | |
6a488035 TO |
156 | * Helper function for Check Signature in Editor. |
157 | */ | |
158 | function _checkSignature($fieldName, $signature, $editor) { | |
159 | if ($editor == 'CKEditor') { | |
160 | $this->waitForElementPresent("xpath=//div[@id='cke_{$fieldName}']//iframe"); | |
161 | $this->selectFrame("xpath=//div[@id='cke_{$fieldName}']//iframe"); | |
162 | } | |
163 | else { | |
164 | $this->selectFrame("xpath=//iframe[@id='{$fieldName}_ifr']"); | |
165 | } | |
166 | ||
167 | $this->verifyText('//html/body', preg_quote("{$signature}")); | |
168 | $this->selectFrame('relative=top'); | |
169 | } | |
efb29358 CW |
170 | |
171 | /** | |
6a488035 TO |
172 | * Helper function for Check Signature in Activity. |
173 | */ | |
174 | function _checkActivity($subject, $signature) { | |
175 | $this->openCiviPage('activity/search', 'reset=1', '_qf_Search_refresh'); | |
176 | ||
177 | $this->type('activity_subject', $subject); | |
178 | ||
225a8648 | 179 | $this->clickLink('_qf_Search_refresh', 'Search'); |
6a488035 TO |
180 | |
181 | // View your Activity | |
44c45561 | 182 | $this->clickLink("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']", '_qf_ActivityView_cancel-bottom', FALSE); |
6a488035 TO |
183 | |
184 | // Is signature correct? in Activity | |
efb29358 | 185 | $this->assertTextPresent($signature); |
6a488035 TO |
186 | } |
187 | } | |
188 |