Completed
Branch FET-3467-waitlists (bb55f8)
by
unknown
68:09 queued 54:37
created

verifyMatchingCountofTextInMessageActivityListTableFor()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 25
nc 1
nop 7
dl 0
loc 30
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
        ));
100
        $actual_count = count($elements);
101
        $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...
102
            $expected_occurence_count,
103
            $actual_count,
104
            sprintf(
105
                'Expected %s of the %s text for the %s field but there were actually %s counted.',
106
                $expected_occurence_count,
107
                $text_to_check_for,
108
                $field,
109
                $actual_count
110
            )
111
        );
112
    }
113
114
}