Merge pull request #203 from mlutfy/CRM-11755
[civicrm-core.git] / tests / phpunit / WebTest / Admin / Form / ScheduleReminderTest.php
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 $this->webtestLogin();
37
38 // Add new Schedule Reminder
39 $this->openCiviPage("admin/scheduleReminders", "action=add&reset=1", '_qf_ScheduleReminders_cancel-bottom');
40
41 // Fill Title
42 $title = 'Title' . substr(sha1(rand()), 0, 4);
43 $this->type('title', $title);
44
45 // Fill Entity Details
46 $this->click('entity_0');
47 $this->select('entity_0', 'label=Activity');
48 $this->addSelection('entity_1', 'label=Meeting');
49 $this->addSelection('entity_2', 'label=Completed');
50 $this->select('start_action_offset', 'label=1');
51 $this->select('start_action_condition', 'label=after');
52 $this->click('is_repeat');
53 $this->select('repetition_frequency_interval', 'label=1');
54 $this->click('recipient');
55 $this->select('recipient', 'label=Activity Assignees');
56
57 // Fill Subject
58 $subject = 'subject' . substr(sha1(rand()), 0, 4);
59 $this->type('subject', $subject);
60
61 //click on save
62 $this->click('_qf_ScheduleReminders_next-bottom');
63 $this->waitForPageToLoad($this->getTimeoutMsec());
64
65 $this->click("//div[@id='reminder']//div[@class='dataTables_wrapper']/table/tbody//tr/td[1][text()='{$title}']/../td[7]/span/a[text()='Edit']");
66 $this->waitForElementPresent('_qf_ScheduleReminders_cancel-bottom');
67
68 $this->assertEquals($title, $this->getValue('id=title'));
69 $this->removeSelection('entity_1', 'label=Meeting');
70 $this->addSelection('entity_1', 'label=Phone Call');
71 $this->addSelection('entity_1', 'label=Interview');
72 $this->removeSelection('entity_2', 'label=Completed');
73 $this->addSelection('entity_2', 'label=Scheduled');
74 $this->addSelection('entity_2', 'label=Completed');
75
76 $this->assertEquals('1', $this->getSelectedValue('id=start_action_offset'));
77 $this->assertEquals('hour', $this->getSelectedValue('id=start_action_unit'));
78 $this->assertEquals('after', $this->getSelectedValue('id=start_action_condition'));
79 $this->assertEquals('activity_date_time', $this->getSelectedValue('id=start_action_date'));
80
81 $this->assertChecked('is_repeat');
82
83 $this->assertEquals('1', $this->getSelectedValue('id=recipient'));
84 $this->assertChecked('is_active');
85 }
86 }
87