Merge pull request #5534 from davecivicrm/CRM-15197
[civicrm-core.git] / tests / phpunit / WebTest / Event / AddRecurringEventTest.php
CommitLineData
eac2f71b 1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
eac2f71b 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
eac2f71b 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 */
eac2f71b 26
27/**
28 * Description of AddRecurringEventTest
29 *
30 * @author Priyanka
31 */
32
33require_once 'CiviTest/CiviSeleniumTestCase.php';
34
7fe37828
EM
35/**
36 * Class WebTest_Event_AddRecurringEventTest
37 */
eac2f71b 38class WebTest_Event_AddRecurringEventTest extends CiviSeleniumTestCase {
39
40 protected function setUp() {
41 parent::setUp();
42 }
43
00be9182 44 public function testRecurringEvent() {
eac2f71b 45 $this->webtestLogin();
46
47 //Add repeat configuration for an event
48 $this->openCiviPage("event/manage/repeat", "reset=1&action=update&id=1", '_qf_Repeat_cancel-bottom');
49
50 $this->click('repetition_frequency_unit');
df519dcf 51 $this->select('repetition_frequency_unit', 'label=week');
eac2f71b 52 $this->click('repetition_frequency_interval');
53 $this->select('repetition_frequency_interval', 'label=1');
54 $this->click('start_action_condition_monday');
55 $this->click('start_action_condition_tuesday');
56 $this->click('CIVICRM_QFID_1_ends');
57
58 $occurrences = rand(3, 5);
59 if (!$occurrences) {
60 $occurrences = 3;
61 }
62 $this->type('start_action_offset', $occurrences);
63 $this->webtestFillDate("exclude_date", "11/05/2015");
64 $this->click('add_to_exclude_list');
65 $this->webtestFillDate("exclude_date", "12/05/2015");
66 $this->click('add_to_exclude_list');
67 $this->click('_qf_Repeat_submit-bottom');
fe87e754 68 $this->waitForTextPresent('Based on your repeat configuration, here is the list of dates. Do you wish to create a recurring set with these dates?');
eac2f71b 69 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Ok']");
70 $this->waitForAjaxContent();
71 $this->checkCRMAlert('Repeat Configuration has been saved');
72
73 //Check if assertions are correct
74 $count = $this->getXpathCount("xpath=//div[@id='event_status_id']/div[@class='crm-accordion-body']/div/table/tbody/tr");
75 $count = $count - 1;
76 $this->assertEquals($occurrences, $count);
77
78 //Lets go to find participant page and see our repetitive events there
79 $this->openCiviPage("event/manage", "reset=1");
80 $eventTitle = "Fall Fundraiser Dinner";
81 $this->type("title", $eventTitle);
82 $this->click("_qf_SearchEvent_refresh");
83 $this->assertTrue($this->isTextPresent("Recurring Event - (Child)"));
84 $this->assertTrue($this->isTextPresent("Recurring Event - (Parent)"));
85
86 //Update Mode Cascade Changes
87 $this->click('event-configure-1');
88 $this->waitForElementPresent("xpath=//span[@id='event-configure-1']/ul[@class='panel']/li/a[text()='Info and Settings']");
89 $this->click("xpath=//span[@id='event-configure-1']/ul[@class='panel']/li/a[text()='Info and Settings']");
90 $this->waitForElementPresent('_qf_EventInfo_cancel-bottom');
91 $this->type('title', 'CiviCon');
92 $this->click('_qf_EventInfo_upload_done-top');
93 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
94 $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()='All the entities']");
95 $this->waitForAjaxContent();
96 $this->openCiviPage("event/manage", "reset=1");
97 $newEventTitle = "CiviCon";
98 $this->type("title", $newEventTitle);
99 $this->click("_qf_SearchEvent_refresh");
100 $this->waitForPageToLoad();
101 $countOfEvents = $this->getXpathCount("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr");
102 if ($countOfEvents) {
103 for ($i = 0; $i <= $countOfEvents; $i++) {
f78f9745 104 $this->verifyText("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr/td[1]/a", 'CiviCon');
eac2f71b 105 }
106 }
107 }
108
109}