Completed
Branch FET-10785-ee-system-loader (4ec117)
by
unknown
139:17 queued 127:33
created

deleteMessageInMessagesListTableFor()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 23
nc 1
nop 5
dl 0
loc 29
rs 8.8571
c 0
b 0
f 0
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));
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
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));
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
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));
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
39
    }
40
41
42
    /**
43
     * Directs to message settings page
44
     */
45
    public function amOnMessageSettingsPage()
46
    {
47
        $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
48
    }
49
50
51
    public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
    {
53
        $this->actor()->dragAndDrop(
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
54
            MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
            MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
        );
57
    }
58
59
60
    /**
61
     * Assumes you are already on the list table page that has the ui for editing the template.
62
     * @param string $message_type_slug
63
     * @param string $context [optional] if you want to click directly to the given context in the editor
64
     */
65
    public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
    {
67
        $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
68
    }
69
70
71
    /**
72
     * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
     * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
     *
75
     * @param int    $expected_occurence_count
76
     * @param string $text_to_check_for
77
     * @param string $field
78
     * @param string $message_type_label
79
     * @param string $message_status
80
     * @param string $messenger
81
     * @param string $context
82
     */
83
    public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
        $expected_occurence_count,
85
        $text_to_check_for,
86
        $field,
87
        $message_type_label,
88
        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
        $messenger = 'Email',
90
        $context = 'Event Admin'
91
    ) {
92
        $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
93
            $field,
94
            $message_type_label,
95
            $message_status,
96
            $messenger,
97
            $context,
98
            $text_to_check_for,
99
            0
100
        ));
101
        $actual_count = count($elements);
102
        $this->actor()->assertEquals(
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
103
            $expected_occurence_count,
104
            $actual_count,
105
            sprintf(
106
                'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
                $expected_occurence_count,
108
                $text_to_check_for,
109
                $field,
110
                $actual_count
111
            )
112
        );
113
    }
114
115
116
    /**
117
     * This will create a custom message template for the given messenger and message type from the context of the
118
     * default (global) message template list table.
119
     * Also takes care of verifying the template was created.
120
     * @param string $message_type_label
121
     * @param string $messenger_label
122
     */
123
    public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
    {
125
        $this->amOnDefaultMessageTemplateListTablePage();
126
        $this->actor()->click(
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
127
            MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
                $message_type_label,
129
                $messenger_label
130
            )
131
        );
132
        $this->actor()->seeInField('#title', 'New Custom Template');
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
133
    }
134
135
136
    /**
137
     * This switches the context of the current messages template to the given reference.
138
     * @param string $context_reference  This should be the visible label for the option.
139
     */
140
    public function switchContextTo($context_reference)
141
    {
142
        $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
143
        $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
144
        $this->actor()->waitForText($context_reference, 10, 'h1');
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
145
    }
146
147
148
    /**
149
     * This takes care of clicking the View Message icon for the given parameters.
150
     * Assumes you are already viewing the messages activity list table.
151
     * @param        $message_type_label
152
     * @param        $message_status
153
     * @param string $messenger
154
     * @param string $context
155
     * @param int    $number_in_set
156
     */
157
    public function viewMessageInMessagesListTableFor(
158
        $message_type_label,
159
        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
160
        $messenger = 'Email',
161
        $context = 'Event Admin',
162
        $number_in_set = 1
163
    ) {
164
        $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
165
            $message_type_label,
166
            $message_status,
167
            $messenger,
168
            $context,
169
            $number_in_set
170
        ));
171
    }
172
173
174
    /**
175
     * Takes care of deleting a message matching the given parameters via the message activity list table.
176
     * Assumes you are already viewing the messages activity list table.
177
     * @param        $message_type_label
178
     * @param        $message_status
179
     * @param string $messenger
180
     * @param string $context
181
     * @param int    $number_in_set
182
     */
183
    public function deleteMessageInMessagesListTableFor(
184
        $message_type_label,
185
        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
186
        $messenger = 'Email',
187
        $context = 'Event Admin',
188
        $number_in_set = 1
189
    ) {
190
        $this->actor()->moveMouseOver(
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
191
            MessagesPage::messagesActivityListTableCellSelectorFor(
192
                'to',
193
                $message_type_label,
194
                $message_status,
195
                $messenger,
196
                $context,
197
                '',
198
                $number_in_set
199
            )
200
        );
201
        $this->actor()->click(
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
202
            MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
203
                $message_type_label,
204
                $message_status,
205
                $messenger,
206
                $context,
207
                $number_in_set
208
            )
209
        );
210
        $this->actor()->waitForText('successfully deleted');
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
211
    }
212
213
214
    /**
215
     * Assuming you have already triggered the view modal for a single message from the context of the message activity
216
     * list table, this will take care of validating the given text is in that window.
217
     * @param string $text_to_view
218
     */
219
    public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
220
    {
221
        $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
222
        $this->actor()->switchToIframe('message-view-window');
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
223
        $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
224
        $this->actor()->switchToIframe();
0 ignored issues
show
Bug introduced by
It seems like actor() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). 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.

Loading history...
225
    }
226
227
228
    /**
229
     * Assuming you have already triggered the view modal for a single message from the context of the message activity
230
     * list table, this will take care of validating the given text is NOT that window.
231
     * @param string $text_to_view
232
     */
233
    public function dontSeeTextInViewMessageModal($text_to_view)
234
    {
235
        $this->seeTextInViewMessageModal($text_to_view, true);
236
    }
237
}
238