1
|
|
|
<?php |
2
|
|
|
namespace EventEspresso\Codeception\helpers; |
3
|
|
|
|
4
|
|
|
use Page\MessagesAdmin as MessagesPage; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Trait MessagesAdmin |
8
|
|
|
* Helper actions for the Messages Admin Pages |
9
|
|
|
* @package EventEspresso\Codeception\helpers |
10
|
|
|
*/ |
11
|
|
|
trait MessagesAdmin |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @param string $additional_params Any additional request parameters for the generated url should be included as |
15
|
|
|
* a string. |
16
|
|
|
*/ |
17
|
|
|
public function amOnMessagesActivityListTablePage($additional_params = '') |
18
|
|
|
{ |
19
|
|
|
$this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param string $additional_params Any additional request parameters for the generated url should be included as |
24
|
|
|
* a string. |
25
|
|
|
*/ |
26
|
|
|
public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
27
|
|
|
{ |
28
|
|
|
$this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $additional_params Any additional request parameters for the generated url should be included as |
34
|
|
|
* a string. |
35
|
|
|
*/ |
36
|
|
|
public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
37
|
|
|
{ |
38
|
|
|
$this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Directs to message settings page |
44
|
|
|
*/ |
45
|
|
|
public function amOnMessageSettingsPage() |
46
|
|
|
{ |
47
|
|
|
$this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Assumes you are already on the list table page that has the ui for editing the template. |
53
|
|
|
* @param string $message_type_slug |
54
|
|
|
* @param string $context [optional] if you want to click directly to the given context in the editor |
55
|
|
|
*/ |
56
|
|
|
public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
57
|
|
|
{ |
58
|
|
|
$this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Use this action to verify that the count for the given text in the specified field is as expected. For example |
64
|
|
|
* filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
65
|
|
|
* |
66
|
|
|
* @param int $expected_occurence_count |
67
|
|
|
* @param string $text_to_check_for |
68
|
|
|
* @param string $field |
69
|
|
|
* @param string $message_type_label |
70
|
|
|
* @param string $message_status |
71
|
|
|
* @param string $messenger |
72
|
|
|
* @param string $context |
73
|
|
|
*/ |
74
|
|
|
public function verifyMatchingCountofTextInMessageActivityListTableFor( |
75
|
|
|
$expected_occurence_count, |
76
|
|
|
$text_to_check_for, |
77
|
|
|
$field, |
78
|
|
|
$message_type_label, |
79
|
|
|
$message_status = MessagesPage::MESSAGE_STATUS_SENT, |
80
|
|
|
$messenger = 'Email', |
81
|
|
|
$context = 'Event Admin' |
82
|
|
|
) { |
83
|
|
|
$elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
|
|
|
84
|
|
|
$field, |
85
|
|
|
$message_type_label, |
86
|
|
|
$message_status, |
87
|
|
|
$messenger, |
88
|
|
|
$context, |
89
|
|
|
$text_to_check_for |
90
|
|
|
)); |
91
|
|
|
$actual_count = count($elements); |
92
|
|
|
$this->actor()->assertEquals( |
|
|
|
|
93
|
|
|
$expected_occurence_count, |
94
|
|
|
$actual_count, |
95
|
|
|
sprintf( |
96
|
|
|
'Expected %s of the %s text for the %s field but there were actually %s counted.', |
97
|
|
|
$expected_occurence_count, |
98
|
|
|
$text_to_check_for, |
99
|
|
|
$field, |
100
|
|
|
$actual_count |
101
|
|
|
) |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
} |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.