commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / tests / phpunit / WebTest / Event / EventListingTest.php
1 <?php
2 require_once 'CiviTest/CiviSeleniumTestCase.php';
3
4 /**
5 * Class WebTest_Event_EventListingTest
6 */
7 class WebTest_Event_EventListingTest extends CiviSeleniumTestCase {
8
9 protected function setUp() {
10 parent::setUp();
11 }
12
13 public function testEventListing() {
14 // Log in using webtestLogin() method
15 $this->webtestLogin('admin');
16
17 //Closed Event
18 $eventTitle1 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
19 $this->_testCreateEvent($eventTitle1, '-12 months', '-3 months');
20
21 //Closed Event with current date as end date
22 $eventTitle2 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
23 $this->_testCreateEvent($eventTitle2, '-12 months', 'now');
24
25 //Ongoing Event with start date as yesterday
26 $eventTitle3 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
27 $this->_testCreateEvent($eventTitle3, '-1 day', '+12 months');
28
29 //Upcomming Event
30 $eventTitle4 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
31 $this->_testCreateEvent($eventTitle4, '+6 months', '+12 months');
32
33 //Upcomming Event
34 $eventTitle5 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
35 $this->_testCreateEvent($eventTitle5, '+3 months', '+6 months');
36
37 //go to manage event and check for presence of ongoing and
38 //upcomming events
39 $this->openCiviPage("event/manage", "reset=1");
40 $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle1);
41 $this->click("_qf_SearchEvent_refresh");
42 $this->waitForPageToLoad($this->getTimeoutMsec());
43 $this->assertFalse($this->isTextPresent("{$eventTitle1}"));
44 $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle2);
45 $this->click("_qf_SearchEvent_refresh");
46 $this->waitForPageToLoad($this->getTimeoutMsec());
47 $this->assertFalse($this->isTextPresent("{$eventTitle2}"));
48 $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle3);
49 $this->click("_qf_SearchEvent_refresh");
50 $this->waitForPageToLoad($this->getTimeoutMsec());
51 $this->waitForText("SearchEvent", "{$eventTitle3}");
52 $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle4);
53 $this->click("_qf_SearchEvent_refresh");
54 $this->waitForPageToLoad($this->getTimeoutMsec());
55 $this->waitForText("SearchEvent", "{$eventTitle4}");
56 $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle5);
57 $this->click("_qf_SearchEvent_refresh");
58 $this->waitForPageToLoad($this->getTimeoutMsec());
59 $this->waitForText("SearchEvent", "{$eventTitle5}");
60 $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", "");
61
62 //check if closed Event is present
63 $this->waitForElementPresent('CIVICRM_QFID_1_eventsByDates');
64 $this->click('CIVICRM_QFID_1_eventsByDates');
65 $this->webtestFillDate("end_date", "now");
66 $this->waitForElementPresent('_qf_SearchEvent_refresh');
67 $this->click('_qf_SearchEvent_refresh');
68 $this->waitForPageToLoad($this->getTimeoutMsec());
69
70 $this->waitForText("option11", "{$eventTitle1}");
71 $this->waitForText("option11", "{$eventTitle2}");
72 $this->assertFalse($this->isTextPresent("{$eventTitle3}"));
73 $this->assertFalse($this->isTextPresent("{$eventTitle4}"));
74 $this->assertFalse($this->isTextPresent("{$eventTitle5}"));
75
76 //go to ical and check for presence of ongoing and upcomming events
77 $this->openCiviPage("event/ical", "reset=1&page=1&html=1", NULL);
78 $this->assertFalse($this->isTextPresent("{$eventTitle1}"));
79 $this->assertFalse($this->isTextPresent("{$eventTitle2}"));
80 $this->waitForText("option11", "{$eventTitle3}");
81 $this->waitForText("option11", "{$eventTitle4}");
82 $this->waitForText("option11", "{$eventTitle5}");
83
84 //go to block listing to enable Upcomming Events Block
85 // you need to be admin user for below operation
86 $this->webtestLogout();
87 $this->webtestLogin('admin');
88
89 $this->open($this->sboxPath . 'admin/structure/block/manage/civicrm/6/configure');
90 $this->waitForElementPresent('edit-submit');
91 $this->type('edit-pages', 'civicrm/dashboard');
92 $this->click('edit-submit');
93 $this->waitForPageToLoad($this->getTimeoutMsec());
94 $this->open($this->sboxPath . 'admin/structure/block');
95 $this->select('edit-blocks-civicrm-6-region', 'value=sidebar_second');
96 $this->click('edit-submit');
97 $this->waitForPageToLoad($this->getTimeoutMsec());
98 $this->waitForTextPresent("The block settings have been updated.");
99
100 //go to civicrm home and check for presence of upcomming events
101 $this->openCiviPage("dashboard", "reset=1");
102 $this->assertFalse($this->isTextPresent("{$eventTitle1}"));
103 $this->assertFalse($this->isTextPresent("{$eventTitle2}"));
104 $this->assertFalse($this->isTextPresent("{$eventTitle3}"));
105 $this->waitForText("block-civicrm-6", "{$eventTitle4}");
106 $this->waitForText("block-civicrm-6", "{$eventTitle5}");
107
108 //go to block listing to disable Upcomming Events Block
109 $this->open($this->sboxPath . 'admin/structure/block');
110 $this->select('edit-blocks-civicrm-6-region', 'value=-1');
111 $this->click('edit-submit');
112 $this->waitForPageToLoad($this->getTimeoutMsec());
113 $this->waitForTextPresent("The block settings have been updated.");
114 }
115
116 /**
117 * @param $eventTitle
118 * @param $startdate
119 * @param $enddate
120 */
121 public function _testCreateEvent($eventTitle, $startdate, $enddate) {
122
123 $this->openCiviPage("event/add", "reset=1&action=add");
124
125 // $eventTitle = 'My Conference - '.substr(sha1(rand()), 0, 7);
126 $eventDescription = "Here is a description for this conference.";
127 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
128
129 $this->select("event_type_id", "value=1");
130
131 // Attendee role s/b selected now.
132 $this->select("default_role_id", "value=1");
133
134 // Enter Event Title, Summary and Description
135 $this->type("title", $eventTitle);
136 $this->type("summary", "This is a great conference. Sign up now!");
137
138 // Type description in ckEditor (fieldname, text to type, editor)
139 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
140
141 // Choose Start and End dates.
142 // Using helper webtestFillDate function.
143 if ($startdate) {
144 $this->webtestFillDateTime("start_date", $startdate);
145 }
146
147 if ($enddate == 'now') {
148 // to avoid time zone difference problem between selenium-test & drupal
149 $this->webtestFillDate("end_date", $enddate);
150 }
151 elseif ($enddate) {
152 $this->webtestFillDateTime("end_date", $enddate);
153 }
154
155 $this->type("max_participants", "6");
156 $this->click("is_public");
157 $this->clickLink("_qf_EventInfo_upload-bottom", "_qf_Location_upload_done-bottom");
158
159 $this->click("_qf_Location_upload_done-bottom");
160
161 // Wait for "saved" status msg
162 $this->waitForPageToLoad($this->getTimeoutMsec());
163 $this->waitForText("crm-notification-container", "'Event Location' information has been saved.");
164 }
165
166 }