Completed
Branch FET/extract-activation-detecti... (285969)
by
unknown
10:31 queued 07:29
created
core/domain/services/commands/attendee/CreateAttendeeCommandHandler.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
     public function handle(CommandInterface $command)
52 52
     {
53 53
         /** @var CreateAttendeeCommand $command */
54
-        if (! $command instanceof CreateAttendeeCommand) {
54
+        if ( ! $command instanceof CreateAttendeeCommand) {
55 55
             throw new InvalidEntityException(get_class($command), 'CreateAttendeeCommand');
56 56
         }
57 57
         // have we met before?
Please login to merge, or discard this patch.
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -20,142 +20,142 @@
 block discarded – undo
20 20
  */
21 21
 class CreateAttendeeCommandHandler extends CommandHandler
22 22
 {
23
-    /**
24
-     * @var EEM_Attendee $attendee_model
25
-     */
26
-    protected $attendee_model;
23
+	/**
24
+	 * @var EEM_Attendee $attendee_model
25
+	 */
26
+	protected $attendee_model;
27 27
 
28 28
 
29
-    /**
30
-     * @param EEM_Attendee $attendee_model
31
-     */
32
-    public function __construct(EEM_Attendee $attendee_model)
33
-    {
34
-        defined('EVENT_ESPRESSO_VERSION') || exit;
35
-        $this->attendee_model = $attendee_model;
36
-    }
29
+	/**
30
+	 * @param EEM_Attendee $attendee_model
31
+	 */
32
+	public function __construct(EEM_Attendee $attendee_model)
33
+	{
34
+		defined('EVENT_ESPRESSO_VERSION') || exit;
35
+		$this->attendee_model = $attendee_model;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @param CommandInterface|CreateAttendeeCommand $command
41
-     * @return EE_Attendee
42
-     * @throws EE_Error
43
-     * @throws InvalidEntityException
44
-     */
45
-    public function handle(CommandInterface $command)
46
-    {
47
-        /** @var CreateAttendeeCommand $command */
48
-        if (! $command instanceof CreateAttendeeCommand) {
49
-            throw new InvalidEntityException(get_class($command), 'CreateAttendeeCommand');
50
-        }
51
-        // have we met before?
52
-        $attendee = $this->findExistingAttendee(
53
-            $command->registration(),
54
-            $command->attendeeDetails()
55
-        );
56
-        // did we find an already existing record for this attendee ?
57
-        if ($attendee instanceof EE_Attendee) {
58
-            $attendee = $this->updateExistingAttendeeData(
59
-                $attendee,
60
-                $command->attendeeDetails()
61
-            );
62
-        } else {
63
-            $attendee = $this->createNewAttendee(
64
-                $command->registration(),
65
-                $command->attendeeDetails()
66
-            );
67
-        }
68
-        return $attendee;
69
-    }
39
+	/**
40
+	 * @param CommandInterface|CreateAttendeeCommand $command
41
+	 * @return EE_Attendee
42
+	 * @throws EE_Error
43
+	 * @throws InvalidEntityException
44
+	 */
45
+	public function handle(CommandInterface $command)
46
+	{
47
+		/** @var CreateAttendeeCommand $command */
48
+		if (! $command instanceof CreateAttendeeCommand) {
49
+			throw new InvalidEntityException(get_class($command), 'CreateAttendeeCommand');
50
+		}
51
+		// have we met before?
52
+		$attendee = $this->findExistingAttendee(
53
+			$command->registration(),
54
+			$command->attendeeDetails()
55
+		);
56
+		// did we find an already existing record for this attendee ?
57
+		if ($attendee instanceof EE_Attendee) {
58
+			$attendee = $this->updateExistingAttendeeData(
59
+				$attendee,
60
+				$command->attendeeDetails()
61
+			);
62
+		} else {
63
+			$attendee = $this->createNewAttendee(
64
+				$command->registration(),
65
+				$command->attendeeDetails()
66
+			);
67
+		}
68
+		return $attendee;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * find_existing_attendee
74
-     *
75
-     * @param EE_Registration $registration
76
-     * @param array           $attendee_data
77
-     * @return EE_Attendee
78
-     * @throws EE_Error
79
-     */
80
-    private function findExistingAttendee(EE_Registration $registration, array $attendee_data)
81
-    {
82
-        $existing_attendee = null;
83
-        // does this attendee already exist in the db ?
84
-        // we're searching using a combination of first name, last name, AND email address
85
-        $ATT_fname = ! empty($attendee_data['ATT_fname'])
86
-            ? $attendee_data['ATT_fname']
87
-            : '';
88
-        $ATT_lname = ! empty($attendee_data['ATT_lname'])
89
-            ? $attendee_data['ATT_lname']
90
-            : '';
91
-        $ATT_email = ! empty($attendee_data['ATT_email'])
92
-            ? $attendee_data['ATT_email']
93
-            : '';
94
-        // but only if those have values
95
-        if ($ATT_fname && $ATT_lname && $ATT_email) {
96
-            $existing_attendee = $this->attendee_model->find_existing_attendee(
97
-                [
98
-                    'ATT_fname' => $ATT_fname,
99
-                    'ATT_lname' => $ATT_lname,
100
-                    'ATT_email' => $ATT_email,
101
-                ]
102
-            );
103
-        }
104
-        return apply_filters(
105
-            'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
106
-            $existing_attendee,
107
-            $registration,
108
-            $attendee_data
109
-        );
110
-    }
72
+	/**
73
+	 * find_existing_attendee
74
+	 *
75
+	 * @param EE_Registration $registration
76
+	 * @param array           $attendee_data
77
+	 * @return EE_Attendee
78
+	 * @throws EE_Error
79
+	 */
80
+	private function findExistingAttendee(EE_Registration $registration, array $attendee_data)
81
+	{
82
+		$existing_attendee = null;
83
+		// does this attendee already exist in the db ?
84
+		// we're searching using a combination of first name, last name, AND email address
85
+		$ATT_fname = ! empty($attendee_data['ATT_fname'])
86
+			? $attendee_data['ATT_fname']
87
+			: '';
88
+		$ATT_lname = ! empty($attendee_data['ATT_lname'])
89
+			? $attendee_data['ATT_lname']
90
+			: '';
91
+		$ATT_email = ! empty($attendee_data['ATT_email'])
92
+			? $attendee_data['ATT_email']
93
+			: '';
94
+		// but only if those have values
95
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
96
+			$existing_attendee = $this->attendee_model->find_existing_attendee(
97
+				[
98
+					'ATT_fname' => $ATT_fname,
99
+					'ATT_lname' => $ATT_lname,
100
+					'ATT_email' => $ATT_email,
101
+				]
102
+			);
103
+		}
104
+		return apply_filters(
105
+			'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
106
+			$existing_attendee,
107
+			$registration,
108
+			$attendee_data
109
+		);
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * _update_existing_attendee_data
115
-     * in case it has changed since last time they registered for an event
116
-     *
117
-     * @param EE_Attendee $existing_attendee
118
-     * @param array       $attendee_data
119
-     * @return EE_Attendee
120
-     * @throws EE_Error
121
-     */
122
-    private function updateExistingAttendeeData(EE_Attendee $existing_attendee, array $attendee_data)
123
-    {
124
-        // first remove fname, lname, and email from attendee data
125
-        // because these properties will be exactly the same as the returned attendee object,
126
-        // since they were used in the query to get the attendee object in the first place
127
-        $dont_set = ['ATT_fname', 'ATT_lname', 'ATT_email'];
128
-        // now loop thru what's left and add to attendee CPT
129
-        foreach ($attendee_data as $property_name => $property_value) {
130
-            if (
131
-                ! in_array($property_name, $dont_set, true)
132
-                && $this->attendee_model->has_field($property_name)
133
-            ) {
134
-                $existing_attendee->set($property_name, $property_value);
135
-            }
136
-        }
137
-        // better save that now
138
-        $existing_attendee->save();
139
-        return $existing_attendee;
140
-    }
113
+	/**
114
+	 * _update_existing_attendee_data
115
+	 * in case it has changed since last time they registered for an event
116
+	 *
117
+	 * @param EE_Attendee $existing_attendee
118
+	 * @param array       $attendee_data
119
+	 * @return EE_Attendee
120
+	 * @throws EE_Error
121
+	 */
122
+	private function updateExistingAttendeeData(EE_Attendee $existing_attendee, array $attendee_data)
123
+	{
124
+		// first remove fname, lname, and email from attendee data
125
+		// because these properties will be exactly the same as the returned attendee object,
126
+		// since they were used in the query to get the attendee object in the first place
127
+		$dont_set = ['ATT_fname', 'ATT_lname', 'ATT_email'];
128
+		// now loop thru what's left and add to attendee CPT
129
+		foreach ($attendee_data as $property_name => $property_value) {
130
+			if (
131
+				! in_array($property_name, $dont_set, true)
132
+				&& $this->attendee_model->has_field($property_name)
133
+			) {
134
+				$existing_attendee->set($property_name, $property_value);
135
+			}
136
+		}
137
+		// better save that now
138
+		$existing_attendee->save();
139
+		return $existing_attendee;
140
+	}
141 141
 
142 142
 
143
-    /**
144
-     * create_new_attendee
145
-     *
146
-     * @param EE_Registration $registration
147
-     * @param array           $attendee_data
148
-     * @return EE_Attendee
149
-     * @throws EE_Error
150
-     * @throws EntityNotFoundException
151
-     */
152
-    private function createNewAttendee(EE_Registration $registration, array $attendee_data)
153
-    {
154
-        // create new attendee object
155
-        $new_attendee = EE_Attendee::new_instance($attendee_data);
156
-        // set author to event creator
157
-        $new_attendee->set('ATT_author', $registration->event()->wp_user());
158
-        $new_attendee->save();
159
-        return $new_attendee;
160
-    }
143
+	/**
144
+	 * create_new_attendee
145
+	 *
146
+	 * @param EE_Registration $registration
147
+	 * @param array           $attendee_data
148
+	 * @return EE_Attendee
149
+	 * @throws EE_Error
150
+	 * @throws EntityNotFoundException
151
+	 */
152
+	private function createNewAttendee(EE_Registration $registration, array $attendee_data)
153
+	{
154
+		// create new attendee object
155
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
156
+		// set author to event creator
157
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
158
+		$new_attendee->save();
159
+		return $new_attendee;
160
+	}
161 161
 }
Please login to merge, or discard this patch.
core/domain/services/commands/attendee/CreateAttendeeCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
     public function getCapCheck()
82 82
     {
83 83
         // need cap for non-AJAX admin requests
84
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
84
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
85 85
             return new CapCheck('ee_edit_contacts', 'create_new_contact');
86 86
         }
87 87
         return new PublicCapabilities('', 'create_new_contact');
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -20,62 +20,62 @@
 block discarded – undo
20 20
  */
21 21
 class CreateAttendeeCommand extends Command implements CommandRequiresCapCheckInterface
22 22
 {
23
-    /**
24
-     * array of details where keys are names of EEM_Attendee model fields
25
-     *
26
-     * @var array $attendee_details
27
-     */
28
-    protected $attendee_details;
23
+	/**
24
+	 * array of details where keys are names of EEM_Attendee model fields
25
+	 *
26
+	 * @var array $attendee_details
27
+	 */
28
+	protected $attendee_details;
29 29
 
30
-    /**
31
-     * an existing registration to associate this attendee with
32
-     *
33
-     * @var EE_Registration $registration
34
-     */
35
-    protected $registration;
30
+	/**
31
+	 * an existing registration to associate this attendee with
32
+	 *
33
+	 * @var EE_Registration $registration
34
+	 */
35
+	protected $registration;
36 36
 
37 37
 
38
-    /**
39
-     * CreateAttendeeCommand constructor.
40
-     *
41
-     * @param array           $attendee_details
42
-     * @param EE_Registration $registration
43
-     */
44
-    public function __construct(array $attendee_details, EE_Registration $registration)
45
-    {
46
-        $this->attendee_details = $attendee_details;
47
-        $this->registration     = $registration;
48
-    }
38
+	/**
39
+	 * CreateAttendeeCommand constructor.
40
+	 *
41
+	 * @param array           $attendee_details
42
+	 * @param EE_Registration $registration
43
+	 */
44
+	public function __construct(array $attendee_details, EE_Registration $registration)
45
+	{
46
+		$this->attendee_details = $attendee_details;
47
+		$this->registration     = $registration;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * @return array
53
-     */
54
-    public function attendeeDetails()
55
-    {
56
-        return $this->attendee_details;
57
-    }
51
+	/**
52
+	 * @return array
53
+	 */
54
+	public function attendeeDetails()
55
+	{
56
+		return $this->attendee_details;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * @return EE_Registration
62
-     */
63
-    public function registration()
64
-    {
65
-        return $this->registration;
66
-    }
60
+	/**
61
+	 * @return EE_Registration
62
+	 */
63
+	public function registration()
64
+	{
65
+		return $this->registration;
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * @return CapCheckInterface
71
-     * @throws InvalidDataTypeException
72
-     */
73
-    public function getCapCheck()
74
-    {
75
-        // need cap for non-AJAX admin requests
76
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
77
-            return new CapCheck('ee_edit_contacts', 'create_new_contact');
78
-        }
79
-        return new PublicCapabilities('', 'create_new_contact');
80
-    }
69
+	/**
70
+	 * @return CapCheckInterface
71
+	 * @throws InvalidDataTypeException
72
+	 */
73
+	public function getCapCheck()
74
+	{
75
+		// need cap for non-AJAX admin requests
76
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
77
+			return new CapCheck('ee_edit_contacts', 'create_new_contact');
78
+		}
79
+		return new PublicCapabilities('', 'create_new_contact');
80
+	}
81 81
 }
Please login to merge, or discard this patch.
core/services/collections/iterators/CollectionFilterCallbackIterator.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -9,51 +9,51 @@
 block discarded – undo
9 9
 class CollectionFilterCallbackIterator extends FilterIterator
10 10
 {
11 11
 
12
-    /**
13
-     * Used for determining whether the iterated object in the Collection is "valid" or not.
14
-     * @var Closure
15
-     */
16
-    private $acceptance_callback;
17
-
18
-
19
-    /**
20
-     * CollectionFilterCallbackIterator constructor.
21
-     *
22
-     * @param Collection $collection
23
-     * @param Closure    $acceptance_callback  The closure will receive an instance of whatever object is stored on the
24
-     *                                         collection when iterating over the collection and should return boolean.
25
-     */
26
-    public function __construct(Collection $collection, Closure $acceptance_callback)
27
-    {
28
-        $this->acceptance_callback = $acceptance_callback;
29
-        parent::__construct($collection);
30
-    }
31
-
32
-    /**
33
-     * Check whether the current element of the iterator is acceptable
34
-     *
35
-     * @link  http://php.net/manual/en/filteriterator.accept.php
36
-     * @return bool true if the current element is acceptable, otherwise false.
37
-     */
38
-    public function accept()
39
-    {
40
-        $acceptance_callback = $this->acceptance_callback;
41
-        return $acceptance_callback($this->getInnerIterator()->current());
42
-    }
43
-
44
-
45
-
46
-    /**
47
-     * Returns a filtered array of objects from the collection using the provided acceptance callback
48
-     * @return array
49
-     */
50
-    public function getFiltered()
51
-    {
52
-        $filtered_array = array();
53
-        $this->rewind();
54
-        foreach ($this as $filtered_object) {
55
-            $filtered_array[] = $filtered_object;
56
-        }
57
-        return $filtered_array;
58
-    }
12
+	/**
13
+	 * Used for determining whether the iterated object in the Collection is "valid" or not.
14
+	 * @var Closure
15
+	 */
16
+	private $acceptance_callback;
17
+
18
+
19
+	/**
20
+	 * CollectionFilterCallbackIterator constructor.
21
+	 *
22
+	 * @param Collection $collection
23
+	 * @param Closure    $acceptance_callback  The closure will receive an instance of whatever object is stored on the
24
+	 *                                         collection when iterating over the collection and should return boolean.
25
+	 */
26
+	public function __construct(Collection $collection, Closure $acceptance_callback)
27
+	{
28
+		$this->acceptance_callback = $acceptance_callback;
29
+		parent::__construct($collection);
30
+	}
31
+
32
+	/**
33
+	 * Check whether the current element of the iterator is acceptable
34
+	 *
35
+	 * @link  http://php.net/manual/en/filteriterator.accept.php
36
+	 * @return bool true if the current element is acceptable, otherwise false.
37
+	 */
38
+	public function accept()
39
+	{
40
+		$acceptance_callback = $this->acceptance_callback;
41
+		return $acceptance_callback($this->getInnerIterator()->current());
42
+	}
43
+
44
+
45
+
46
+	/**
47
+	 * Returns a filtered array of objects from the collection using the provided acceptance callback
48
+	 * @return array
49
+	 */
50
+	public function getFiltered()
51
+	{
52
+		$filtered_array = array();
53
+		$this->rewind();
54
+		foreach ($this as $filtered_object) {
55
+			$filtered_array[] = $filtered_object;
56
+		}
57
+		return $filtered_array;
58
+	}
59 59
 }
Please login to merge, or discard this patch.
core/domain/values/Url.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     private function setScheme($url)
93 93
     {
94
-        $this->scheme = $url['scheme'] . '://';
94
+        $this->scheme = $url['scheme'].'://';
95 95
     }
96 96
 
97 97
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public function queryString()
147 147
     {
148
-        return $this->query !== '' ? '?' . $this->query : '';
148
+        return $this->query !== '' ? '?'.$this->query : '';
149 149
     }
150 150
 
151 151
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function fragment()
180 180
     {
181
-        return $this->fragment !== '' ? '#' . $this->fragment : '';
181
+        return $this->fragment !== '' ? '#'.$this->fragment : '';
182 182
     }
183 183
 
184 184
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      */
200 200
     public function getFullUrl()
201 201
     {
202
-        return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment();
202
+        return $this->scheme().$this->host().$this->path().$this->queryString().$this->fragment();
203 203
     }
204 204
 
205 205
 
Please login to merge, or discard this patch.
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -16,199 +16,199 @@
 block discarded – undo
16 16
  */
17 17
 class Url
18 18
 {
19
-    /**
20
-     * @var string $scheme
21
-     */
22
-    private $scheme;
23
-
24
-    /**
25
-     * @var string $host
26
-     */
27
-    private $host;
28
-
29
-    /**
30
-     * @var string $path
31
-     */
32
-    private $path;
33
-
34
-    /**
35
-     * @var string $query
36
-     */
37
-    private $query;
38
-
39
-    /**
40
-     * @var string $fragment
41
-     */
42
-    private $fragment;
43
-
44
-
45
-    /**
46
-     * Url constructor.
47
-     *
48
-     * @param $url
49
-     * @throws InvalidArgumentException
50
-     */
51
-    public function __construct($url)
52
-    {
53
-        if (
54
-            ! filter_var(
55
-                $url,
56
-                FILTER_VALIDATE_URL
57
-            )
58
-        ) {
59
-            throw new InvalidArgumentException(
60
-                esc_html__(
61
-                    'Invalid URL. Both the "Scheme" and "Host" are required.',
62
-                    'event_espresso'
63
-                )
64
-            );
65
-        }
66
-        $url = parse_url($url);
67
-        $this->setScheme($url);
68
-        $this->setHost($url);
69
-        $this->setPath($url);
70
-        $this->setQuery($url);
71
-        $this->setFragment($url);
72
-    }
73
-
74
-
75
-    /**
76
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
77
-     * will return a string like: 'abc://'
78
-     *
79
-     * @return string
80
-     */
81
-    public function scheme()
82
-    {
83
-        return $this->scheme;
84
-    }
85
-
86
-
87
-    /**
88
-     * @param array $url
89
-     */
90
-    private function setScheme($url)
91
-    {
92
-        $this->scheme = $url['scheme'] . '://';
93
-    }
94
-
95
-
96
-    /**
97
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
98
-     * will return a string like: 'example.com'
99
-     *
100
-     * @return string
101
-     */
102
-    public function host()
103
-    {
104
-        return $this->host;
105
-    }
106
-
107
-
108
-    /**
109
-     * @param array $url
110
-     */
111
-    private function setHost($url)
112
-    {
113
-        $this->host = $url['host'];
114
-    }
115
-
116
-
117
-    /**
118
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
119
-     * will return a string like: '/path/data'
120
-     *
121
-     * @return string
122
-     */
123
-    public function path()
124
-    {
125
-        return $this->path;
126
-    }
127
-
128
-
129
-    /**
130
-     * @param array $url
131
-     */
132
-    private function setPath($url)
133
-    {
134
-        $this->path = isset($url['path']) ? $url['path'] : '';
135
-    }
136
-
137
-
138
-    /**
139
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
140
-     * will return a string like: '?key=value'
141
-     *
142
-     * @return string
143
-     */
144
-    public function queryString()
145
-    {
146
-        return $this->query !== '' ? '?' . $this->query : '';
147
-    }
148
-
149
-
150
-    /**
151
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
152
-     * will return an array like: array('key' => 'value')
153
-     *
154
-     * @return array
155
-     */
156
-    public function queryParams()
157
-    {
158
-        return wp_parse_args($this->query);
159
-    }
160
-
161
-
162
-    /**
163
-     * @param array $url
164
-     */
165
-    private function setQuery($url)
166
-    {
167
-        $this->query = isset($url['query']) ? $url['query'] : '';
168
-    }
169
-
170
-
171
-    /**
172
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
173
-     * will return a string like: '#id'
174
-     *
175
-     * @return string
176
-     */
177
-    public function fragment()
178
-    {
179
-        return $this->fragment !== '' ? '#' . $this->fragment : '';
180
-    }
181
-
182
-
183
-    /**
184
-     * @param array $url
185
-     */
186
-    private function setFragment($url)
187
-    {
188
-        $this->fragment = isset($url['fragment']) ? $url['fragment'] : '';
189
-    }
190
-
191
-
192
-    /**
193
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
194
-     * will return a string like: 'abc://example.com/path/data?key=value#id'
195
-     *
196
-     * @return string
197
-     */
198
-    public function getFullUrl()
199
-    {
200
-        return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment();
201
-    }
202
-
203
-
204
-    /**
205
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
206
-     * will return a string like: 'abc://example.com/path/data?key=value#id'
207
-     *
208
-     * @return string
209
-     */
210
-    public function __toString()
211
-    {
212
-        return $this->getFullUrl();
213
-    }
19
+	/**
20
+	 * @var string $scheme
21
+	 */
22
+	private $scheme;
23
+
24
+	/**
25
+	 * @var string $host
26
+	 */
27
+	private $host;
28
+
29
+	/**
30
+	 * @var string $path
31
+	 */
32
+	private $path;
33
+
34
+	/**
35
+	 * @var string $query
36
+	 */
37
+	private $query;
38
+
39
+	/**
40
+	 * @var string $fragment
41
+	 */
42
+	private $fragment;
43
+
44
+
45
+	/**
46
+	 * Url constructor.
47
+	 *
48
+	 * @param $url
49
+	 * @throws InvalidArgumentException
50
+	 */
51
+	public function __construct($url)
52
+	{
53
+		if (
54
+			! filter_var(
55
+				$url,
56
+				FILTER_VALIDATE_URL
57
+			)
58
+		) {
59
+			throw new InvalidArgumentException(
60
+				esc_html__(
61
+					'Invalid URL. Both the "Scheme" and "Host" are required.',
62
+					'event_espresso'
63
+				)
64
+			);
65
+		}
66
+		$url = parse_url($url);
67
+		$this->setScheme($url);
68
+		$this->setHost($url);
69
+		$this->setPath($url);
70
+		$this->setQuery($url);
71
+		$this->setFragment($url);
72
+	}
73
+
74
+
75
+	/**
76
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
77
+	 * will return a string like: 'abc://'
78
+	 *
79
+	 * @return string
80
+	 */
81
+	public function scheme()
82
+	{
83
+		return $this->scheme;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param array $url
89
+	 */
90
+	private function setScheme($url)
91
+	{
92
+		$this->scheme = $url['scheme'] . '://';
93
+	}
94
+
95
+
96
+	/**
97
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
98
+	 * will return a string like: 'example.com'
99
+	 *
100
+	 * @return string
101
+	 */
102
+	public function host()
103
+	{
104
+		return $this->host;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @param array $url
110
+	 */
111
+	private function setHost($url)
112
+	{
113
+		$this->host = $url['host'];
114
+	}
115
+
116
+
117
+	/**
118
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
119
+	 * will return a string like: '/path/data'
120
+	 *
121
+	 * @return string
122
+	 */
123
+	public function path()
124
+	{
125
+		return $this->path;
126
+	}
127
+
128
+
129
+	/**
130
+	 * @param array $url
131
+	 */
132
+	private function setPath($url)
133
+	{
134
+		$this->path = isset($url['path']) ? $url['path'] : '';
135
+	}
136
+
137
+
138
+	/**
139
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
140
+	 * will return a string like: '?key=value'
141
+	 *
142
+	 * @return string
143
+	 */
144
+	public function queryString()
145
+	{
146
+		return $this->query !== '' ? '?' . $this->query : '';
147
+	}
148
+
149
+
150
+	/**
151
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
152
+	 * will return an array like: array('key' => 'value')
153
+	 *
154
+	 * @return array
155
+	 */
156
+	public function queryParams()
157
+	{
158
+		return wp_parse_args($this->query);
159
+	}
160
+
161
+
162
+	/**
163
+	 * @param array $url
164
+	 */
165
+	private function setQuery($url)
166
+	{
167
+		$this->query = isset($url['query']) ? $url['query'] : '';
168
+	}
169
+
170
+
171
+	/**
172
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
173
+	 * will return a string like: '#id'
174
+	 *
175
+	 * @return string
176
+	 */
177
+	public function fragment()
178
+	{
179
+		return $this->fragment !== '' ? '#' . $this->fragment : '';
180
+	}
181
+
182
+
183
+	/**
184
+	 * @param array $url
185
+	 */
186
+	private function setFragment($url)
187
+	{
188
+		$this->fragment = isset($url['fragment']) ? $url['fragment'] : '';
189
+	}
190
+
191
+
192
+	/**
193
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
194
+	 * will return a string like: 'abc://example.com/path/data?key=value#id'
195
+	 *
196
+	 * @return string
197
+	 */
198
+	public function getFullUrl()
199
+	{
200
+		return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment();
201
+	}
202
+
203
+
204
+	/**
205
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
206
+	 * will return a string like: 'abc://example.com/path/data?key=value#id'
207
+	 *
208
+	 * @return string
209
+	 */
210
+	public function __toString()
211
+	{
212
+		return $this->getFullUrl();
213
+	}
214 214
 }
Please login to merge, or discard this patch.
acceptance_tests/tests/b-TestRegistrationSummaryCept.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 
15 15
 //need the MER plugin active for this test (we'll deactivate it after).
16 16
 $I->ensurePluginActive(
17
-    'event-espresso-mer-multi-event-registration',
18
-    'activated'
17
+	'event-espresso-mer-multi-event-registration',
18
+	'activated'
19 19
 );
20 20
 
21 21
 //k now we need to make sure the registration multi-status message type is active because it isn't by default
@@ -73,38 +73,38 @@  discard block
 block discarded – undo
73 73
 $I->loginAsAdmin();
74 74
 $I->amOnMessagesActivityListTablePage();
75 75
 $I->see(
76
-    '[email protected]',
77
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
78
-        'to',
79
-        'Registration Multi-status Summary',
80
-        MessagesAdmin::MESSAGE_STATUS_SENT,
81
-        '',
82
-        'Primary Registrant'
83
-    )
76
+	'[email protected]',
77
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
78
+		'to',
79
+		'Registration Multi-status Summary',
80
+		MessagesAdmin::MESSAGE_STATUS_SENT,
81
+		'',
82
+		'Primary Registrant'
83
+	)
84 84
 );
85 85
 $I->see(
86
-    '[email protected]',
87
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
88
-        'to',
89
-        'Registration Multi-status Summary',
90
-        MessagesAdmin::MESSAGE_STATUS_SENT
91
-    )
86
+	'[email protected]',
87
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
88
+		'to',
89
+		'Registration Multi-status Summary',
90
+		MessagesAdmin::MESSAGE_STATUS_SENT
91
+	)
92 92
 );
93 93
 //verify count
94 94
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
95
-    1,
96
-    '[email protected]',
97
-    'to',
98
-    'Registration Multi-status Summary',
99
-    MessagesAdmin::MESSAGE_STATUS_SENT,
100
-    'Email',
101
-    'Primary Registrant'
95
+	1,
96
+	'[email protected]',
97
+	'to',
98
+	'Registration Multi-status Summary',
99
+	MessagesAdmin::MESSAGE_STATUS_SENT,
100
+	'Email',
101
+	'Primary Registrant'
102 102
 );
103 103
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
104
-    1,
105
-    '[email protected]',
106
-    'to',
107
-    'Registration Multi-status Summary'
104
+	1,
105
+	'[email protected]',
106
+	'to',
107
+	'Registration Multi-status Summary'
108 108
 );
109 109
 
110 110
 //okay now let's do some registrations for just the first event and verify that registration multi-status summary is NOT
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
 $I->loginAsAdmin();
135 135
 $I->amOnMessagesActivityListTablePage();
136 136
 $I->dontSee(
137
-    '[email protected]',
138
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
139
-        'to',
140
-        'Registration Multi-status Summary',
141
-        MessagesAdmin::MESSAGE_STATUS_SENT,
142
-        '',
143
-        'Primary Registrant'
144
-    )
137
+	'[email protected]',
138
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
139
+		'to',
140
+		'Registration Multi-status Summary',
141
+		MessagesAdmin::MESSAGE_STATUS_SENT,
142
+		'',
143
+		'Primary Registrant'
144
+	)
145 145
 );
146 146
 //there should still only be one admin multi-status summary thing.
147 147
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
148
-    1,
149
-    '[email protected]',
150
-    'to',
151
-    'Registration Multi-status Summary'
148
+	1,
149
+	'[email protected]',
150
+	'to',
151
+	'Registration Multi-status Summary'
152 152
 );
153 153
 
154 154
 //deactivate MER plugin so its not active for future tests
155 155
 $I->ensurePluginDeactivated(
156
-    'event-espresso-mer-multi-event-registration',
157
-    'plugins deactivated'
156
+	'event-espresso-mer-multi-event-registration',
157
+	'plugins deactivated'
158 158
 );
159 159
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/tests/c-TestCustomMessageTemplateCept.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 $event_one_link = $event_two_link = $event_three_link = '';
19 19
 
20 20
 $I->wantTo(
21
-    'Test that when registrations for multiple events are completed, and those events share the same custom'
22
-    . 'template, that that custom template will be used.'
21
+	'Test that when registrations for multiple events are completed, and those events share the same custom'
22
+	. 'template, that that custom template will be used.'
23 23
 );
24 24
 
25 25
 //need the MER plugin active for this test (we'll deactivate it after).
26 26
 $I->ensurePluginActive(
27
-    'event-espresso-mer-multi-event-registration',
28
-    'activated'
27
+	'event-espresso-mer-multi-event-registration',
28
+	'activated'
29 29
 );
30 30
 
31 31
 $I->loginAsAdmin();
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 
81 81
 
82 82
 $test_registration_details = array(
83
-    'fname' => 'CTGuy',
84
-    'lname' => 'Dude',
85
-    'email' => '[email protected]'
83
+	'fname' => 'CTGuy',
84
+	'lname' => 'Dude',
85
+	'email' => '[email protected]'
86 86
 );
87 87
 
88 88
 $I->amGoingTo('Register for Event One and Event Two and verify Custom Template A was used.');
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 $I->loginAsAdmin();
109 109
 $I->amOnMessagesActivityListTablePage();
110 110
 $I->viewMessageInMessagesListTableFor(
111
-    'Registration Approved',
112
-    MessagesAdmin::MESSAGE_STATUS_SENT,
113
-    'Email',
114
-    'Registrant'
111
+	'Registration Approved',
112
+	MessagesAdmin::MESSAGE_STATUS_SENT,
113
+	'Email',
114
+	'Registrant'
115 115
 );
116 116
 $I->seeTextInViewMessageModal($custom_template_a_label);
117 117
 $I->dismissMessageModal();
118 118
 $I->deleteMessageInMessagesListTableFor(
119
-    'Registration Approved',
120
-    MessagesAdmin::MESSAGE_STATUS_SENT,
121
-    'Email',
122
-    'Registrant'
119
+	'Registration Approved',
120
+	MessagesAdmin::MESSAGE_STATUS_SENT,
121
+	'Email',
122
+	'Registrant'
123 123
 );
124 124
 
125 125
 //verify admin context
126 126
 $I->viewMessageInMessagesListTableFor(
127
-    'Registration Approved'
127
+	'Registration Approved'
128 128
 );
129 129
 $I->seeTextInViewMessageModal($custom_template_a_label);
130 130
 $I->dismissMessageModal();
@@ -153,25 +153,25 @@  discard block
 block discarded – undo
153 153
 $I->loginAsAdmin();
154 154
 $I->amOnMessagesActivityListTablePage();
155 155
 $I->viewMessageInMessagesListTableFor(
156
-    'Registration Approved',
157
-    MessagesAdmin::MESSAGE_STATUS_SENT,
158
-    'Email',
159
-    'Registrant'
156
+	'Registration Approved',
157
+	MessagesAdmin::MESSAGE_STATUS_SENT,
158
+	'Email',
159
+	'Registrant'
160 160
 );
161 161
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
162 162
 $I->dontSeeTextInViewMessageModal($custom_template_a_label);
163 163
 $I->dontSeeTextInViewMessageModal($custom_template_b_label);
164 164
 $I->dismissMessageModal();
165 165
 $I->deleteMessageInMessagesListTableFor(
166
-    'Registration Approved',
167
-    MessagesAdmin::MESSAGE_STATUS_SENT,
168
-    'Email',
169
-    'Registrant'
166
+	'Registration Approved',
167
+	MessagesAdmin::MESSAGE_STATUS_SENT,
168
+	'Email',
169
+	'Registrant'
170 170
 );
171 171
 
172 172
 //verify admin context
173 173
 $I->viewMessageInMessagesListTableFor(
174
-    'Registration Approved'
174
+	'Registration Approved'
175 175
 );
176 176
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
177 177
 $I->dontSee($custom_template_a_label);
@@ -183,6 +183,6 @@  discard block
 block discarded – undo
183 183
 
184 184
 //deactivate MER plugin so its not active for future tests
185 185
 $I->ensurePluginDeactivated(
186
-    'event-espresso-mer-multi-event-registration',
187
-    'plugins deactivated'
186
+	'event-espresso-mer-multi-event-registration',
187
+	'plugins deactivated'
188 188
 );
189 189
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/CountrySettingsAdmin.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -6,59 +6,59 @@
 block discarded – undo
6 6
 
7 7
 trait CountrySettingsAdmin
8 8
 {
9
-    /**
10
-     * Instructs the actor to browse to the country settings page.
11
-     * Assumes the actor is already logged in.
12
-     * @param string $additional_params
13
-     */
14
-    public function amOnCountrySettingsAdminPage($additional_params = '')
15
-    {
16
-        $this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
-    }
9
+	/**
10
+	 * Instructs the actor to browse to the country settings page.
11
+	 * Assumes the actor is already logged in.
12
+	 * @param string $additional_params
13
+	 */
14
+	public function amOnCountrySettingsAdminPage($additional_params = '')
15
+	{
16
+		$this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * Instructs the actor to select the given decimal places radio option.
22
-     * Assumes the actor is already on the country settings page.
23
-     * @param string $decimal_places
24
-     * @param string $country_code
25
-     */
26
-    public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
-    {
28
-        $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
-    }
20
+	/**
21
+	 * Instructs the actor to select the given decimal places radio option.
22
+	 * Assumes the actor is already on the country settings page.
23
+	 * @param string $decimal_places
24
+	 * @param string $country_code
25
+	 */
26
+	public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
+	{
28
+		$this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Instructs the actor to select the given decimal mark radio option.
34
-     * Assumes the actor is already on the country settings page.
35
-     * @param string $decimal_mark
36
-     */
37
-    public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
-    {
39
-        $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
-    }
32
+	/**
33
+	 * Instructs the actor to select the given decimal mark radio option.
34
+	 * Assumes the actor is already on the country settings page.
35
+	 * @param string $decimal_mark
36
+	 */
37
+	public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
+	{
39
+		$this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Instructs the actor to select the given thousands separator radio option.
45
-     * Assumes the actor is already on the country settings page.
46
-     * @param string $thousands_seperator
47
-     */
48
-    public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
-    {
50
-        $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
-    }
43
+	/**
44
+	 * Instructs the actor to select the given thousands separator radio option.
45
+	 * Assumes the actor is already on the country settings page.
46
+	 * @param string $thousands_seperator
47
+	 */
48
+	public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
+	{
50
+		$this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * Clicks the country settings submit button.
56
-     * Assumes the actor is on the country settings admin page.
57
-     */
58
-    public function saveCountrySettings()
59
-    {
60
-        $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
-        //no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
-        $this->actor()->wait(10);
63
-    }
54
+	/**
55
+	 * Clicks the country settings submit button.
56
+	 * Assumes the actor is on the country settings admin page.
57
+	 */
58
+	public function saveCountrySettings()
59
+	{
60
+		$this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
+		//no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
+		$this->actor()->wait(10);
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/RegistrationsAdmin.php 1 patch
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -15,139 +15,139 @@
 block discarded – undo
15 15
 trait RegistrationsAdmin
16 16
 {
17 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
-    }
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 152
 
153 153
 }
154 154
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/Checkout.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -13,75 +13,75 @@
 block discarded – undo
13 13
  */
14 14
 trait Checkout
15 15
 {
16
-    /**
17
-     * @param     $value
18
-     * @param int $attendee_number
19
-     * @param bool  $admin  Used to indicate whether we're filling out the field from the context of the admin or not.
20
-     */
21
-    public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1, $admin = false)
22
-    {
23
-        $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number, $admin), $value);
24
-    }
16
+	/**
17
+	 * @param     $value
18
+	 * @param int $attendee_number
19
+	 * @param bool  $admin  Used to indicate whether we're filling out the field from the context of the admin or not.
20
+	 */
21
+	public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1, $admin = false)
22
+	{
23
+		$this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number, $admin), $value);
24
+	}
25 25
 
26
-    /**
27
-     * @param     $value
28
-     * @param int $attendee_number
29
-     * @param bool  $admin  Used to indicate whether we're filling out the field from the context of the admin or not.
30
-     */
31
-    public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1, $admin = false)
32
-    {
33
-        $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number, $admin), $value);
34
-    }
26
+	/**
27
+	 * @param     $value
28
+	 * @param int $attendee_number
29
+	 * @param bool  $admin  Used to indicate whether we're filling out the field from the context of the admin or not.
30
+	 */
31
+	public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1, $admin = false)
32
+	{
33
+		$this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number, $admin), $value);
34
+	}
35 35
 
36
-    /**
37
-     * @param     $value
38
-     * @param int $attendee_number
39
-     * @param bool  $admin  Used to indicate whether we're filling out the field from the context of the admin or not.
40
-     */
41
-    public function fillOutEmailFieldForAttendee($value, $attendee_number = 1, $admin = false)
42
-    {
43
-        $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number, $admin), $value);
44
-    }
36
+	/**
37
+	 * @param     $value
38
+	 * @param int $attendee_number
39
+	 * @param bool  $admin  Used to indicate whether we're filling out the field from the context of the admin or not.
40
+	 */
41
+	public function fillOutEmailFieldForAttendee($value, $attendee_number = 1, $admin = false)
42
+	{
43
+		$this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number, $admin), $value);
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * Clicks the next registration step button.
49
-     */
50
-    public function goToNextRegistrationStep()
51
-    {
52
-        $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR);
53
-    }
47
+	/**
48
+	 * Clicks the next registration step button.
49
+	 */
50
+	public function goToNextRegistrationStep()
51
+	{
52
+		$this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR);
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * Selects the payment option for the given payment method slug.
58
-     *
59
-     * @param string $payment_method_slug
60
-     * @param bool   $verify_selected      If true, this will wait for the "Important Information" info box after the
61
-     *                                     payment option select box is complete.  Otherwise its up to calling code to
62
-     *                                     wait for whatever is needed after selecting the payment method.
63
-     */
64
-    public function selectPaymentOptionFor($payment_method_slug = 'invoice', $verify_selected = true)
65
-    {
66
-        $this->waitForElementVisible(CheckoutPage::SELECTOR_PAYMENT_OPTIONS_CONTAINER);
67
-        $this->wait(5);
68
-        $this->actor()->selectOption(
69
-            CheckoutPage::PAYMENT_METHOD_STEP_FORM,
70
-            $payment_method_slug
71
-        );
72
-        if ($verify_selected) {
73
-            $this->actor()->waitForText('Important information regarding your payment');
74
-        }
75
-    }
56
+	/**
57
+	 * Selects the payment option for the given payment method slug.
58
+	 *
59
+	 * @param string $payment_method_slug
60
+	 * @param bool   $verify_selected      If true, this will wait for the "Important Information" info box after the
61
+	 *                                     payment option select box is complete.  Otherwise its up to calling code to
62
+	 *                                     wait for whatever is needed after selecting the payment method.
63
+	 */
64
+	public function selectPaymentOptionFor($payment_method_slug = 'invoice', $verify_selected = true)
65
+	{
66
+		$this->waitForElementVisible(CheckoutPage::SELECTOR_PAYMENT_OPTIONS_CONTAINER);
67
+		$this->wait(5);
68
+		$this->actor()->selectOption(
69
+			CheckoutPage::PAYMENT_METHOD_STEP_FORM,
70
+			$payment_method_slug
71
+		);
72
+		if ($verify_selected) {
73
+			$this->actor()->waitForText('Important information regarding your payment');
74
+		}
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * Submits the payment options step form.
80
-     * Assumes the actor is in the context of the payment options SPCO step.
81
-     */
82
-    public function submitPaymentOptionsRegistrationStepForm()
83
-    {
84
-        $this->actor()->submitForm(CheckoutPage::PAYMENT_METHOD_STEP_FORM, array());
85
-    }
78
+	/**
79
+	 * Submits the payment options step form.
80
+	 * Assumes the actor is in the context of the payment options SPCO step.
81
+	 */
82
+	public function submitPaymentOptionsRegistrationStepForm()
83
+	{
84
+		$this->actor()->submitForm(CheckoutPage::PAYMENT_METHOD_STEP_FORM, array());
85
+	}
86 86
 
87 87
 }
88 88
\ No newline at end of file
Please login to merge, or discard this patch.