Commit | Line | Data |
---|---|---|
6a488035 TO |
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->open($this->sboxPath); | |
37 | $this->webtestLogin(); | |
38 | ||
39 | // ADD a New Group | |
40 | $this->open($this->sboxPath . "civicrm/group/add?reset=1"); | |
41 | $this->waitForElementPresent("_qf_Edit_upload"); | |
42 | ||
43 | $smsGroupName = 'group_' . substr(sha1(rand()), 0, 7); | |
44 | ||
45 | $this->type("title", $smsGroupName); | |
46 | $this->type("description", "New sms group for Webtest"); | |
47 | $this->select("visibility", "value=Public Pages"); | |
48 | ||
49 | $this->click("_qf_Edit_upload"); | |
50 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
51 | ||
52 | // ADD contact1 | |
53 | $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); | |
54 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
55 | $firstName = substr(sha1(rand()), 0, 7); | |
56 | $this->type('first_name', $firstName); | |
57 | ||
58 | $lastName = substr(sha1(rand()), 0, 7); | |
59 | $this->type('last_name', $lastName); | |
60 | ||
61 | $this->waitForElementPresent('phone_1_phone'); | |
62 | $this->type('phone_1_phone', "911234567890"); | |
63 | ||
64 | $this->select('phone_1_phone_type_id', 'label=Mobile'); | |
65 | ||
66 | $this->click("_qf_Contact_upload_view"); | |
67 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
68 | $this->assertElementContainsText('crm-notification-container', "Contact Saved"); | |
69 | ||
70 | $this->click('css=li#tab_group a'); | |
71 | $this->waitForElementPresent('_qf_GroupContact_next'); | |
72 | $this->select('group_id', "label=$smsGroupName"); | |
73 | $this->click('_qf_GroupContact_next'); | |
74 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
75 | $this->assertElementContainsText('crm-notification-container', "Added to Group"); | |
76 | ||
77 | // ADD contact2 | |
78 | $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); | |
79 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
80 | $firstName = substr(sha1(rand()), 0, 7); | |
81 | $this->type('first_name', $firstName); | |
82 | ||
83 | $lastName = substr(sha1(rand()), 0, 7); | |
84 | $this->type('last_name', $lastName); | |
85 | ||
86 | $this->waitForElementPresent('phone_1_phone'); | |
87 | $this->type('phone_1_phone', "911234567891"); | |
88 | ||
89 | $this->select('phone_1_phone_type_id', 'label=Mobile'); | |
90 | ||
91 | $this->click("_qf_Contact_upload_view"); | |
92 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
93 | $this->assertElementContainsText('crm-notification-container', "Contact Saved"); | |
94 | ||
95 | $this->click('css=li#tab_group a'); | |
96 | $this->waitForElementPresent('_qf_GroupContact_next'); | |
97 | $this->select('group_id', "label=$smsGroupName"); | |
98 | $this->click('_qf_GroupContact_next'); | |
99 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
100 | $this->assertElementContainsText('crm-notification-container', "Added to Group"); | |
101 | ||
102 | // Do an advanced search | |
103 | $this->click("css=ul#civicrm-menu li.crm-Search"); | |
104 | $this->click("css=ul#civicrm-menu li.crm-Advanced_Search a"); | |
105 | ||
106 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
107 | $this->waitForElementPresent("email"); | |
108 | ||
109 | $this->select("crmasmSelect1", "label=$smsGroupName"); | |
110 | ||
111 | $this->click("_qf_Advanced_refresh"); | |
112 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
113 | ||
114 | $this->waitForElementPresent('CIVICRM_QFID_ts_all_12'); | |
115 | $this->click('CIVICRM_QFID_ts_all_12'); | |
116 | ||
117 | // Perform a task action | |
118 | $this->select("task", "label=Send SMS to Contacts"); | |
119 | $this->click("Go"); | |
120 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
121 | ||
122 | $this->waitForElementPresent('activity_subject'); | |
123 | $this->type('activity_subject', "Send SMS to Contacts of {$smsGroupName}"); | |
124 | $this->type('text_message', "Test SMS to Contacts of {$smsGroupName}"); | |
125 | $this->click("_qf_SMS_upload-bottom"); | |
126 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
127 | ||
128 | $this->assertTrue($this->isTextPresent('Your message has been sent.'), "Test SMS could not be sent!"); | |
129 | } | |
130 | } | |
131 | ||
132 |