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() { | |
10 | // This is the path where our testing install resides. | |
11 | // The rest of URL is defined in CiviSeleniumTestCase base class, in | |
12 | // class attributes. | |
13 | $this->open($this->sboxPath); | |
14 | ||
15 | // Log in using webtestLogin() method | |
16 | $this->webtestLogin(TRUE); | |
17 | ||
18 | //Closed Event | |
19 | $eventTitle1 = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
20 | $this->_testCreateEvent($eventTitle1, '-12 months', '-3 months'); | |
21 | ||
22 | //Closed Event with current date as end date | |
23 | $eventTitle2 = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
24 | $this->_testCreateEvent($eventTitle2, '-12 months', 'now'); | |
25 | ||
26 | //Ongoing Event with start date as yesterday | |
27 | $eventTitle3 = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
28 | $this->_testCreateEvent($eventTitle3, '-1 day', '+12 months'); | |
29 | ||
30 | //Upcomming Event | |
31 | $eventTitle4 = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
32 | $this->_testCreateEvent($eventTitle4, '+6 months', '+12 months'); | |
33 | ||
34 | //Upcomming Event | |
35 | $eventTitle5 = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
36 | $this->_testCreateEvent($eventTitle5, '+3 months', '+6 months'); | |
37 | ||
38 | //go to manage event and check for presence of ongoing and | |
39 | //upcomming events | |
acd28991 | 40 | $this->openCiviPage("event/manage", "reset=1"); |
6a488035 TO |
41 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input",$eventTitle1); |
42 | $this->click("_qf_SearchEvent_refresh"); | |
43 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
44 | $this->assertFalse($this->isTextPresent("{$eventTitle1}")); | |
45 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input",$eventTitle2); | |
46 | $this->click("_qf_SearchEvent_refresh"); | |
47 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
48 | $this->assertFalse($this->isTextPresent("{$eventTitle2}")); | |
49 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input",$eventTitle3); | |
50 | $this->click("_qf_SearchEvent_refresh"); | |
51 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
52 | $this->assertTrue($this->isTextPresent("{$eventTitle3}")); | |
53 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input",$eventTitle4); | |
54 | $this->click("_qf_SearchEvent_refresh"); | |
55 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
56 | $this->assertTrue($this->isTextPresent("{$eventTitle4}")); | |
57 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input",$eventTitle5); | |
58 | $this->click("_qf_SearchEvent_refresh"); | |
59 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
60 | $this->assertTrue($this->isTextPresent("{$eventTitle5}")); | |
61 | $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input",""); | |
62 | ||
63 | //check if closed Event is present | |
64 | $this->waitForElementPresent('CIVICRM_QFID_1_eventsByDates'); | |
65 | $this->click('CIVICRM_QFID_1_eventsByDates'); | |
66 | $this->webtestFillDate("end_date", "now"); | |
67 | $this->waitForElementPresent('_qf_SearchEvent_refresh'); | |
68 | $this->click('_qf_SearchEvent_refresh'); | |
69 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
70 | ||
71 | $this->assertTrue($this->isTextPresent("{$eventTitle1}")); | |
72 | $this->assertTrue($this->isTextPresent("{$eventTitle2}")); | |
73 | $this->assertFalse($this->isTextPresent("{$eventTitle3}")); | |
74 | $this->assertFalse($this->isTextPresent("{$eventTitle4}")); | |
75 | $this->assertFalse($this->isTextPresent("{$eventTitle5}")); | |
76 | ||
77 | //go to ical and check for presence of ongoing and upcomming events | |
6eb238c8 | 78 | $this->openCiviPage("event/ical", "reset=1&page=1&html=1", NULL); |
6a488035 TO |
79 | $this->assertFalse($this->isTextPresent("{$eventTitle1}")); |
80 | $this->assertFalse($this->isTextPresent("{$eventTitle2}")); | |
81 | $this->assertTrue($this->isTextPresent("{$eventTitle3}")); | |
82 | $this->assertTrue($this->isTextPresent("{$eventTitle4}")); | |
83 | $this->assertTrue($this->isTextPresent("{$eventTitle5}")); | |
84 | ||
85 | //go to block listing to enable Upcomming Events Block | |
86 | // you need to be admin user for below operation | |
9bffa155 | 87 | $this->openCiviPage("logout", "reset=1", NULL); |
6a488035 TO |
88 | $this->webtestLogin(TRUE); |
89 | ||
90 | $this->open($this->sboxPath . 'admin/structure/block/manage/civicrm/6/configure'); | |
91 | $this->waitForElementPresent('edit-submit'); | |
92 | $this->type('edit-pages', 'civicrm/dashboard'); | |
93 | $this->click('edit-submit'); | |
94 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
95 | $this->open($this->sboxPath . 'admin/structure/block'); | |
96 | $this->select('edit-blocks-civicrm-6-region', 'value=sidebar_second'); | |
97 | $this->click('edit-submit'); | |
98 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
99 | $this->waitForTextPresent("The block settings have been updated."); | |
100 | ||
101 | //go to civicrm home and check for presence of upcomming events | |
acd28991 | 102 | $this->openCiviPage("dashboard", "reset=1"); |
6a488035 TO |
103 | $this->assertFalse($this->isTextPresent("{$eventTitle1}")); |
104 | $this->assertFalse($this->isTextPresent("{$eventTitle2}")); | |
105 | $this->assertFalse($this->isTextPresent("{$eventTitle3}")); | |
106 | $this->assertTrue($this->isTextPresent("{$eventTitle4}")); | |
107 | $this->assertTrue($this->isTextPresent("{$eventTitle5}")); | |
108 | ||
109 | //go to block listing to disable Upcomming Events Block | |
110 | $this->open($this->sboxPath . 'admin/structure/block'); | |
111 | $this->select('edit-blocks-civicrm-6-region', 'value=-1'); | |
112 | $this->click('edit-submit'); | |
113 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
114 | $this->waitForTextPresent("The block settings have been updated."); | |
115 | } | |
116 | ||
117 | function _testCreateEvent($eventTitle, $startdate, $enddate) { | |
118 | // Go directly to the URL of the screen that you will be testing (New Event). | |
acd28991 | 119 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
120 | |
121 | // $eventTitle = 'My Conference - '.substr(sha1(rand()), 0, 7); | |
122 | $eventDescription = "Here is a description for this conference."; | |
123 | ||
124 | // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit | |
125 | // button at the end of this page to show up, to make sure it's fully loaded. | |
126 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); | |
127 | ||
128 | // Let's start filling the form with values. | |
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->click("_qf_EventInfo_upload-bottom"); | |
158 | ||
159 | // Wait for Location tab form to load | |
160 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
161 | $this->waitForElementPresent("_qf_Location_upload_done-bottom"); | |
162 | ||
163 | $this->click("_qf_Location_upload_done-bottom"); | |
164 | ||
165 | // Wait for "saved" status msg | |
166 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
167 | $this->waitForTextPresent("'Location' information has been saved."); | |
168 | } | |
169 | } | |
170 | ||
171 |