1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\Codeception\helpers; |
4
|
|
|
|
5
|
|
|
use Page\CoreAdmin; |
6
|
|
|
use Page\RegistrationsAdmin as RegistrationsAdminPage; |
7
|
|
|
use Page\EventsAdmin; |
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Trait RegistrationsAdmin |
11
|
|
|
* Helper actions for Registration Admin Page actions. |
12
|
|
|
* |
13
|
|
|
* @package EventEspresso\Codeception\helpers |
14
|
|
|
*/ |
15
|
|
|
trait RegistrationsAdmin |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* This will select all checkboxes on a registration list table for the given array of |
20
|
|
|
* registration ids. |
21
|
|
|
* Assumes the actor is on a list table page for registrations. |
22
|
|
|
* @param $registration_ids |
23
|
|
|
*/ |
24
|
|
|
public function selectBulkActionCheckboxesForRegistrationIds(array $registration_ids) |
25
|
|
|
{ |
26
|
|
|
foreach ($registration_ids as $registration_id) { |
27
|
|
|
$this->actor()->checkOption( |
|
|
|
|
28
|
|
|
RegistrationsAdminPage::listTableCheckBoxSelectorForRegistrationId($registration_id) |
29
|
|
|
); |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Navigates the actor to the default registration list table page. |
36
|
|
|
* @param string $additional_params |
37
|
|
|
*/ |
38
|
|
|
public function amOnDefaultRegistrationsListTableAdminPage($additional_params = '') |
39
|
|
|
{ |
40
|
|
|
$this->actor()->amOnAdminPage( |
|
|
|
|
41
|
|
|
RegistrationsAdminPage::registrationsDefaultAdminListTableUrl($additional_params) |
42
|
|
|
); |
43
|
|
|
//wait for page to fully load |
44
|
|
|
$this->actor()->wait(5); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Will enter the provided value in the registration list table search field and execute a search for that value. |
50
|
|
|
* @param string $search_text |
51
|
|
|
*/ |
52
|
|
|
public function searchForRegistrationOnRegistrationListTableWithText($search_text) |
53
|
|
|
{ |
54
|
|
|
$this->amOnDefaultRegistrationsListTableAdminPage(); |
55
|
|
|
$this->actor()->fillField(RegistrationsAdminPage::SEARCH_INPUT_SELECTOR_LIST_TABLE_REGISTRATION, $search_text); |
|
|
|
|
56
|
|
|
$this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR); |
|
|
|
|
57
|
|
|
$this->actor()->waitForText('Displaying search results for'); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* This will filter the registration list table to view registrations for the given event id. |
64
|
|
|
* Assumption is made that you are logged into the admin but you do not need to be on the registration list table |
65
|
|
|
* page. |
66
|
|
|
* |
67
|
|
|
* @param int $event_id The id of the event viewing registrations for. |
68
|
|
|
*/ |
69
|
|
|
public function amViewingRegistrationsForEvent($event_id) |
70
|
|
|
{ |
71
|
|
|
$this->actor()->amOnDefaultEventsListTablePage(); |
|
|
|
|
72
|
|
|
$this->actor()->click(EventsAdmin::listTableActionLinkRegistrationsForEvent($event_id)); |
|
|
|
|
73
|
|
|
$this->actor()->waitForText('Viewing registrations for the event'); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* This helper will initiate registering for the given event via the backend. |
79
|
|
|
* @param int $event_id The event to initiate registration for. |
80
|
|
|
*/ |
81
|
|
|
public function amOnAdminRegistrationPageForEvent($event_id) |
82
|
|
|
{ |
83
|
|
|
$this->actor()->amViewingRegistrationsForEvent($event_id); |
|
|
|
|
84
|
|
|
$this->actor()->click(RegistrationsAdminPage::BUTTON_ADD_NEW_REGISTRATION); |
|
|
|
|
85
|
|
|
$this->actor()->waitForText('Adding Registration For'); |
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* This clicks the View Details Link for Registration with the given Id |
92
|
|
|
* @param $registration_id |
93
|
|
|
*/ |
94
|
|
|
public function clickViewDetailsLinkForRegistrationWithId($registration_id) |
95
|
|
|
{ |
96
|
|
|
$this->actor()->click(RegistrationsAdminPage::viewDetailsLinkSelectorForRegistrationId($registration_id)); |
|
|
|
|
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* /** |
102
|
|
|
* This assumes you are on the admin details page for a registration in EE. It selects the given status in the |
103
|
|
|
* dropdown for changing registration status. |
104
|
|
|
* |
105
|
|
|
* @param string $status_label_or_value Either the label for the dropdown option or the value for the option. |
106
|
|
|
* @param $status_label_or_value |
107
|
|
|
*/ |
108
|
|
|
public function selectRegistrationStatusOnRegistrationDetailsPageFor($status_label_or_value) |
109
|
|
|
{ |
110
|
|
|
$this->actor()->selectOption( |
|
|
|
|
111
|
|
|
RegistrationsAdminPage::DROPDOWN_REGISTRATION_STATUS, |
112
|
|
|
$status_label_or_value |
113
|
|
|
); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* This selects (or deselects) the "Send Related Messages" checkbox on the Registration Details page. |
119
|
|
|
* @param bool $send_related_messages |
120
|
|
|
*/ |
121
|
|
|
public function selectSendRelatedMessagesOptionOnRegistrationDetailsPage($send_related_messages = true) |
122
|
|
|
{ |
123
|
|
|
$send_related_messages |
124
|
|
|
? $this->actor()->selectOption( |
|
|
|
|
125
|
|
|
RegistrationsAdminPage::DROPDOWN_SEND_RELATED_MESSAGES, |
126
|
|
|
'Yes' |
127
|
|
|
) |
128
|
|
|
: $this->actor()->selecOption( |
|
|
|
|
129
|
|
|
RegistrationsAdminPage::DROPDOWN_SEND_RELATED_MESSAGES, |
130
|
|
|
'No' |
131
|
|
|
); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* This assumes you are on the admin details page for a registration in EE. It selects the given status in the |
138
|
|
|
* dropdown for changing registration status and submits the change. |
139
|
|
|
* |
140
|
|
|
* @param string $status_label_or_value Either the label for the dropdown option or the value for the option. |
141
|
|
|
* @param bool $send_related_messages Whether or not to send related messages after changing the bulk action. |
142
|
|
|
*/ |
143
|
|
|
public function changeRegistrationStatusOnRegistrationDetailsPageTo( |
144
|
|
|
$status_label_or_value, |
145
|
|
|
$send_related_messages = true |
146
|
|
|
) { |
147
|
|
|
$this->actor()->selectRegistrationStatusOnRegistrationDetailsPageFor($status_label_or_value); |
|
|
|
|
148
|
|
|
$this->actor()->selectSendRelatedMessagesOptionOnRegistrationDetailsPage($send_related_messages); |
|
|
|
|
149
|
|
|
$this->actor()->click(RegistrationsAdminPage::BUTTON_UPDATE_REGISTRATION_STATUS); |
|
|
|
|
150
|
|
|
$this->actor()->waitForText('Registration status has been set to'); |
|
|
|
|
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
} |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: