Completed
Branch BUG-10738-inconsistency-in-ses... (8f6fbc)
by
unknown
74:03 queued 63:31
created

BaseCoreAdmin::submitBulkActionOnListTable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace EventEspresso\Codeception\helpers;
3
4
use Page\CoreAdmin;
5
6
/**
7
 * Trait BaseCoreAdmin
8
 * Contains actions for more generic EE Admin page navigation.  Generally speaking it is preferable to create a helper
9
 * specific to an EE admin page you want actions for, but this is provided for quicker setup as necessary.
10
 *
11
 * @package EventEspresso\Codeception\helpers
12
 */
13
trait BaseCoreAdmin
14
{
15
16
    /**
17
     * Core method for going to an Event Espresso Admin page.
18
     * @param string $page
19
     * @param string $action
20
     * @param string $additional_params
21
     */
22
    public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
    {
24
        $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
    }
26
27
28
    /**
29
     * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
     * @return \EventEspressoAcceptanceTester;
31
     */
32
    protected function actor()
33
    {
34
        /** @var \EventEspressoAcceptanceTester $this */
35
        return $this;
36
    }
37
38
39
    /**
40
     * Use this to set the per page option for a list table page.
41
     * Assumes you are on a page that has this field exposed.
42
     *
43
     * @param int|string $per_page_value
44
     * @throws \Codeception\Exception\TestRuntimeException
45
     */
46
    public function setPerPageOptionForScreen($per_page_value)
47
    {
48
        $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
49
        $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
50
        $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
51
        $this->actor()->wait(8);
52
    }
53
54
55
56
    /**
57
     * Use this to append a given value to a wpEditor instance.
58
     * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and
59
     * the value is added to the text area.
60
     *
61
     * @param $field_reference
62
     * @param $value
63
     * @throws \Codeception\Exception\ElementNotFound
64
     */
65
    public function appendToWPEditorField($field_reference, $value)
66
    {
67
        $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference));
68
        $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value);
69
    }
70
71
72
    /**
73
     * Use to select and submit the given bulk action.
74
     * @param string $bulk_action_option
75
     */
76
    public function submitBulkActionOnListTable($bulk_action_option)
77
    {
78
        $this->actor()->selectOption(
79
            CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTION_FIELD,
80
            $bulk_action_option
81
        );
82
        $this->actor()->click(CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY);
83
    }
84
}
85