Merge pull request #12011 from lcdservices/dev-financial-12
[civicrm-core.git] / tests / phpunit / WebTest / Event / AddRecurringEventTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 /**
28 * Description of AddRecurringEventTest
29 *
30 * @author Priyanka
31 */
32
33 require_once 'CiviTest/CiviSeleniumTestCase.php';
34
35 /**
36 * Class WebTest_Event_AddRecurringEventTest
37 */
38 class WebTest_Event_AddRecurringEventTest extends CiviSeleniumTestCase {
39
40 protected function setUp() {
41 parent::setUp();
42 }
43
44 public function testRecurringEvent() {
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');
51 $this->select('repetition_frequency_unit', 'label=week');
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->select('start_action_offset', $occurrences);
63 $this->multiselect2('exclude_date_list', array('05/11/2015', '05/12/2015'), TRUE);
64 $this->click('_qf_Repeat_submit-bottom');
65 $this->waitForTextPresent('A repeating set will be created with the following dates.');
66 $this->click("xpath=//button//span[text()='Continue']");
67 $this->waitForAjaxContent();
68 $this->checkCRMAlert('Repeat Configuration has been saved');
69
70 //Check if assertions are correct
71 $this->waitForElementPresent("xpath=//div[@id='recurring-entity-block']/following-sibling::div//div[@class='crm-accordion-body']/div/table/tbody/tr");
72 $count = $this->getXpathCount("xpath=//div[@id='recurring-entity-block']/following-sibling::div//div[@class='crm-accordion-body']/div/table/tbody/tr");
73 $this->assertEquals($occurrences, $count);
74
75 //Lets go to find participant page and see our repetitive events there
76 $this->openCiviPage("event/manage", "reset=1");
77 $eventTitle = "Fall Fundraiser Dinner";
78 $this->type("title", $eventTitle);
79 $this->click("_qf_SearchEvent_refresh");
80 $this->assertTrue($this->isTextPresent("Repeating"));
81
82 //Update Mode Cascade Changes
83 $this->click('event-configure-1');
84 $this->waitForElementPresent("xpath=//span[@id='event-configure-1']/ul[@class='panel']/li/a[text()='Info and Settings']");
85 $this->click("xpath=//span[@id='event-configure-1']/ul[@class='panel']/li/a[text()='Info and Settings']");
86 $this->waitForTextPresent("Event Title");
87 $this->type('title', 'CiviCon');
88 $this->click('_qf_EventInfo_upload_done-top');
89 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
90 $this->click("recur-all-entity");
91 $this->click("xpath=//button//span[text()='Continue']");
92 $this->waitForAjaxContent();
93 $this->openCiviPage("event/manage", "reset=1");
94 $newEventTitle = "CiviCon";
95 $this->type("title", $newEventTitle);
96 $this->click("_qf_SearchEvent_refresh");
97 $this->waitForPageToLoad();
98 $countOfEvents = $this->getXpathCount("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr");
99 if ($countOfEvents) {
100 for ($i = 0; $i <= $countOfEvents; $i++) {
101 $this->verifyText("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr/td[1]/a", 'CiviCon');
102 }
103 }
104 }
105
106 }