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