3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Contact_SignatureTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
35 * Test Signature in TinyMC.
37 function testTinyMCE() {
38 $this->webtestLogin();
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']");
45 // Get contact id from url.
46 $contactId = $this->urlArg('cid');
49 $this->_selectEditor('TinyMCE');
51 $this->openCiviPage("contact/add", "reset=1&action=update&cid=$contactId");
53 $this->click("//tr[@id='Email_Block_1']/td[1]/div[3]/div[1]");
54 // HTML format message
55 $signature = 'Contact Signature in html';
57 $this->fireEvent('email_1_signature_html', 'focus');
58 $this->fillRichTextField('email_1_signature_html', $signature, 'TinyMCE');
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());
65 // Is status message correct?
66 $this->waitForText('crm-notification-container', "Contact Saved");
68 // Go for Ckeck Your Editor, Click on Send Mail
69 $this->click("//a[@id='crm-contact-actions-link']/span");
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]", FALSE);
73 $this->click('subject');
74 $subject = 'Subject_' . substr(sha1(rand()), 0, 8);
75 $this->type('subject', $subject);
77 // Is signature correct? in Editor
78 $this->_checkSignature('html_message', $signature, 'TinyMCE');
80 $this->click('_qf_Email_upload-top');
82 // Go for Activity Search
83 $this->_checkActivity($subject, $signature);
85 // Set Editor back to default so we don't break other tests
86 $this->_selectEditor('CKEditor');
90 * Test Signature in CKEditor.
92 function testCKEditor() {
93 $this->webtestLogin();
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']");
100 // Get contact id from url.
101 $contactId = $this->urlArg('cid');
103 // Select Your Editor
104 $this->_selectEditor('CKEditor');
106 $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}");
107 $this->click("//tr[@id='Email_Block_1']/td[1]/div[3]/div[1]");
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');
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());
119 // Is status message correct?
120 $this->waitForText('crm-notification-container', "{$name} has been updated.");
122 // Go for Ckeck Your Editor, Click on Send Mail
123 $this->click("//a[@id='crm-contact-actions-link']/span");
124 $this->clickLink('link=Send an Email', 'subject', FALSE);
126 $this->click('subject');
127 $subject = 'Subject_' . substr(sha1(rand()), 0, 7);
128 $this->type('subject', $subject);
130 // Is signature correct? in Editor
131 $this->_checkSignature('html_message', $signature, 'CKEditor');
133 $this->click('_qf_Email_upload-top');
134 $this->waitForElementPresent("//a[@id='crm-contact-actions-link']/span");
136 // Go for Activity Search
137 $this->_checkActivity($subject, $signature);
141 * Helper function to select Editor.
143 function _selectEditor($editor) {
144 $this->openCiviPage('admin/setting/preferences/display', 'reset=1');
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());
156 * Helper function for Check Signature in Editor.
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");
164 $this->selectFrame("xpath=//iframe[@id='{$fieldName}_ifr']");
167 $this->verifyText('//html/body', preg_quote("{$signature}"));
168 $this->selectFrame('relative=top');
172 * Helper function for Check Signature in Activity.
174 function _checkActivity($subject, $signature) {
175 $this->openCiviPage('activity/search', 'reset=1', '_qf_Search_refresh');
177 $this->type('activity_subject', $subject);
179 $this->clickLink('_qf_Search_refresh', 'Search');
181 // View your Activity
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);
184 // Is signature correct? in Activity
185 $this->assertTextPresent($signature);