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