Start migrating to use clickLink method
[civicrm-core.git] / tests / phpunit / WebTest / Contact / TaskActionSendSMS.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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
27
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contact_TaskActionSendSMS extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testSMSToContacts() {
36 $this->webtestLogin();
37
38 // ADD a New Group
39 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
40
41 $smsGroupName = 'group_' . substr(sha1(rand()), 0, 7);
42
43 $this->type("title", $smsGroupName);
44 $this->type("description", "New sms group for Webtest");
45 $this->select("visibility", "value=Public Pages");
46
47 $this->click("_qf_Edit_upload");
48 $this->waitForPageToLoad($this->getTimeoutMsec());
49
50 // ADD contact1
51 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
52 $firstName = substr(sha1(rand()), 0, 7);
53 $this->type('first_name', $firstName);
54
55 $lastName = substr(sha1(rand()), 0, 7);
56 $this->type('last_name', $lastName);
57
58 $this->waitForElementPresent('phone_1_phone');
59 $this->type('phone_1_phone', "911234567890");
60
61 $this->select('phone_1_phone_type_id', 'label=Mobile');
62
63 $this->click("_qf_Contact_upload_view");
64 $this->waitForPageToLoad($this->getTimeoutMsec());
65 $this->assertElementContainsText('crm-notification-container', "Contact Saved");
66
67 $this->click('css=li#tab_group a');
68 $this->waitForElementPresent('_qf_GroupContact_next');
69 $this->select('group_id', "label=$smsGroupName");
70 $this->click('_qf_GroupContact_next');
71 $this->waitForPageToLoad($this->getTimeoutMsec());
72 $this->assertElementContainsText('crm-notification-container', "Added to Group");
73
74 // ADD contact2
75 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
76 $firstName = substr(sha1(rand()), 0, 7);
77 $this->type('first_name', $firstName);
78
79 $lastName = substr(sha1(rand()), 0, 7);
80 $this->type('last_name', $lastName);
81
82 $this->waitForElementPresent('phone_1_phone');
83 $this->type('phone_1_phone', "911234567891");
84
85 $this->select('phone_1_phone_type_id', 'label=Mobile');
86
87 $this->click("_qf_Contact_upload_view");
88 $this->waitForPageToLoad($this->getTimeoutMsec());
89 $this->assertElementContainsText('crm-notification-container', "Contact Saved");
90
91 $this->click('css=li#tab_group a');
92 $this->waitForElementPresent('_qf_GroupContact_next');
93 $this->select('group_id', "label=$smsGroupName");
94 $this->click('_qf_GroupContact_next');
95 $this->waitForPageToLoad($this->getTimeoutMsec());
96 $this->assertElementContainsText('crm-notification-container', "Added to Group");
97
98 // Do an advanced search
99 $this->click("css=ul#civicrm-menu li.crm-Search");
100 $this->clickLink("css=ul#civicrm-menu li.crm-Advanced_Search a", "email");
101
102 $this->select("crmasmSelect1", "label=$smsGroupName");
103
104 $this->clickLink("_qf_Advanced_refresh", 'CIVICRM_QFID_ts_all_12');
105 $this->click('CIVICRM_QFID_ts_all_12');
106
107 // Perform a task action
108 $this->select("task", "label=Send SMS to Contacts");
109 $this->clickLink("Go", 'activity_subject');
110 $this->type('activity_subject', "Send SMS to Contacts of {$smsGroupName}");
111 $this->type('text_message', "Test SMS to Contacts of {$smsGroupName}");
112 $this->click("_qf_SMS_upload-bottom");
113 $this->waitForPageToLoad($this->getTimeoutMsec());
114
115 $this->assertTrue($this->isTextPresent('Your message has been sent.'), "Test SMS could not be sent!");
116 }
117 }
118
119