Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
aba1cd8b EM |
3 | |
4 | /** | |
5 | * Class WebTest_Event_EventListingTest | |
6 | */ | |
6a488035 TO |
7 | class WebTest_Event_EventListingTest extends CiviSeleniumTestCase { |
8 | ||
9 | protected function setUp() { | |
10 | parent::setUp(); | |
11 | } | |
12 | ||
13 | function testEventListing() { | |
6a488035 | 14 | // Log in using webtestLogin() method |
42daf119 | 15 | $this->webtestLogin('admin'); |
6a488035 TO |
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 | |
acd28991 | 39 | $this->openCiviPage("event/manage", "reset=1"); |
461d123d | 40 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle1); |
6a488035 TO |
41 | $this->click("_qf_SearchEvent_refresh"); |
42 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
43 | $this->assertFalse($this->isTextPresent("{$eventTitle1}")); | |
461d123d | 44 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle2); |
6a488035 TO |
45 | $this->click("_qf_SearchEvent_refresh"); |
46 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
47 | $this->assertFalse($this->isTextPresent("{$eventTitle2}")); | |
461d123d | 48 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle3); |
6a488035 TO |
49 | $this->click("_qf_SearchEvent_refresh"); |
50 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
2ac4a694 | 51 | $this->waitForText("SearchEvent", "{$eventTitle3}"); |
461d123d | 52 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle4); |
6a488035 TO |
53 | $this->click("_qf_SearchEvent_refresh"); |
54 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
2ac4a694 | 55 | $this->waitForText("SearchEvent", "{$eventTitle4}"); |
461d123d | 56 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle5); |
6a488035 TO |
57 | $this->click("_qf_SearchEvent_refresh"); |
58 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
2ac4a694 | 59 | $this->waitForText("SearchEvent", "{$eventTitle5}"); |
461d123d | 60 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", ""); |
6a488035 TO |
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 | ||
2ac4a694 RN |
70 | $this->waitForText("option11", "{$eventTitle1}"); |
71 | $this->waitForText("option11", "{$eventTitle2}"); | |
6a488035 TO |
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 | |
6eb238c8 | 77 | $this->openCiviPage("event/ical", "reset=1&page=1&html=1", NULL); |
6a488035 TO |
78 | $this->assertFalse($this->isTextPresent("{$eventTitle1}")); |
79 | $this->assertFalse($this->isTextPresent("{$eventTitle2}")); | |
2ac4a694 RN |
80 | $this->waitForText("option11", "{$eventTitle3}"); |
81 | $this->waitForText("option11", "{$eventTitle4}"); | |
82 | $this->waitForText("option11", "{$eventTitle5}"); | |
6a488035 TO |
83 | |
84 | //go to block listing to enable Upcomming Events Block | |
85 | // you need to be admin user for below operation | |
42daf119 CW |
86 | $this->webtestLogout(); |
87 | $this->webtestLogin('admin'); | |
6a488035 TO |
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 | |
acd28991 | 101 | $this->openCiviPage("dashboard", "reset=1"); |
6a488035 TO |
102 | $this->assertFalse($this->isTextPresent("{$eventTitle1}")); |
103 | $this->assertFalse($this->isTextPresent("{$eventTitle2}")); | |
104 | $this->assertFalse($this->isTextPresent("{$eventTitle3}")); | |
2ac4a694 RN |
105 | $this->waitForText("block-civicrm-6", "{$eventTitle4}"); |
106 | $this->waitForText("block-civicrm-6", "{$eventTitle5}"); | |
6a488035 TO |
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 | ||
4cbe18b8 EM |
116 | /** |
117 | * @param $eventTitle | |
118 | * @param $startdate | |
119 | * @param $enddate | |
120 | */ | |
6a488035 | 121 | function _testCreateEvent($eventTitle, $startdate, $enddate) { |
42daf119 | 122 | |
acd28991 | 123 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
124 | |
125 | // $eventTitle = 'My Conference - '.substr(sha1(rand()), 0, 7); | |
126 | $eventDescription = "Here is a description for this conference."; | |
6a488035 TO |
127 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
128 | ||
6a488035 TO |
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"); | |
225a8648 | 157 | $this->clickLink("_qf_EventInfo_upload-bottom", "_qf_Location_upload_done-bottom"); |
6a488035 TO |
158 | |
159 | $this->click("_qf_Location_upload_done-bottom"); | |
160 | ||
161 | // Wait for "saved" status msg | |
162 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
60709d21 | 163 | $this->waitForText("crm-notification-container", "'Event Location' information has been saved."); |
6a488035 TO |
164 | } |
165 | } | |
166 |