8b7ce8d7 |
1 | <?php |
2 | /* |
3 | +--------------------------------------------------------------------+ |
39de6fd5 |
4 | | CiviCRM version 4.6 | |
8b7ce8d7 |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | /** |
eac2f71b |
28 | * Description of AddRecurringActivityTest |
8b7ce8d7 |
29 | * |
30 | * @author Priyanka |
31 | */ |
32 | |
33 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
34 | |
eac2f71b |
35 | class WebTest_Activity_AddRecurringActivityTest extends CiviSeleniumTestCase { |
8b7ce8d7 |
36 | |
37 | protected function setUp() { |
38 | parent::setUp(); |
39 | } |
40 | |
00be9182 |
41 | public function testRecurringActivity() { |
8b7ce8d7 |
42 | $this->webtestLogin(); |
43 | |
44 | //Adding new contact |
45 | $contact1 = substr(sha1(rand()), 0, 7); |
46 | $this->webtestAddContact("$contact1", "Karan", $contact1 . "@exampleone.com"); |
47 | $contact2 = substr(sha1(rand()), 0, 7); |
48 | $this->webtestAddContact("$contact2", "Jane", $contact2 . "@exampletwo.com"); |
49 | |
50 | //Lets create an activity and add repeat configuration |
51 | $this->openCiviPage("activity", "?reset=1&action=add&context=standalone", '_qf_Activity_cancel-bottom'); |
52 | $this->select("activity_type_id", "value=1"); |
53 | |
54 | //Add a new contact |
55 | $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input"); |
56 | $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " "); |
57 | $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contact1); |
58 | $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contact1); |
59 | |
60 | // ...waiting for drop down with results to show up... |
61 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
62 | |
63 | // ...need to use mouseDownAt on first result (which is a li element), click does not work |
64 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
6c6e6187 |
65 | $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$contact1"); |
8b7ce8d7 |
66 | $this->assertElementContainsText("xpath=//div[@id='s2id_target_contact_id']", "Karan, $contact1", 'Contact not found in line ' . __LINE__); |
67 | |
8b7ce8d7 |
68 | //Assigned To field |
69 | $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input"); |
70 | $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " "); |
71 | $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contact2); |
72 | $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contact2); |
73 | |
74 | // ...waiting for drop down with results to show up... |
75 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
76 | |
77 | //..need to use mouseDownAt on first result (which is a li element), click does not work |
78 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
79 | |
80 | // ...again, waiting for the box with contact name to show up... |
6c6e6187 |
81 | $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$contact2"); |
8b7ce8d7 |
82 | |
83 | // ...and verifying if the page contains properly formatted display name for chosen contact. |
84 | $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Jane, $contact2", 'Contact not found in line ' . __LINE__); |
85 | |
86 | $subject = "Test activity recursion"; |
87 | $this->type("subject", $subject); |
88 | $this->type("duration", "30"); |
89 | |
90 | //Lets configure recursion for activity |
91 | $this->click("css=.crm-activity-form-block-recurring_activity div.crm-accordion-header"); |
92 | $this->click('repetition_frequency_unit'); |
93 | $this->select('repetition_frequency_unit', 'label=monthly'); |
94 | $this->click('repetition_frequency_interval'); |
95 | $this->select('repetition_frequency_interval', 'label=1'); |
96 | $this->click('CIVICRM_QFID_1_repeats_by'); |
97 | $this->click('limit_to'); |
98 | $this->select('limit_to', 'label=26'); |
99 | $this->click('CIVICRM_QFID_1_ends'); |
100 | |
101 | $occurrences = rand(3, 5); |
102 | if (!$occurrences) { |
103 | $occurrences = 3; |
104 | } |
105 | $this->type('start_action_offset', $occurrences); |
106 | $this->click('_qf_Activity_upload-bottom'); |
fe87e754 |
107 | $this->waitForTextPresent('Based on your repeat configuration, here is the list of dates. Do you wish to create a recurring set with these dates?'); |
8b7ce8d7 |
108 | $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Ok']"); |
109 | $this->waitForPageToLoad(); |
110 | |
111 | //Lets go to search screen and see if the records new activities are created() |
112 | $this->openCiviPage("activity/search", "?reset=1", '_qf_Search_refresh'); |
113 | $search_subject = 'Test activity recursion'; |
114 | $this->type('activity_subject', $search_subject); |
115 | $this->click('_qf_Search_refresh'); |
116 | $this->waitForPageToLoad(); |
117 | |
118 | //Minus tr having th and parent activity |
119 | $countOfActivities = $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr"); |
120 | $countOfActivities = $countOfActivities - 2; |
121 | $this->assertEquals($occurrences, $countOfActivities); |
122 | $this->assertTrue($this->isTextPresent("Recurring Activity - (Child)")); |
123 | $this->assertTrue($this->isTextPresent("Recurring Activity - (Parent)")); |
327b6726 |
124 | |
125 | //Cascade changes |
126 | $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td/span/a[text()='Edit']"); |
127 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']"); |
128 | $this->type('subject', 'Test activity recursion modified'); |
129 | $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']"); |
130 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']"); |
131 | $this->click("xpath=//div[@id='recurring-dialog']/div[@class='show-block']/div[@class='recurring-dialog-inner-wrapper']/div[@class='recurring-dialog-inner-left']/button[text()='This and Following entities']"); |
132 | $this->waitForAjaxContent(); |
133 | $this->type('activity_subject', 'Test activity recursion modified'); |
134 | $this->click('_qf_Search_refresh'); |
135 | $this->waitForPageToLoad(); |
136 | $countOfActivities = $this->getXpathCount("xpath=//div[@class='crm-search-results']/table/tbody/tr"); |
137 | if ($countOfActivities) { |
138 | for ($i = 0; $i <= $countOfActivities; $i++) { |
139 | $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[3]", 'Test activity recursion modified'); |
140 | } |
141 | } |
8b7ce8d7 |
142 | } |
143 | |
144 | } |