| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.3 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2013 | |
| 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 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
| 29 | class WebTest_Admin_Form_ScheduleReminderTest extends CiviSeleniumTestCase { |
| 30 | |
| 31 | protected function setUp() { |
| 32 | parent::setUp(); |
| 33 | } |
| 34 | |
| 35 | function testScheduleReminder() { |
| 36 | |
| 37 | // This is the path where our testing install resides. |
| 38 | // The rest of URL is defined in CiviSeleniumTestCase base class, in |
| 39 | // class attributes. |
| 40 | $this->open($this->sboxPath); |
| 41 | |
| 42 | // Logging in. Remember to wait for page to load. In most cases, |
| 43 | // you can rely on 30000 as the value that allows your test to pass, however, |
| 44 | // sometimes your test might fail because of this. In such cases, it's better to pick one element |
| 45 | // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole |
| 46 | // page contents loaded and you can continue your test execution. |
| 47 | $this->webtestLogin(); |
| 48 | |
| 49 | // Add new Schedule Reminder |
| 50 | $this->open($this->sboxPath . 'civicrm/admin/scheduleReminders?reset=1'); |
| 51 | $this->open($this->sboxPath . 'civicrm/admin/scheduleReminders?action=add&reset=1'); |
| 52 | $this->waitForElementPresent('_qf_ScheduleReminders_cancel-bottom'); |
| 53 | |
| 54 | // Fill Title |
| 55 | $title = 'Title' . substr(sha1(rand()), 0, 4); |
| 56 | $this->type('title', $title); |
| 57 | |
| 58 | // Fill Entity Details |
| 59 | $this->click('entity_0'); |
| 60 | $this->select('entity_0', 'label=Activity'); |
| 61 | $this->addSelection('entity_1', 'label=Meeting'); |
| 62 | $this->addSelection('entity_2', 'label=Completed'); |
| 63 | $this->select('start_action_offset', 'label=1'); |
| 64 | $this->select('start_action_condition', 'label=after'); |
| 65 | $this->click('is_repeat'); |
| 66 | $this->select('repetition_frequency_interval', 'label=1'); |
| 67 | $this->click('recipient'); |
| 68 | $this->select('recipient', 'label=Activity Assignees'); |
| 69 | |
| 70 | // Fill Subject |
| 71 | $subject = 'subject' . substr(sha1(rand()), 0, 4); |
| 72 | $this->type('subject', $subject); |
| 73 | |
| 74 | //click on save |
| 75 | $this->click('_qf_ScheduleReminders_next-bottom'); |
| 76 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 77 | |
| 78 | $this->click("//div[@id='reminder']//div[@class='dataTables_wrapper']/table/tbody//tr/td[1][text()='{$title}']/../td[7]/span/a[text()='Edit']"); |
| 79 | $this->waitForElementPresent('_qf_ScheduleReminders_cancel-bottom'); |
| 80 | |
| 81 | $this->assertEquals($title, $this->getValue('id=title')); |
| 82 | $this->removeSelection('entity_1', 'label=Meeting'); |
| 83 | $this->addSelection('entity_1', 'label=Phone Call'); |
| 84 | $this->addSelection('entity_1', 'label=Interview'); |
| 85 | $this->removeSelection('entity_2', 'label=Completed'); |
| 86 | $this->addSelection('entity_2', 'label=Scheduled'); |
| 87 | $this->addSelection('entity_2', 'label=Completed'); |
| 88 | |
| 89 | $this->assertEquals('1', $this->getSelectedValue('id=start_action_offset')); |
| 90 | $this->assertEquals('hour', $this->getSelectedValue('id=start_action_unit')); |
| 91 | $this->assertEquals('after', $this->getSelectedValue('id=start_action_condition')); |
| 92 | $this->assertEquals('activity_date_time', $this->getSelectedValue('id=start_action_date')); |
| 93 | |
| 94 | $this->assertChecked('is_repeat'); |
| 95 | |
| 96 | $this->assertEquals('1', $this->getSelectedValue('id=recipient')); |
| 97 | $this->assertChecked('is_active'); |
| 98 | } |
| 99 | } |
| 100 | |