Commit | Line | Data |
---|---|---|
8b7ce8d7 | 1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
8b7ce8d7 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
8b7ce8d7 | 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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
8b7ce8d7 | 26 | |
27 | /** | |
eac2f71b | 28 | * Description of AddRecurringActivityTest |
8b7ce8d7 | 29 | * |
30 | * @author Priyanka | |
31 | */ | |
32 | ||
33 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
34 | ||
7fe37828 EM |
35 | /** |
36 | * Class WebTest_Activity_AddRecurringActivityTest | |
37 | */ | |
eac2f71b | 38 | class WebTest_Activity_AddRecurringActivityTest extends CiviSeleniumTestCase { |
8b7ce8d7 | 39 | |
40 | protected function setUp() { | |
41 | parent::setUp(); | |
42 | } | |
43 | ||
00be9182 | 44 | public function testRecurringActivity() { |
8b7ce8d7 | 45 | $this->webtestLogin(); |
46 | ||
47 | //Adding new contact | |
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"); | |
52 | ||
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"); | |
56 | ||
57 | //Add a new contact | |
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); | |
62 | ||
63 | // ...waiting for drop down with results to show up... | |
64 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); | |
65 | ||
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']"); | |
6c6e6187 | 68 | $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$contact1"); |
8b7ce8d7 | 69 | $this->assertElementContainsText("xpath=//div[@id='s2id_target_contact_id']", "Karan, $contact1", 'Contact not found in line ' . __LINE__); |
70 | ||
8b7ce8d7 | 71 | //Assigned To field |
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); | |
76 | ||
77 | // ...waiting for drop down with results to show up... | |
78 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); | |
79 | ||
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']"); | |
82 | ||
83 | // ...again, waiting for the box with contact name to show up... | |
6c6e6187 | 84 | $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$contact2"); |
8b7ce8d7 | 85 | |
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__); | |
88 | ||
df519dcf | 89 | if ($this->isTextPresent("A copy of this activity will be emailed to each Assignee.")) { |
90 | $isAssigneeNotificationEnabled = TRUE; | |
91 | } | |
92 | ||
93 | $subject = "Test activity recursion " . substr(sha1(rand()), 0, 7); | |
8b7ce8d7 | 94 | $this->type("subject", $subject); |
95 | $this->type("duration", "30"); | |
96 | ||
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'); | |
df519dcf | 100 | $this->select('repetition_frequency_unit', 'label=month'); |
8b7ce8d7 | 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'); | |
107 | ||
108 | $occurrences = rand(3, 5); | |
109 | if (!$occurrences) { | |
110 | $occurrences = 3; | |
111 | } | |
112 | $this->type('start_action_offset', $occurrences); | |
113 | $this->click('_qf_Activity_upload-bottom'); | |
c0c937ab | 114 | $this->waitForTextPresent('A repeating set will be created with the following dates.'); |
df519dcf | 115 | |
116 | $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Continue']"); | |
8b7ce8d7 | 117 | $this->waitForPageToLoad(); |
118 | ||
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'); | |
df519dcf | 121 | $this->type('activity_subject', $subject); |
8b7ce8d7 | 122 | $this->click('_qf_Search_refresh'); |
123 | $this->waitForPageToLoad(); | |
124 | ||
125 | //Minus tr having th and parent activity | |
126 | $countOfActivities = $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr"); | |
127 | $countOfActivities = $countOfActivities - 2; | |
df519dcf | 128 | |
129 | if (!empty($isAssigneeNotificationEnabled)) { | |
130 | $countOfActivities--; | |
131 | } | |
132 | ||
8b7ce8d7 | 133 | $this->assertEquals($occurrences, $countOfActivities); |
04374d9d | 134 | $this->assertTrue($this->isTextPresent("Repeating")); |
327b6726 | 135 | |
136 | //Cascade changes | |
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']"); | |
df519dcf | 139 | $this->type('subject', "{$subject} modified"); |
327b6726 | 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']"); | |
df519dcf | 142 | $this->click("xpath=//input[@id='recur-this-and-all-following-entity']"); |
327b6726 | 143 | $this->waitForAjaxContent(); |
df519dcf | 144 | $this->type('activity_subject', "{$subject} modified"); |
327b6726 | 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'); | |
151 | } | |
152 | } | |
8b7ce8d7 | 153 | } |
154 | ||
155 | } |