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