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 +--------------------------------------------------------------------+
28 * Description of AddRecurringActivityTest
33 require_once 'CiviTest/CiviSeleniumTestCase.php';
36 * Class WebTest_Activity_AddRecurringActivityTest
38 class WebTest_Activity_AddRecurringActivityTest
extends CiviSeleniumTestCase
{
40 protected function setUp() {
44 public function testRecurringActivity() {
45 $this->webtestLogin();
48 $contact1 = substr(sha1(rand()), 0, 7);
49 $this->webtestAddContact("$contact1", "Karan", $contact1 . "@exampleone.com");
50 $contact2 = substr(sha1(rand()), 0, 7);
51 $this->webtestAddContact("$contact2", "Jane", $contact2 . "@exampletwo.com");
53 //Lets create an activity and add repeat configuration
54 $this->openCiviPage("activity", "?reset=1&action=add&context=standalone", '_qf_Activity_cancel-bottom');
55 $this->select("activity_type_id", "value=1");
58 $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input");
59 $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " ");
60 $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contact1);
61 $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contact1);
63 // ...waiting for drop down with results to show up...
64 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
66 // ...need to use mouseDownAt on first result (which is a li element), click does not work
67 $this->clickAt("xpath=//div[@class='select2-result-label']");
68 $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$contact1");
69 $this->assertElementContainsText("xpath=//div[@id='s2id_target_contact_id']", "Karan, $contact1", 'Contact not found in line ' . __LINE__
);
72 $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
73 $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
74 $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contact2);
75 $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contact2);
77 // ...waiting for drop down with results to show up...
78 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
80 //..need to use mouseDownAt on first result (which is a li element), click does not work
81 $this->clickAt("xpath=//div[@class='select2-result-label']");
83 // ...again, waiting for the box with contact name to show up...
84 $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$contact2");
86 // ...and verifying if the page contains properly formatted display name for chosen contact.
87 $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Jane, $contact2", 'Contact not found in line ' . __LINE__
);
89 if ($this->isTextPresent("A copy of this activity will be emailed to each Assignee.")) {
90 $isAssigneeNotificationEnabled = TRUE;
93 $subject = "Test activity recursion " . substr(sha1(rand()), 0, 7);
94 $this->type("subject", $subject);
95 $this->type("duration", "30");
97 //Lets configure recursion for activity
98 $this->click("css=.crm-activity-form-block-recurring_activity div.crm-accordion-header");
99 $this->click('repetition_frequency_unit');
100 $this->select('repetition_frequency_unit', 'label=month');
101 $this->click('repetition_frequency_interval');
102 $this->select('repetition_frequency_interval', 'label=1');
103 $this->click('CIVICRM_QFID_1_repeats_by');
104 $this->click('limit_to');
105 $this->select('limit_to', 'label=26');
106 $this->click('CIVICRM_QFID_1_ends');
108 $occurrences = rand(3, 5);
112 $this->type('start_action_offset', $occurrences);
113 $this->click('_qf_Activity_upload-bottom');
114 $this->waitForTextPresent('A repeating set will be created with the following dates.');
116 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Continue']");
117 $this->waitForPageToLoad();
119 //Lets go to search screen and see if the records new activities are created()
120 $this->openCiviPage("activity/search", "?reset=1", '_qf_Search_refresh');
121 $this->type('activity_subject', $subject);
122 $this->click('_qf_Search_refresh');
123 $this->waitForPageToLoad();
125 //Minus tr having th and parent activity
126 $countOfActivities = $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr");
127 $countOfActivities = $countOfActivities - 2;
129 if (!empty($isAssigneeNotificationEnabled)) {
130 $countOfActivities--;
133 $this->assertEquals($occurrences, $countOfActivities);
134 $this->assertTrue($this->isTextPresent("Repeating"));
137 $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td/span/a[text()='Edit']");
138 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
139 $this->type('subject', "{$subject} modified");
140 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
141 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
142 $this->click("xpath=//input[@id='recur-this-and-all-following-entity']");
143 $this->waitForAjaxContent();
144 $this->type('activity_subject', "{$subject} modified");
145 $this->click('_qf_Search_refresh');
146 $this->waitForPageToLoad();
147 $countOfActivities = $this->getXpathCount("xpath=//div[@class='crm-search-results']/table/tbody/tr");
148 if ($countOfActivities) {
149 for ($i = 0; $i <= $countOfActivities; $i++
) {
150 $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[3]", 'Test activity recursion modified');