| 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 | /** |
| 28 | * Description of AddRecurringEventTest |
| 29 | * |
| 30 | * @author Priyanka |
| 31 | */ |
| 32 | |
| 33 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
| 34 | |
| 35 | class WebTest_Event_AddRecurringEventTest extends CiviSeleniumTestCase { |
| 36 | |
| 37 | protected function setUp() { |
| 38 | parent::setUp(); |
| 39 | } |
| 40 | |
| 41 | function testRecurringEvent() { |
| 42 | $this->webtestLogin(); |
| 43 | |
| 44 | //Add repeat configuration for an event |
| 45 | $this->openCiviPage("event/manage/repeat", "reset=1&action=update&id=1", '_qf_Repeat_cancel-bottom'); |
| 46 | |
| 47 | $this->click('repetition_frequency_unit'); |
| 48 | $this->select('repetition_frequency_unit', 'label=weekly'); |
| 49 | $this->click('repetition_frequency_interval'); |
| 50 | $this->select('repetition_frequency_interval', 'label=1'); |
| 51 | $this->click('start_action_condition_monday'); |
| 52 | $this->click('start_action_condition_tuesday'); |
| 53 | $this->click('CIVICRM_QFID_1_ends'); |
| 54 | |
| 55 | $occurrences = rand(3, 5); |
| 56 | if (!$occurrences) { |
| 57 | $occurrences = 3; |
| 58 | } |
| 59 | $this->type('start_action_offset', $occurrences); |
| 60 | $this->webtestFillDate("exclude_date", "11/05/2015"); |
| 61 | $this->click('add_to_exclude_list'); |
| 62 | $this->webtestFillDate("exclude_date", "12/05/2015"); |
| 63 | $this->click('add_to_exclude_list'); |
| 64 | $this->click('_qf_Repeat_submit-bottom'); |
| 65 | $this->waitForTextPresent('Based on your repeat configuration, here is the list of dates. Do you wish to create a recurring set with these dates?'); |
| 66 | $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Ok']"); |
| 67 | $this->waitForAjaxContent(); |
| 68 | $this->checkCRMAlert('Repeat Configuration has been saved'); |
| 69 | |
| 70 | //Check if assertions are correct |
| 71 | $count = $this->getXpathCount("xpath=//div[@id='event_status_id']/div[@class='crm-accordion-body']/div/table/tbody/tr"); |
| 72 | $count = $count - 1; |
| 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("Recurring Event - (Child)")); |
| 81 | $this->assertTrue($this->isTextPresent("Recurring Event - (Parent)")); |
| 82 | |
| 83 | //Update Mode Cascade Changes |
| 84 | $this->click('event-configure-1'); |
| 85 | $this->waitForElementPresent("xpath=//span[@id='event-configure-1']/ul[@class='panel']/li/a[text()='Info and Settings']"); |
| 86 | $this->click("xpath=//span[@id='event-configure-1']/ul[@class='panel']/li/a[text()='Info and Settings']"); |
| 87 | $this->waitForElementPresent('_qf_EventInfo_cancel-bottom'); |
| 88 | $this->type('title', 'CiviCon'); |
| 89 | $this->click('_qf_EventInfo_upload_done-top'); |
| 90 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']"); |
| 91 | $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']"); |
| 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/a", 'CiviCon'); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | } |