3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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';
30 * Class WebTest_Contact_SignatureTest
32 class WebTest_Contact_SignatureTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
39 * Test Signature in CKEditor.
41 public function testCKEditor() {
42 $this->webtestLogin();
44 $this->openCiviPage('dashboard', 'reset=1', 'crm-recently-viewed');
45 $this->click("//div[@id='crm-recently-viewed']/ul/li/a");
46 $this->waitForPageToLoad($this->getTimeoutMsec());
47 $name = $this->getText("xpath=//div[@class='crm-summary-display_name']");
49 // Get contact id from url.
50 $contactId = $this->urlArg('cid');
53 $this->_selectEditor('CKEditor');
55 $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}");
56 $this->click("//tr[@id='Email_Block_1']/td[1]/div[3]/div[1]");
58 // HTML format message
59 $signature = 'Contact Signature in html';
60 $this->fireEvent('email_1_signature_html', 'focus');
61 $this->fillRichTextField('email_1_signature_html', $signature, 'CKEditor');
63 // TEXT Format Message
64 $this->type('email_1_signature_text', 'Contact Signature in text');
65 $this->click('_qf_Contact_upload_view-top');
66 $this->waitForPageToLoad($this->getTimeoutMsec());
68 // Is status message correct?
69 $this->waitForText('crm-notification-container', "{$name} has been updated.");
71 // Go for Ckeck Your Editor, Click on Send Mail
72 $this->click("//a[@id='crm-contact-actions-link']/span");
73 $this->clickLink('link=Send an Email', 'subject', FALSE);
75 $this->click('subject');
76 $subject = 'Subject_' . substr(sha1(rand()), 0, 7);
77 $this->type('subject', $subject);
79 // Is signature correct? in Editor
80 $this->_checkSignature('html_message', $signature, 'CKEditor');
82 $this->click('_qf_Email_upload-top');
83 $this->waitForElementPresent("//a[@id='crm-contact-actions-link']/span");
85 // Go for Activity Search
86 $this->_checkActivity($subject, $signature);
90 * Helper function to select Editor.
93 public function _selectEditor($editor) {
94 $this->openCiviPage('admin/setting/preferences/display', 'reset=1');
96 // Change editor if not already selected
97 if ($this->getSelectedLabel('editor_id') != $editor) {
98 $this->click('editor_id');
99 $this->select('editor_id', "label=$editor");
100 $this->click('_qf_Display_next-bottom');
101 $this->waitForPageToLoad($this->getTimeoutMsec());
106 * Helper function for Check Signature in Editor.
111 public function _checkSignature($fieldName, $signature, $editor) {
112 if ($editor == 'CKEditor') {
113 $this->waitForElementPresent("xpath=//div[@id='cke_{$fieldName}']//iframe");
114 $this->selectFrame("xpath=//div[@id='cke_{$fieldName}']//iframe");
117 $this->selectFrame("xpath=//iframe[@id='{$fieldName}_ifr']");
120 $this->verifyText('//html/body', preg_quote("{$signature}"));
121 $this->selectFrame('relative=top');
125 * Helper function for Check Signature in Activity.
129 public function _checkActivity($subject, $signature) {
130 $this->openCiviPage('activity/search', 'reset=1', '_qf_Search_refresh');
132 $this->type('activity_subject', $subject);
134 $this->clickLink('_qf_Search_refresh', 'Search');
136 // View your Activity
137 $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);
139 // Is signature correct? in Activity
140 $this->assertTextPresent($signature);