Merge pull request #4691 from webaccess/pledge-batchentry
[civicrm-core.git] / tests / phpunit / WebTest / Activity / AddRecurringActivityTest.php
CommitLineData
8b7ce8d7 1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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
33require_once 'CiviTest/CiviSeleniumTestCase.php';
34
eac2f71b 35class WebTest_Activity_AddRecurringActivityTest extends CiviSeleniumTestCase {
8b7ce8d7 36
37 protected function setUp() {
38 parent::setUp();
39 }
40
8b7ce8d7 41 function testRecurringActivity() {
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']");
65 $this->waitForText("xpath=//div[@id='s2id_target_contact_id']","$contact1");
66 $this->assertElementContainsText("xpath=//div[@id='s2id_target_contact_id']", "Karan, $contact1", 'Contact not found in line ' . __LINE__);
67
68
69 //Assigned To field
70 $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
71 $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
72 $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contact2);
73 $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contact2);
74
75 // ...waiting for drop down with results to show up...
76 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
77
78 //..need to use mouseDownAt on first result (which is a li element), click does not work
79 $this->clickAt("xpath=//div[@class='select2-result-label']");
80
81 // ...again, waiting for the box with contact name to show up...
82 $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']","$contact2");
83
84 // ...and verifying if the page contains properly formatted display name for chosen contact.
85 $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Jane, $contact2", 'Contact not found in line ' . __LINE__);
86
87 $subject = "Test activity recursion";
88 $this->type("subject", $subject);
89 $this->type("duration", "30");
90
91 //Lets configure recursion for activity
92 $this->click("css=.crm-activity-form-block-recurring_activity div.crm-accordion-header");
93 $this->click('repetition_frequency_unit');
94 $this->select('repetition_frequency_unit', 'label=monthly');
95 $this->click('repetition_frequency_interval');
96 $this->select('repetition_frequency_interval', 'label=1');
97 $this->click('CIVICRM_QFID_1_repeats_by');
98 $this->click('limit_to');
99 $this->select('limit_to', 'label=26');
100 $this->click('CIVICRM_QFID_1_ends');
101
102 $occurrences = rand(3, 5);
103 if (!$occurrences) {
104 $occurrences = 3;
105 }
106 $this->type('start_action_offset', $occurrences);
107 $this->click('_qf_Activity_upload-bottom');
fe87e754 108 $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 109 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Ok']");
110 $this->waitForPageToLoad();
111
112 //Lets go to search screen and see if the records new activities are created()
113 $this->openCiviPage("activity/search", "?reset=1", '_qf_Search_refresh');
114 $search_subject = 'Test activity recursion';
115 $this->type('activity_subject', $search_subject);
116 $this->click('_qf_Search_refresh');
117 $this->waitForPageToLoad();
118
119 //Minus tr having th and parent activity
120 $countOfActivities = $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr");
121 $countOfActivities = $countOfActivities - 2;
122 $this->assertEquals($occurrences, $countOfActivities);
123 $this->assertTrue($this->isTextPresent("Recurring Activity - (Child)"));
124 $this->assertTrue($this->isTextPresent("Recurring Activity - (Parent)"));
327b6726 125
126 //Cascade changes
127 $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td/span/a[text()='Edit']");
128 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
129 $this->type('subject', 'Test activity recursion modified');
130 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
131 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
132 $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']");
133 $this->waitForAjaxContent();
134 $this->type('activity_subject', 'Test activity recursion modified');
135 $this->click('_qf_Search_refresh');
136 $this->waitForPageToLoad();
137 $countOfActivities = $this->getXpathCount("xpath=//div[@class='crm-search-results']/table/tbody/tr");
138 if ($countOfActivities) {
139 for ($i = 0; $i <= $countOfActivities; $i++) {
140 $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[3]", 'Test activity recursion modified');
141 }
142 }
8b7ce8d7 143 }
144
145}