| Total Complexity | 87 |
| Total Lines | 1729 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like SettingFieldTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SettingFieldTest, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 12 | class SettingFieldTest extends \WP_UnitTestCase |
||
|
|
|||
| 13 | { |
||
| 14 | public function test_build_general_delete_data_on_uninstall(): void |
||
| 15 | { |
||
| 16 | $this->assertEquals( |
||
| 17 | $this->buildSetting('settings.general.delete_data_on_uninstall'), |
||
| 18 | '<tr class="glsr-setting-field" data-field="settings.general.delete_data_on_uninstall">'. |
||
| 19 | '<th scope="row">'. |
||
| 20 | '<label for="site_reviews-settings-general-delete_data_on_uninstall">Delete data on uninstall</label>'. |
||
| 21 | '</th>'. |
||
| 22 | '<td>'. |
||
| 23 | '<select class="regular-text" id="site_reviews-settings-general-delete_data_on_uninstall" data-glsr-track="" name="site_reviews[settings][general][delete_data_on_uninstall]">'. |
||
| 24 | '<option value="">Do not delete anything</option>'. |
||
| 25 | '<option value="minimal">Delete all plugin settings, widgets settings, and caches</option>'. |
||
| 26 | '<option value="all">Delete everything (including all reviews and categories)</option>'. |
||
| 27 | '</select>'. |
||
| 28 | '</td>'. |
||
| 29 | '</tr>' |
||
| 30 | ); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function test_build_general_style(): void |
||
| 34 | { |
||
| 35 | $this->assertEquals( |
||
| 36 | $this->buildSetting('settings.general.style'), |
||
| 37 | '<tr class="glsr-setting-field" data-field="settings.general.style">'. |
||
| 38 | '<th scope="row">'. |
||
| 39 | '<label for="site_reviews-settings-general-style">Plugin Style</label>'. |
||
| 40 | '</th>'. |
||
| 41 | '<td>'. |
||
| 42 | '<select class="regular-text" id="site_reviews-settings-general-style" name="site_reviews[settings][general][style]">'. |
||
| 43 | '<optgroup label="Styles">'. |
||
| 44 | '<option value="default">Site Reviews (default)</option>'. |
||
| 45 | '<option value="minimal">Site Reviews (minimal)</option>'. |
||
| 46 | '</optgroup>'. |
||
| 47 | '<optgroup label="Plugins">'. |
||
| 48 | '<option value="breakdance">Breakdance (v2)</option>'. |
||
| 49 | '<option value="contact_form_7">Contact Form 7 (v5)</option>'. |
||
| 50 | '<option value="elementor">Elementor Pro (v3)</option>'. |
||
| 51 | '<option value="ninja_forms">Ninja Forms (v3)</option>'. |
||
| 52 | '<option value="wpforms">WPForms (v1)</option>'. |
||
| 53 | '</optgroup>'. |
||
| 54 | '<optgroup label="Themes">'. |
||
| 55 | '<option value="bootstrap">Bootstrap (v5)</option>'. |
||
| 56 | '<option value="divi">Divi (v4)</option>'. |
||
| 57 | '<option value="twentyfifteen">Twenty Fifteen</option>'. |
||
| 58 | '<option value="twentysixteen">Twenty Sixteen</option>'. |
||
| 59 | '<option value="twentyseventeen">Twenty Seventeen</option>'. |
||
| 60 | '<option value="twentynineteen">Twenty Nineteen</option>'. |
||
| 61 | '<option value="twentytwenty">Twenty Twenty</option>'. |
||
| 62 | '<option value="twentytwentyone">Twenty Twenty-One</option>'. |
||
| 63 | '<option value="twentytwentytwo">Twenty Twenty-Two</option>'. |
||
| 64 | '</optgroup>'. |
||
| 65 | '</select>'. |
||
| 66 | '<p class="description">Description</p>'. |
||
| 67 | '</td>'. |
||
| 68 | '</tr>' |
||
| 69 | ); |
||
| 70 | } |
||
| 71 | |||
| 72 | public function test_build_general_request_verification(): void |
||
| 73 | { |
||
| 74 | $this->assertEquals( |
||
| 75 | $this->buildSetting('settings.general.request_verification'), |
||
| 76 | '<tr class="glsr-setting-field" data-field="settings.general.request_verification">'. |
||
| 77 | '<th scope="row">'. |
||
| 78 | '<label>Request Verification</label>'. |
||
| 79 | '</th>'. |
||
| 80 | '<td>'. |
||
| 81 | '<fieldset data-depends="">'. |
||
| 82 | '<legend class="screen-reader-text">'. |
||
| 83 | '<span>Request Verification</span>'. |
||
| 84 | '</legend>'. |
||
| 85 | '<div class="inline regular-text">'. |
||
| 86 | '<label for="site_reviews-settings-general-request_verification-1">'. |
||
| 87 | '<input type="radio" id="site_reviews-settings-general-request_verification-1" name="site_reviews[settings][general][request_verification]" value="no" /> No'. |
||
| 88 | '</label>'. |
||
| 89 | '<br>'. |
||
| 90 | '<label for="site_reviews-settings-general-request_verification-2">'. |
||
| 91 | '<input type="radio" id="site_reviews-settings-general-request_verification-2" name="site_reviews[settings][general][request_verification]" value="yes" /> Yes'. |
||
| 92 | '</label>'. |
||
| 93 | '</div>'. |
||
| 94 | '</fieldset>'. |
||
| 95 | '</td>'. |
||
| 96 | '</tr>' |
||
| 97 | ); |
||
| 98 | } |
||
| 99 | |||
| 100 | public function test_build_general_request_verification_message(): void |
||
| 101 | { |
||
| 102 | $this->assertEquals( |
||
| 103 | $this->buildSetting('settings.general.request_verification_message'), |
||
| 104 | '<tr class="glsr-setting-field" data-field="settings.general.request_verification_message">'. |
||
| 105 | '<th scope="row">'. |
||
| 106 | '<label for="site_reviews-settings-general-request_verification_message">'. |
||
| 107 | 'Verification Template'. |
||
| 108 | '</label>'. |
||
| 109 | '</th>'. |
||
| 110 | '<td>'. |
||
| 111 | '<div class="glsr-template-editor">'. |
||
| 112 | '<textarea '. |
||
| 113 | 'class="autosized code large-text" '. |
||
| 114 | 'id="site_reviews-settings-general-request_verification_message" '. |
||
| 115 | 'name="site_reviews[settings][general][request_verification_message]" '. |
||
| 116 | 'rows="3"'. |
||
| 117 | '></textarea>'. |
||
| 118 | '<div class="quicktags-toolbar">'. |
||
| 119 | '<input type="button" class="button button-small" data-tag="review_assigned_links" value="assigned links" />'. |
||
| 120 | '<input type="button" class="button button-small" data-tag="review_assigned_posts" value="assigned posts" />'. |
||
| 121 | '<input type="button" class="button button-small" data-tag="review_assigned_users" value="assigned users" />'. |
||
| 122 | '<input type="button" class="button button-small" data-tag="review_author" value="name" />'. |
||
| 123 | '<input type="button" class="button button-small" data-tag="review_categories" value="categories" />'. |
||
| 124 | '<input type="button" class="button button-small" data-tag="review_content" value="content" />'. |
||
| 125 | '<input type="button" class="button button-small" data-tag="review_email" value="email" />'. |
||
| 126 | '<input type="button" class="button button-small" data-tag="review_id" value="review id" />'. |
||
| 127 | '<input type="button" class="button button-small" data-tag="review_ip" value="ip address" />'. |
||
| 128 | '<input type="button" class="button button-small" data-tag="review_rating" value="rating" />'. |
||
| 129 | '<input type="button" class="button button-small" data-tag="review_response" value="response" />'. |
||
| 130 | '<input type="button" class="button button-small" data-tag="review_stars" value="stars" />'. |
||
| 131 | '<input type="button" class="button button-small" data-tag="review_title" value="title" />'. |
||
| 132 | '<input type="button" class="button button-small" data-tag="site_title" value="site title" />'. |
||
| 133 | '<input type="button" class="button button-small" data-tag="site_url" value="site url" />'. |
||
| 134 | '<input type="button" class="button button-small" data-tag="verify_url" value="verify url" />'. |
||
| 135 | '</div>'. |
||
| 136 | '</div>'. |
||
| 137 | '<p class="description">Description</p>'. |
||
| 138 | '</td>'. |
||
| 139 | '</tr>' |
||
| 140 | ); |
||
| 141 | } |
||
| 142 | |||
| 143 | public function test_build_general_require_approval(): void |
||
| 144 | { |
||
| 145 | $this->assertEquals( |
||
| 146 | $this->buildSetting('settings.general.require.approval'), |
||
| 147 | '<tr class="glsr-setting-field" data-field="settings.general.require.approval">'. |
||
| 148 | '<th scope="row">'. |
||
| 149 | '<label>'. |
||
| 150 | 'Require Approval'. |
||
| 151 | '</label>'. |
||
| 152 | '</th>'. |
||
| 153 | '<td>'. |
||
| 154 | '<fieldset data-depends="">'. |
||
| 155 | '<legend class="screen-reader-text">'. |
||
| 156 | '<span>Require Approval</span>'. |
||
| 157 | '</legend>'. |
||
| 158 | '<div class="inline">'. |
||
| 159 | '<label for="site_reviews-settings-general-require-approval-1">'. |
||
| 160 | '<input type="radio" id="site_reviews-settings-general-require-approval-1" name="site_reviews[settings][general][require][approval]" value="no" /> No'. |
||
| 161 | '</label>'. |
||
| 162 | '<br>'. |
||
| 163 | '<label for="site_reviews-settings-general-require-approval-2">'. |
||
| 164 | '<input type="radio" id="site_reviews-settings-general-require-approval-2" name="site_reviews[settings][general][require][approval]" value="yes" /> Yes'. |
||
| 165 | '</label>'. |
||
| 166 | '</div>'. |
||
| 167 | '</fieldset>'. |
||
| 168 | '</td>'. |
||
| 169 | '</tr>' |
||
| 170 | ); |
||
| 171 | } |
||
| 172 | |||
| 173 | public function test_build_general_require_approval_for(): void |
||
| 174 | { |
||
| 175 | $this->assertEquals( |
||
| 176 | $this->buildSetting('settings.general.require.approval_for'), |
||
| 177 | '<tr class="glsr-setting-field" data-field="settings.general.require.approval_for">'. |
||
| 178 | '<th scope="row">'. |
||
| 179 | '<label for="site_reviews-settings-general-require-approval_for">'. |
||
| 180 | 'Require Approval For'. |
||
| 181 | '</label>'. |
||
| 182 | '</th>'. |
||
| 183 | '<td>'. |
||
| 184 | '<select '. |
||
| 185 | 'class="regular-text" '. |
||
| 186 | 'id="site_reviews-settings-general-require-approval_for" '. |
||
| 187 | 'name="site_reviews[settings][general][require][approval_for]"'. |
||
| 188 | '>'. |
||
| 189 | '<option value="5">5 stars or less</option>'. |
||
| 190 | '<option value="4">4 stars or less</option>'. |
||
| 191 | '<option value="3">3 stars or less</option>'. |
||
| 192 | '<option value="2">2 stars or less</option>'. |
||
| 193 | '<option value="1">1 star or less</option>'. |
||
| 194 | '</select>'. |
||
| 195 | '</td>'. |
||
| 196 | '</tr>' |
||
| 197 | ); |
||
| 198 | } |
||
| 199 | |||
| 200 | public function test_build_general_require_login(): void |
||
| 201 | { |
||
| 202 | $this->assertEquals( |
||
| 203 | $this->buildSetting('settings.general.require.login'), |
||
| 204 | '<tr class="glsr-setting-field" data-field="settings.general.require.login">'. |
||
| 205 | '<th scope="row">'. |
||
| 206 | '<label>Require Login</label>'. |
||
| 207 | '</th>'. |
||
| 208 | '<td>'. |
||
| 209 | '<fieldset data-depends="">'. |
||
| 210 | '<legend class="screen-reader-text">'. |
||
| 211 | '<span>Require Login</span>'. |
||
| 212 | '</legend>'. |
||
| 213 | '<div class="inline">'. |
||
| 214 | '<label for="site_reviews-settings-general-require-login-1">'. |
||
| 215 | '<input type="radio" id="site_reviews-settings-general-require-login-1" name="site_reviews[settings][general][require][login]" value="no" /> No'. |
||
| 216 | '</label>'. |
||
| 217 | '<br>'. |
||
| 218 | '<label for="site_reviews-settings-general-require-login-2">'. |
||
| 219 | '<input type="radio" id="site_reviews-settings-general-require-login-2" name="site_reviews[settings][general][require][login]" value="yes" /> Yes'. |
||
| 220 | '</label>'. |
||
| 221 | '</div>'. |
||
| 222 | '</fieldset>'. |
||
| 223 | '</td>'. |
||
| 224 | '</tr>' |
||
| 225 | ); |
||
| 226 | } |
||
| 227 | |||
| 228 | public function test_build_general_require_login_url(): void |
||
| 229 | { |
||
| 230 | $this->assertEquals( |
||
| 231 | $this->buildSetting('settings.general.require.login_url'), |
||
| 232 | '<tr class="glsr-setting-field" data-field="settings.general.require.login_url">'. |
||
| 233 | '<th scope="row">'. |
||
| 234 | '<label for="site_reviews-settings-general-require-login_url">Custom Login URL</label>'. |
||
| 235 | '</th>'. |
||
| 236 | '<td>'. |
||
| 237 | '<input '. |
||
| 238 | 'type="text" '. |
||
| 239 | 'class="large-text" '. |
||
| 240 | 'id="site_reviews-settings-general-require-login_url" '. |
||
| 241 | 'name="site_reviews[settings][general][require][login_url]" '. |
||
| 242 | 'placeholder="Placeholder" '. |
||
| 243 | 'value="" '. |
||
| 244 | '/>'. |
||
| 245 | '</td>'. |
||
| 246 | '</tr>' |
||
| 247 | ); |
||
| 248 | } |
||
| 249 | |||
| 250 | public function test_build_general_require_register(): void |
||
| 251 | { |
||
| 252 | $this->assertEquals( |
||
| 253 | $this->buildSetting('settings.general.require.register'), |
||
| 254 | '<tr class="glsr-setting-field" data-field="settings.general.require.register">'. |
||
| 255 | '<th scope="row">'. |
||
| 256 | '<label>Show Registration Link</label>'. |
||
| 257 | '</th>'. |
||
| 258 | '<td>'. |
||
| 259 | '<fieldset data-depends="">'. |
||
| 260 | '<legend class="screen-reader-text">'. |
||
| 261 | '<span>Show Registration Link</span>'. |
||
| 262 | '</legend>'. |
||
| 263 | '<div class="inline">'. |
||
| 264 | '<label for="site_reviews-settings-general-require-register-1">'. |
||
| 265 | '<input type="radio" id="site_reviews-settings-general-require-register-1" name="site_reviews[settings][general][require][register]" value="no" /> No'. |
||
| 266 | '</label>'. |
||
| 267 | '<br>'. |
||
| 268 | '<label for="site_reviews-settings-general-require-register-2">'. |
||
| 269 | '<input type="radio" id="site_reviews-settings-general-require-register-2" name="site_reviews[settings][general][require][register]" value="yes" /> Yes'. |
||
| 270 | '</label>'. |
||
| 271 | '</div>'. |
||
| 272 | '</fieldset>'. |
||
| 273 | '</td>'. |
||
| 274 | '</tr>' |
||
| 275 | ); |
||
| 276 | } |
||
| 277 | |||
| 278 | public function test_build_general_require_register_url(): void |
||
| 279 | { |
||
| 280 | $this->assertEquals( |
||
| 281 | $this->buildSetting('settings.general.require.register_url'), |
||
| 282 | '<tr class="glsr-setting-field" data-field="settings.general.require.register_url">'. |
||
| 283 | '<th scope="row">'. |
||
| 284 | '<label for="site_reviews-settings-general-require-register_url">Custom Registration URL</label>'. |
||
| 285 | '</th>'. |
||
| 286 | '<td>'. |
||
| 287 | '<input '. |
||
| 288 | 'type="text" '. |
||
| 289 | 'class="large-text" '. |
||
| 290 | 'id="site_reviews-settings-general-require-register_url" '. |
||
| 291 | 'name="site_reviews[settings][general][require][register_url]" '. |
||
| 292 | 'placeholder="Placeholder" '. |
||
| 293 | 'value="" '. |
||
| 294 | '/>'. |
||
| 295 | '</td>'. |
||
| 296 | '</tr>' |
||
| 297 | ); |
||
| 298 | } |
||
| 299 | |||
| 300 | public function test_build_general_multilingual(): void |
||
| 301 | { |
||
| 302 | $this->assertEquals( |
||
| 303 | $this->buildSetting('settings.general.multilingual'), |
||
| 304 | '<tr class="glsr-setting-field" data-field="settings.general.multilingual">'. |
||
| 305 | '<th scope="row">'. |
||
| 306 | '<label for="site_reviews-settings-general-multilingual">Multilingual</label>'. |
||
| 307 | '</th>'. |
||
| 308 | '<td>'. |
||
| 309 | '<select class="regular-text" id="site_reviews-settings-general-multilingual" name="site_reviews[settings][general][multilingual]">'. |
||
| 310 | '<option value="">No Integration</option>'. |
||
| 311 | '<option value="polylang">Integrate with Polylang</option>'. |
||
| 312 | '<option value="wpml">Integrate with WPML</option>'. |
||
| 313 | '</select>'. |
||
| 314 | '<p class="description">Description</p>'. |
||
| 315 | '</td>'. |
||
| 316 | '</tr>' |
||
| 317 | ); |
||
| 318 | } |
||
| 319 | |||
| 320 | public function test_build_general_notifications(): void |
||
| 321 | { |
||
| 322 | $this->assertEquals( |
||
| 323 | $this->buildSetting('settings.general.notifications'), |
||
| 324 | '<tr class="glsr-setting-field" data-field="settings.general.notifications">'. |
||
| 325 | '<th scope="row">'. |
||
| 326 | '<label>Notifications</label>'. |
||
| 327 | '</th>'. |
||
| 328 | '<td>'. |
||
| 329 | '<fieldset data-depends="">'. |
||
| 330 | '<legend class="screen-reader-text">'. |
||
| 331 | '<span>Notifications</span>'. |
||
| 332 | '</legend>'. |
||
| 333 | '<div>'. |
||
| 334 | '<label for="site_reviews-settings-general-notifications-1">'. |
||
| 335 | '<input type="checkbox" id="site_reviews-settings-general-notifications-1" name="site_reviews[settings][general][notifications][]" value="admin" /> Send to administrator <code>[email protected]</code>'. |
||
| 336 | '</label>'. |
||
| 337 | '<br>'. |
||
| 338 | '<label for="site_reviews-settings-general-notifications-2">'. |
||
| 339 | '<input type="checkbox" id="site_reviews-settings-general-notifications-2" name="site_reviews[settings][general][notifications][]" value="author" /> Send to author of the page that the review is assigned to'. |
||
| 340 | '</label>'. |
||
| 341 | '<br>'. |
||
| 342 | '<label for="site_reviews-settings-general-notifications-3">'. |
||
| 343 | '<input type="checkbox" id="site_reviews-settings-general-notifications-3" name="site_reviews[settings][general][notifications][]" value="custom" /> Send to one or more email addresses'. |
||
| 344 | '</label>'. |
||
| 345 | '<br>'. |
||
| 346 | '<label for="site_reviews-settings-general-notifications-4">'. |
||
| 347 | '<input type="checkbox" id="site_reviews-settings-general-notifications-4" name="site_reviews[settings][general][notifications][]" value="discord" /> Send to <a href="https://discord.com/" target="_blank">Discord</a> channel'. |
||
| 348 | '</label>'. |
||
| 349 | '<br>'. |
||
| 350 | '<label for="site_reviews-settings-general-notifications-5">'. |
||
| 351 | '<input type="checkbox" id="site_reviews-settings-general-notifications-5" name="site_reviews[settings][general][notifications][]" value="slack" /> Send to <a href="https://slack.com/" target="_blank">Slack</a>'. |
||
| 352 | '</label>'. |
||
| 353 | '</div>'. |
||
| 354 | '</fieldset>'. |
||
| 355 | '</td>'. |
||
| 356 | '</tr>' |
||
| 357 | ); |
||
| 358 | } |
||
| 359 | |||
| 360 | public function test_build_general_notification_discord(): void |
||
| 361 | { |
||
| 362 | $this->assertEquals( |
||
| 363 | $this->buildSetting('settings.general.notification_discord'), |
||
| 364 | '<tr class="glsr-setting-field" data-field="settings.general.notification_discord">'. |
||
| 365 | '<th scope="row">'. |
||
| 366 | '<label for="site_reviews-settings-general-notification_discord">'. |
||
| 367 | 'Discord Webhook URL'. |
||
| 368 | '</label>'. |
||
| 369 | '</th>'. |
||
| 370 | '<td>'. |
||
| 371 | '<input '. |
||
| 372 | 'type="text" '. |
||
| 373 | 'class="large-text" '. |
||
| 374 | 'id="site_reviews-settings-general-notification_discord" '. |
||
| 375 | 'name="site_reviews[settings][general][notification_discord]" '. |
||
| 376 | 'autocomplete="off" '. |
||
| 377 | 'value="" />'. |
||
| 378 | '</td>'. |
||
| 379 | '</tr>' |
||
| 380 | ); |
||
| 381 | } |
||
| 382 | |||
| 383 | public function test_build_general_notification_slack(): void |
||
| 384 | { |
||
| 385 | $this->assertEquals( |
||
| 386 | $this->buildSetting('settings.general.notification_slack'), |
||
| 387 | '<tr class="glsr-setting-field" data-field="settings.general.notification_slack">'. |
||
| 388 | '<th scope="row">'. |
||
| 389 | '<label for="site_reviews-settings-general-notification_slack">'. |
||
| 390 | 'Slack Webhook URL'. |
||
| 391 | '</label>'. |
||
| 392 | '</th>'. |
||
| 393 | '<td>'. |
||
| 394 | '<input '. |
||
| 395 | 'type="text" '. |
||
| 396 | 'class="large-text" '. |
||
| 397 | 'id="site_reviews-settings-general-notification_slack" '. |
||
| 398 | 'name="site_reviews[settings][general][notification_slack]" '. |
||
| 399 | 'autocomplete="off" '. |
||
| 400 | 'value="" />'. |
||
| 401 | '</td>'. |
||
| 402 | '</tr>' |
||
| 403 | ); |
||
| 404 | } |
||
| 405 | |||
| 406 | public function test_build_general_notification_from(): void |
||
| 407 | { |
||
| 408 | $this->assertEquals( |
||
| 409 | $this->buildSetting('settings.general.notification_from'), |
||
| 410 | '<tr class="glsr-setting-field" data-field="settings.general.notification_from">'. |
||
| 411 | '<th scope="row">'. |
||
| 412 | '<label for="site_reviews-settings-general-notification_from">Send Emails From</label>'. |
||
| 413 | '</th>'. |
||
| 414 | '<td>'. |
||
| 415 | '<input '. |
||
| 416 | 'type="text" '. |
||
| 417 | 'class="regular-text" '. |
||
| 418 | 'id="site_reviews-settings-general-notification_from" '. |
||
| 419 | 'name="site_reviews[settings][general][notification_from]" '. |
||
| 420 | 'placeholder="Placeholder" '. |
||
| 421 | 'value="" '. |
||
| 422 | '/>'. |
||
| 423 | '</td>'. |
||
| 424 | '</tr>' |
||
| 425 | ); |
||
| 426 | } |
||
| 427 | |||
| 428 | public function test_build_general_notification_email(): void |
||
| 429 | { |
||
| 430 | $this->assertEquals( |
||
| 431 | $this->buildSetting('settings.general.notification_email'), |
||
| 432 | '<tr class="glsr-setting-field" data-field="settings.general.notification_email">'. |
||
| 433 | '<th scope="row">'. |
||
| 434 | '<label for="site_reviews-settings-general-notification_email">Send Emails To</label>'. |
||
| 435 | '</th>'. |
||
| 436 | '<td>'. |
||
| 437 | '<input '. |
||
| 438 | 'type="text" '. |
||
| 439 | 'class="regular-text" '. |
||
| 440 | 'id="site_reviews-settings-general-notification_email" '. |
||
| 441 | 'name="site_reviews[settings][general][notification_email]" '. |
||
| 442 | 'placeholder="Placeholder" '. |
||
| 443 | 'value="" />'. |
||
| 444 | '</td>'. |
||
| 445 | '</tr>' |
||
| 446 | ); |
||
| 447 | } |
||
| 448 | |||
| 449 | public function test_build_general_notification_message(): void |
||
| 450 | { |
||
| 451 | $this->assertEquals( |
||
| 452 | $this->buildSetting('settings.general.notification_message'), |
||
| 453 | '<tr class="glsr-setting-field" data-field="settings.general.notification_message">'. |
||
| 454 | '<th scope="row">'. |
||
| 455 | '<label for="site_reviews-settings-general-notification_message">'. |
||
| 456 | 'Notification Template'. |
||
| 457 | '</label>'. |
||
| 458 | '</th>'. |
||
| 459 | '<td>'. |
||
| 460 | '<div class="glsr-template-editor">'. |
||
| 461 | '<textarea '. |
||
| 462 | 'class="autosized code large-text" '. |
||
| 463 | 'id="site_reviews-settings-general-notification_message" '. |
||
| 464 | 'name="site_reviews[settings][general][notification_message]" '. |
||
| 465 | 'rows="3">'. |
||
| 466 | '</textarea>'. |
||
| 467 | '<div class="quicktags-toolbar">'. |
||
| 468 | '<input type="button" class="button button-small" data-tag="approve_url" value="approve url" />'. |
||
| 469 | '<input type="button" class="button button-small" data-tag="edit_url" value="edit url" />'. |
||
| 470 | '<input type="button" class="button button-small" data-tag="review_assigned_links" value="assigned links" />'. |
||
| 471 | '<input type="button" class="button button-small" data-tag="review_assigned_posts" value="assigned posts" />'. |
||
| 472 | '<input type="button" class="button button-small" data-tag="review_assigned_users" value="assigned users" />'. |
||
| 473 | '<input type="button" class="button button-small" data-tag="review_author" value="name" />'. |
||
| 474 | '<input type="button" class="button button-small" data-tag="review_categories" value="categories" />'. |
||
| 475 | '<input type="button" class="button button-small" data-tag="review_content" value="content" />'. |
||
| 476 | '<input type="button" class="button button-small" data-tag="review_email" value="email" />'. |
||
| 477 | '<input type="button" class="button button-small" data-tag="review_id" value="review id" />'. |
||
| 478 | '<input type="button" class="button button-small" data-tag="review_ip" value="ip address" />'. |
||
| 479 | '<input type="button" class="button button-small" data-tag="review_rating" value="rating" />'. |
||
| 480 | '<input type="button" class="button button-small" data-tag="review_response" value="response" />'. |
||
| 481 | '<input type="button" class="button button-small" data-tag="review_stars" value="stars" />'. |
||
| 482 | '<input type="button" class="button button-small" data-tag="review_title" value="title" />'. |
||
| 483 | '<input type="button" class="button button-small" data-tag="site_title" value="site title" />'. |
||
| 484 | '<input type="button" class="button button-small" data-tag="site_url" value="site url" />'. |
||
| 485 | '</div>'. |
||
| 486 | '</div>'. |
||
| 487 | '<p class="description">Description</p>'. |
||
| 488 | '</td>'. |
||
| 489 | '</tr>' |
||
| 490 | ); |
||
| 491 | } |
||
| 492 | |||
| 493 | public function test_build_reviews_date_format(): void |
||
| 494 | { |
||
| 495 | $this->assertEquals( |
||
| 496 | $this->buildSetting('settings.reviews.date.format'), |
||
| 497 | '<tr class="glsr-setting-field" data-field="settings.reviews.date.format">'. |
||
| 498 | '<th scope="row">'. |
||
| 499 | '<label for="site_reviews-settings-reviews-date-format">Date Format</label>'. |
||
| 500 | '</th>'. |
||
| 501 | '<td>'. |
||
| 502 | '<select class="regular-text" id="site_reviews-settings-reviews-date-format" name="site_reviews[settings][reviews][date][format]">'. |
||
| 503 | '<option value="">Use the default date format</option>'. |
||
| 504 | '<option value="relative">Use a relative date format</option>'. |
||
| 505 | '<option value="custom">Use a custom date format</option>'. |
||
| 506 | '</select>'. |
||
| 507 | '</td>'. |
||
| 508 | '</tr>' |
||
| 509 | ); |
||
| 510 | } |
||
| 511 | |||
| 512 | public function test_build_reviews_date_custom(): void |
||
| 513 | { |
||
| 514 | $this->assertEquals( |
||
| 515 | $this->buildSetting('settings.reviews.date.custom'), |
||
| 516 | '<tr class="glsr-setting-field" data-field="settings.reviews.date.custom">'. |
||
| 517 | '<th scope="row">'. |
||
| 518 | '<label for="site_reviews-settings-reviews-date-custom">Custom Date Format</label>'. |
||
| 519 | '</th>'. |
||
| 520 | '<td>'. |
||
| 521 | '<input type="text" class="regular-text" id="site_reviews-settings-reviews-date-custom" name="site_reviews[settings][reviews][date][custom]" value="" />'. |
||
| 522 | '</td>'. |
||
| 523 | '</tr>' |
||
| 524 | ); |
||
| 525 | } |
||
| 526 | |||
| 527 | public function test_build_reviews_name_format(): void |
||
| 528 | { |
||
| 529 | $this->assertEquals( |
||
| 530 | $this->buildSetting('settings.reviews.name.format'), |
||
| 531 | '<tr class="glsr-setting-field" data-field="settings.reviews.name.format">'. |
||
| 532 | '<th scope="row">'. |
||
| 533 | '<label for="site_reviews-settings-reviews-name-format">Name Format</label>'. |
||
| 534 | '</th>'. |
||
| 535 | '<td>'. |
||
| 536 | '<select class="regular-text" id="site_reviews-settings-reviews-name-format" name="site_reviews[settings][reviews][name][format]">'. |
||
| 537 | '<option value="">Use the name as given</option>'. |
||
| 538 | '<option value="first">Use the first name only</option>'. |
||
| 539 | '<option value="first_initial">Convert first name to an initial</option>'. |
||
| 540 | '<option value="last_initial">Convert last name to an initial</option>'. |
||
| 541 | '<option value="initials">Convert to all initials</option>'. |
||
| 542 | '</select>'. |
||
| 543 | '</td>'. |
||
| 544 | '</tr>' |
||
| 545 | ); |
||
| 546 | } |
||
| 547 | |||
| 548 | public function test_build_reviews_name_initial(): void |
||
| 549 | { |
||
| 550 | $this->assertEquals( |
||
| 551 | $this->buildSetting('settings.reviews.name.initial'), |
||
| 552 | '<tr class="glsr-setting-field" data-field="settings.reviews.name.initial">'. |
||
| 553 | '<th scope="row">'. |
||
| 554 | '<label for="site_reviews-settings-reviews-name-initial">Initial Format</label>'. |
||
| 555 | '</th>'. |
||
| 556 | '<td>'. |
||
| 557 | '<select class="regular-text" id="site_reviews-settings-reviews-name-initial" name="site_reviews[settings][reviews][name][initial]">'. |
||
| 558 | '<option value="">Initial with a space</option>'. |
||
| 559 | '<option value="period">Initial with a period</option>'. |
||
| 560 | '<option value="period_space">Initial with a period and a space</option>'. |
||
| 561 | '</select>'. |
||
| 562 | '</td>'. |
||
| 563 | '</tr>' |
||
| 564 | ); |
||
| 565 | } |
||
| 566 | |||
| 567 | public function test_build_reviews_assignment(): void |
||
| 568 | { |
||
| 569 | $this->assertEquals( |
||
| 570 | $this->buildSetting('settings.reviews.assignment'), |
||
| 571 | '<tr class="glsr-setting-field" data-field="settings.reviews.assignment">'. |
||
| 572 | '<th scope="row">'. |
||
| 573 | '<label for="site_reviews-settings-reviews-assignment">Review Assignment</label>'. |
||
| 574 | '</th>'. |
||
| 575 | '<td>'. |
||
| 576 | '<select class="regular-text" id="site_reviews-settings-reviews-assignment" name="site_reviews[settings][reviews][assignment]">'. |
||
| 577 | '<option value="loose">Loose Assignment (slower database queries)</option>'. |
||
| 578 | '<option value="strict">Strict Assignment (faster database queries)</option>'. |
||
| 579 | '</select>'. |
||
| 580 | '<p class="description">Description</p>'. |
||
| 581 | '</td>'. |
||
| 582 | '</tr>' |
||
| 583 | ); |
||
| 584 | } |
||
| 585 | |||
| 586 | public function test_build_reviews_assigned_links(): void |
||
| 587 | { |
||
| 588 | $this->assertEquals( |
||
| 589 | $this->buildSetting('settings.reviews.assigned_links'), |
||
| 590 | '<tr class="glsr-setting-field" data-field="settings.reviews.assigned_links">'. |
||
| 591 | '<th scope="row">'. |
||
| 592 | '<label>Enable Assigned Links</label>'. |
||
| 593 | '</th>'. |
||
| 594 | '<td>'. |
||
| 595 | '<fieldset data-depends="">'. |
||
| 596 | '<legend class="screen-reader-text">'. |
||
| 597 | '<span>Enable Assigned Links</span>'. |
||
| 598 | '</legend>'. |
||
| 599 | '<div class="inline">'. |
||
| 600 | '<label for="site_reviews-settings-reviews-assigned_links-1">'. |
||
| 601 | '<input type="radio" id="site_reviews-settings-reviews-assigned_links-1" name="site_reviews[settings][reviews][assigned_links]" value="no" /> No'. |
||
| 602 | '</label>'. |
||
| 603 | '<br>'. |
||
| 604 | '<label for="site_reviews-settings-reviews-assigned_links-2">'. |
||
| 605 | '<input type="radio" id="site_reviews-settings-reviews-assigned_links-2" name="site_reviews[settings][reviews][assigned_links]" value="yes" /> Yes'. |
||
| 606 | '</label>'. |
||
| 607 | '</div>'. |
||
| 608 | '</fieldset>'. |
||
| 609 | '</td>'. |
||
| 610 | '</tr>' |
||
| 611 | ); |
||
| 612 | } |
||
| 613 | |||
| 614 | public function test_build_reviews_avatars(): void |
||
| 615 | { |
||
| 616 | $this->assertEquals( |
||
| 617 | $this->buildSetting('settings.reviews.avatars'), |
||
| 618 | '<tr class="glsr-setting-field" data-field="settings.reviews.avatars">'. |
||
| 619 | '<th scope="row">'. |
||
| 620 | '<label>Enable Avatars</label>'. |
||
| 621 | '</th>'. |
||
| 622 | '<td>'. |
||
| 623 | '<fieldset data-depends="">'. |
||
| 624 | '<legend class="screen-reader-text">'. |
||
| 625 | '<span>Enable Avatars</span>'. |
||
| 626 | '</legend>'. |
||
| 627 | '<div class="inline">'. |
||
| 628 | '<label for="site_reviews-settings-reviews-avatars-1">'. |
||
| 629 | '<input type="radio" id="site_reviews-settings-reviews-avatars-1" name="site_reviews[settings][reviews][avatars]" value="no" /> No'. |
||
| 630 | '</label>'. |
||
| 631 | '<br>'. |
||
| 632 | '<label for="site_reviews-settings-reviews-avatars-2">'. |
||
| 633 | '<input type="radio" id="site_reviews-settings-reviews-avatars-2" name="site_reviews[settings][reviews][avatars]" value="yes" /> Yes'. |
||
| 634 | '</label>'. |
||
| 635 | '</div>'. |
||
| 636 | '</fieldset>'. |
||
| 637 | '</td>'. |
||
| 638 | '</tr>' |
||
| 639 | ); |
||
| 640 | } |
||
| 641 | |||
| 642 | public function test_build_reviews_avatars_fallback(): void |
||
| 643 | { |
||
| 644 | $this->assertEquals( |
||
| 645 | $this->buildSetting('settings.reviews.avatars_fallback'), |
||
| 646 | '<tr class="glsr-setting-field" data-field="settings.reviews.avatars_fallback">'. |
||
| 647 | '<th scope="row">'. |
||
| 648 | '<label for="site_reviews-settings-reviews-avatars_fallback">Fallback Avatar</label>'. |
||
| 649 | '</th>'. |
||
| 650 | '<td>'. |
||
| 651 | '<select class="regular-text" id="site_reviews-settings-reviews-avatars_fallback" name="site_reviews[settings][reviews][avatars_fallback]">'. |
||
| 652 | '<option value="custom">Custom Image URL</option>'. |
||
| 653 | '<option value="identicon">Identicon (geometric patterns)</option>'. |
||
| 654 | '<option value="initials">Initials (initials of reviewer\'s name)</option>'. |
||
| 655 | '<option value="monsterid">Monster (monsters with generated faces)</option>'. |
||
| 656 | '<option value="mystery">Mystery (silhouetted outline of a person)</option>'. |
||
| 657 | '<option value="none">None (select this if you want an avatar plugin to manage the fallback avatar)</option>'. |
||
| 658 | '<option value="pixels">Pixel Avatars (locally generated)</option>'. |
||
| 659 | '<option value="retro">Retro (8-bit arcade-style pixelated faces)</option>'. |
||
| 660 | '<option value="robohash">Robohash (robots with generated faces)</option>'. |
||
| 661 | '<option value="wavatar">Wavatar (faces with generated features)</option>'. |
||
| 662 | '</select>'. |
||
| 663 | '</td>'. |
||
| 664 | '</tr>' |
||
| 665 | ); |
||
| 666 | } |
||
| 667 | |||
| 668 | public function test_build_reviews_avatars_fallback_url(): void |
||
| 669 | { |
||
| 670 | $this->assertEquals( |
||
| 671 | $this->buildSetting('settings.reviews.avatars_fallback_url'), |
||
| 672 | '<tr class="glsr-setting-field" data-field="settings.reviews.avatars_fallback_url">'. |
||
| 673 | '<th scope="row">'. |
||
| 674 | '<label for="site_reviews-settings-reviews-avatars_fallback_url">Fallback Avatar URL</label>'. |
||
| 675 | '</th>'. |
||
| 676 | '<td>'. |
||
| 677 | '<input type="text" class="large-text" id="site_reviews-settings-reviews-avatars_fallback_url" name="site_reviews[settings][reviews][avatars_fallback_url]" value="" />'. |
||
| 678 | '</td>'. |
||
| 679 | '</tr>' |
||
| 680 | ); |
||
| 681 | } |
||
| 682 | |||
| 683 | public function test_build_reviews_avatars_regenerate(): void |
||
| 684 | { |
||
| 685 | $this->assertEquals( |
||
| 686 | $this->buildSetting('settings.reviews.avatars_regenerate'), |
||
| 687 | '<tr class="glsr-setting-field" data-field="settings.reviews.avatars_regenerate">'. |
||
| 688 | '<th scope="row">'. |
||
| 689 | '<label>Regenerate Avatars</label>'. |
||
| 690 | '</th>'. |
||
| 691 | '<td>'. |
||
| 692 | '<fieldset data-depends="">'. |
||
| 693 | '<legend class="screen-reader-text">'. |
||
| 694 | '<span>Regenerate Avatars</span>'. |
||
| 695 | '</legend>'. |
||
| 696 | '<div class="inline">'. |
||
| 697 | '<label for="site_reviews-settings-reviews-avatars_regenerate-1">'. |
||
| 698 | '<input type="radio" id="site_reviews-settings-reviews-avatars_regenerate-1" name="site_reviews[settings][reviews][avatars_regenerate]" value="no" /> No'. |
||
| 699 | '</label>'. |
||
| 700 | '<br>'. |
||
| 701 | '<label for="site_reviews-settings-reviews-avatars_regenerate-2">'. |
||
| 702 | '<input type="radio" id="site_reviews-settings-reviews-avatars_regenerate-2" name="site_reviews[settings][reviews][avatars_regenerate]" value="yes" /> Yes'. |
||
| 703 | '</label>'. |
||
| 704 | '</div>'. |
||
| 705 | '</fieldset>'. |
||
| 706 | '</td>'. |
||
| 707 | '</tr>' |
||
| 708 | ); |
||
| 709 | } |
||
| 710 | |||
| 711 | public function test_build_reviews_avatars_size(): void |
||
| 712 | { |
||
| 713 | $this->assertEquals( |
||
| 714 | $this->buildSetting('settings.reviews.avatars_size'), |
||
| 715 | '<tr class="glsr-setting-field" data-field="settings.reviews.avatars_size">'. |
||
| 716 | '<th scope="row">'. |
||
| 717 | '<label for="site_reviews-settings-reviews-avatars_size">Avatar Size</label>'. |
||
| 718 | '</th>'. |
||
| 719 | '<td>'. |
||
| 720 | '<input type="number" class="small-text" id="site_reviews-settings-reviews-avatars_size" name="site_reviews[settings][reviews][avatars_size]" min="16" value="" /> pixels'. |
||
| 721 | '</td>'. |
||
| 722 | '</tr>' |
||
| 723 | ); |
||
| 724 | } |
||
| 725 | |||
| 726 | public function test_build_reviews_excerpts(): void |
||
| 727 | { |
||
| 728 | $this->assertEquals( |
||
| 729 | $this->buildSetting('settings.reviews.excerpts'), |
||
| 730 | '<tr class="glsr-setting-field" data-field="settings.reviews.excerpts">'. |
||
| 731 | '<th scope="row">'. |
||
| 732 | '<label>Enable Excerpts</label>'. |
||
| 733 | '</th>'. |
||
| 734 | '<td>'. |
||
| 735 | '<fieldset data-depends="">'. |
||
| 736 | '<legend class="screen-reader-text">'. |
||
| 737 | '<span>Enable Excerpts</span>'. |
||
| 738 | '</legend>'. |
||
| 739 | '<div class="inline">'. |
||
| 740 | '<label for="site_reviews-settings-reviews-excerpts-1">'. |
||
| 741 | '<input type="radio" id="site_reviews-settings-reviews-excerpts-1" name="site_reviews[settings][reviews][excerpts]" value="no" /> No'. |
||
| 742 | '</label>'. |
||
| 743 | '<br>'. |
||
| 744 | '<label for="site_reviews-settings-reviews-excerpts-2">'. |
||
| 745 | '<input type="radio" id="site_reviews-settings-reviews-excerpts-2" name="site_reviews[settings][reviews][excerpts]" value="yes" /> Yes'. |
||
| 746 | '</label>'. |
||
| 747 | '</div>'. |
||
| 748 | '</fieldset>'. |
||
| 749 | '</td>'. |
||
| 750 | '</tr>' |
||
| 751 | ); |
||
| 752 | } |
||
| 753 | |||
| 754 | public function test_build_reviews_excerpts_action(): void |
||
| 755 | { |
||
| 756 | $this->assertEquals( |
||
| 757 | $this->buildSetting('settings.reviews.excerpts_action'), |
||
| 758 | '<tr class="glsr-setting-field" data-field="settings.reviews.excerpts_action">'. |
||
| 759 | '<th scope="row">'. |
||
| 760 | '<label for="site_reviews-settings-reviews-excerpts_action">Excerpt Action</label>'. |
||
| 761 | '</th>'. |
||
| 762 | '<td>'. |
||
| 763 | '<select class="regular-text" id="site_reviews-settings-reviews-excerpts_action" name="site_reviews[settings][reviews][excerpts_action]">'. |
||
| 764 | '<option value="">Collapse/Expand the review</option>'. |
||
| 765 | '<option value="modal">Display the review in a modal</option>'. |
||
| 766 | '</select>'. |
||
| 767 | '</td>'. |
||
| 768 | '</tr>' |
||
| 769 | ); |
||
| 770 | } |
||
| 771 | |||
| 772 | public function test_build_reviews_excerpts_length(): void |
||
| 773 | { |
||
| 774 | $this->assertEquals( |
||
| 775 | $this->buildSetting('settings.reviews.excerpts_length'), |
||
| 776 | '<tr class="glsr-setting-field" data-field="settings.reviews.excerpts_length">'. |
||
| 777 | '<th scope="row">'. |
||
| 778 | '<label for="site_reviews-settings-reviews-excerpts_length">Excerpt Length</label>'. |
||
| 779 | '</th>'. |
||
| 780 | '<td>'. |
||
| 781 | '<input type="number" class="small-text" id="site_reviews-settings-reviews-excerpts_length" name="site_reviews[settings][reviews][excerpts_length]" value="" /> words'. |
||
| 782 | '</td>'. |
||
| 783 | '</tr>' |
||
| 784 | ); |
||
| 785 | } |
||
| 786 | |||
| 787 | public function test_build_reviews_fallback(): void |
||
| 788 | { |
||
| 789 | $this->assertEquals( |
||
| 790 | $this->buildSetting('settings.reviews.fallback'), |
||
| 791 | '<tr class="glsr-setting-field" data-field="settings.reviews.fallback">'. |
||
| 792 | '<th scope="row">'. |
||
| 793 | '<label>Enable Fallback Text</label>'. |
||
| 794 | '</th>'. |
||
| 795 | '<td>'. |
||
| 796 | '<fieldset data-depends="">'. |
||
| 797 | '<legend class="screen-reader-text">'. |
||
| 798 | '<span>Enable Fallback Text</span>'. |
||
| 799 | '</legend>'. |
||
| 800 | '<div class="inline">'. |
||
| 801 | '<label for="site_reviews-settings-reviews-fallback-1">'. |
||
| 802 | '<input type="radio" id="site_reviews-settings-reviews-fallback-1" name="site_reviews[settings][reviews][fallback]" value="no" /> No'. |
||
| 803 | '</label>'. |
||
| 804 | '<br>'. |
||
| 805 | '<label for="site_reviews-settings-reviews-fallback-2">'. |
||
| 806 | '<input type="radio" id="site_reviews-settings-reviews-fallback-2" name="site_reviews[settings][reviews][fallback]" value="yes" /> Yes'. |
||
| 807 | '</label>'. |
||
| 808 | '</div>'. |
||
| 809 | '<p class="description">Description</p>'. |
||
| 810 | '</fieldset>'. |
||
| 811 | '</td>'. |
||
| 812 | '</tr>' |
||
| 813 | ); |
||
| 814 | } |
||
| 815 | |||
| 816 | public function test_build_reviews_pagination_url_parameter(): void |
||
| 817 | { |
||
| 818 | $this->assertEquals( |
||
| 819 | $this->buildSetting('settings.reviews.pagination.url_parameter'), |
||
| 820 | '<tr class="glsr-setting-field" data-field="settings.reviews.pagination.url_parameter">'. |
||
| 821 | '<th scope="row">'. |
||
| 822 | '<label>Enable Paginated URLs</label>'. |
||
| 823 | '</th>'. |
||
| 824 | '<td>'. |
||
| 825 | '<fieldset data-depends="">'. |
||
| 826 | '<legend class="screen-reader-text">'. |
||
| 827 | '<span>Enable Paginated URLs</span>'. |
||
| 828 | '</legend>'. |
||
| 829 | '<div class="inline">'. |
||
| 830 | '<label for="site_reviews-settings-reviews-pagination-url_parameter-1">'. |
||
| 831 | '<input type="radio" id="site_reviews-settings-reviews-pagination-url_parameter-1" name="site_reviews[settings][reviews][pagination][url_parameter]" value="no" /> No'. |
||
| 832 | '</label>'. |
||
| 833 | '<br>'. |
||
| 834 | '<label for="site_reviews-settings-reviews-pagination-url_parameter-2">'. |
||
| 835 | '<input type="radio" id="site_reviews-settings-reviews-pagination-url_parameter-2" name="site_reviews[settings][reviews][pagination][url_parameter]" value="yes" /> Yes'. |
||
| 836 | '</label>'. |
||
| 837 | '</div>'. |
||
| 838 | '<p class="description">Description</p>'. |
||
| 839 | '</fieldset>'. |
||
| 840 | '</td>'. |
||
| 841 | '</tr>' |
||
| 842 | ); |
||
| 843 | } |
||
| 844 | |||
| 845 | public function test_build_schema_integration_plugin(): void |
||
| 846 | { |
||
| 847 | $this->assertEquals( |
||
| 848 | $this->buildSetting('settings.schema.integration.plugin'), |
||
| 849 | '<tr class="glsr-setting-field" data-field="settings.schema.integration.plugin">'. |
||
| 850 | '<th scope="row">'. |
||
| 851 | '<label for="site_reviews-settings-schema-integration-plugin">Integrate with plugin</label>'. |
||
| 852 | '</th>'. |
||
| 853 | '<td>'. |
||
| 854 | '<select class="regular-text" id="site_reviews-settings-schema-integration-plugin" name="site_reviews[settings][schema][integration][plugin]">'. |
||
| 855 | '<option value="">No Integration</option>'. |
||
| 856 | '<option value="rankmath">RankMath Pro</option>'. |
||
| 857 | '<option value="saswp">Schema & Structured Data for WP & AMP</option>'. |
||
| 858 | '<option value="schema_pro">Schema Pro</option>'. |
||
| 859 | '<option value="seopress">SEOPress Pro</option>'. |
||
| 860 | '<option value="yoast_seo">Yoast SEO</option>'. |
||
| 861 | '</select>'. |
||
| 862 | '</td>'. |
||
| 863 | '</tr>' |
||
| 864 | ); |
||
| 865 | } |
||
| 866 | |||
| 867 | public function test_build_schema_type_default(): void |
||
| 868 | { |
||
| 869 | $this->assertEquals( |
||
| 870 | $this->buildSetting('settings.schema.type.default'), |
||
| 871 | '<tr class="glsr-setting-field" data-field="settings.schema.type.default">'. |
||
| 872 | '<th scope="row">'. |
||
| 873 | '<label for="site_reviews-settings-schema-type-default">Default Schema Type</label>'. |
||
| 874 | '</th>'. |
||
| 875 | '<td>'. |
||
| 876 | '<select class="regular-text" id="site_reviews-settings-schema-type-default" name="site_reviews[settings][schema][type][default]">'. |
||
| 877 | '<option value="LocalBusiness">Local Business</option>'. |
||
| 878 | '<option value="Product">Product</option>'. |
||
| 879 | '<option value="custom">Custom</option>'. |
||
| 880 | '</select>'. |
||
| 881 | '</td>'. |
||
| 882 | '</tr>' |
||
| 883 | ); |
||
| 884 | } |
||
| 885 | |||
| 886 | public function test_build_schema_type_custom(): void |
||
| 887 | { |
||
| 888 | $this->assertEquals( |
||
| 889 | $this->buildSetting('settings.schema.type.custom'), |
||
| 890 | '<tr class="glsr-setting-field" data-field="settings.schema.type.custom">'. |
||
| 891 | '<th scope="row">'. |
||
| 892 | '<label for="site_reviews-settings-schema-type-custom">Custom Schema Type</label>'. |
||
| 893 | '</th>'. |
||
| 894 | '<td>'. |
||
| 895 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-type-custom" name="site_reviews[settings][schema][type][custom]" value="" />'. |
||
| 896 | '</td>'. |
||
| 897 | '</tr>' |
||
| 898 | ); |
||
| 899 | } |
||
| 900 | |||
| 901 | public function test_build_schema_name_default(): void |
||
| 902 | { |
||
| 903 | $this->assertEquals( |
||
| 904 | $this->buildSetting('settings.schema.name.default'), |
||
| 905 | '<tr class="glsr-setting-field" data-field="settings.schema.name.default">'. |
||
| 906 | '<th scope="row">'. |
||
| 907 | '<label for="site_reviews-settings-schema-name-default">Default Name</label>'. |
||
| 908 | '</th>'. |
||
| 909 | '<td>'. |
||
| 910 | '<select class="regular-text" id="site_reviews-settings-schema-name-default" name="site_reviews[settings][schema][name][default]">'. |
||
| 911 | '<option value="post">Use the assigned or current page title</option>'. |
||
| 912 | '<option value="custom">Enter a custom title</option>'. |
||
| 913 | '</select>'. |
||
| 914 | '</td>'. |
||
| 915 | '</tr>' |
||
| 916 | ); |
||
| 917 | } |
||
| 918 | |||
| 919 | public function test_build_schema_name_custom(): void |
||
| 920 | { |
||
| 921 | $this->assertEquals( |
||
| 922 | $this->buildSetting('settings.schema.name.custom'), |
||
| 923 | '<tr class="glsr-setting-field" data-field="settings.schema.name.custom">'. |
||
| 924 | '<th scope="row">'. |
||
| 925 | '<label for="site_reviews-settings-schema-name-custom">Custom Name</label>'. |
||
| 926 | '</th>'. |
||
| 927 | '<td>'. |
||
| 928 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-name-custom" name="site_reviews[settings][schema][name][custom]" value="" />'. |
||
| 929 | '</td>'. |
||
| 930 | '</tr>' |
||
| 931 | ); |
||
| 932 | } |
||
| 933 | |||
| 934 | public function test_build_schema_description_default(): void |
||
| 935 | { |
||
| 936 | $this->assertEquals( |
||
| 937 | $this->buildSetting('settings.schema.description.default'), |
||
| 938 | '<tr class="glsr-setting-field" data-field="settings.schema.description.default">'. |
||
| 939 | '<th scope="row">'. |
||
| 940 | '<label for="site_reviews-settings-schema-description-default">Default Description</label>'. |
||
| 941 | '</th>'. |
||
| 942 | '<td>'. |
||
| 943 | '<select class="regular-text" id="site_reviews-settings-schema-description-default" name="site_reviews[settings][schema][description][default]">'. |
||
| 944 | '<option value="post">Use the assigned or current page excerpt</option>'. |
||
| 945 | '<option value="custom">Enter a custom description</option>'. |
||
| 946 | '</select>'. |
||
| 947 | '</td>'. |
||
| 948 | '</tr>' |
||
| 949 | ); |
||
| 950 | } |
||
| 951 | |||
| 952 | public function test_build_schema_description_custom(): void |
||
| 953 | { |
||
| 954 | $this->assertEquals( |
||
| 955 | $this->buildSetting('settings.schema.description.custom'), |
||
| 956 | '<tr class="glsr-setting-field" data-field="settings.schema.description.custom">'. |
||
| 957 | '<th scope="row">'. |
||
| 958 | '<label for="site_reviews-settings-schema-description-custom">Custom Description</label>'. |
||
| 959 | '</th>'. |
||
| 960 | '<td>'. |
||
| 961 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-description-custom" name="site_reviews[settings][schema][description][custom]" value="" />'. |
||
| 962 | '</td>'. |
||
| 963 | '</tr>' |
||
| 964 | ); |
||
| 965 | } |
||
| 966 | |||
| 967 | public function test_build_schema_url_default(): void |
||
| 968 | { |
||
| 969 | $this->assertEquals( |
||
| 970 | $this->buildSetting('settings.schema.url.default'), |
||
| 971 | '<tr class="glsr-setting-field" data-field="settings.schema.url.default">'. |
||
| 972 | '<th scope="row">'. |
||
| 973 | '<label for="site_reviews-settings-schema-url-default">Default URL</label>'. |
||
| 974 | '</th>'. |
||
| 975 | '<td>'. |
||
| 976 | '<select class="regular-text" id="site_reviews-settings-schema-url-default" name="site_reviews[settings][schema][url][default]">'. |
||
| 977 | '<option value="post">Use the assigned or current page URL</option>'. |
||
| 978 | '<option value="custom">Enter a custom URL</option>'. |
||
| 979 | '</select>'. |
||
| 980 | '</td>'. |
||
| 981 | '</tr>' |
||
| 982 | ); |
||
| 983 | } |
||
| 984 | |||
| 985 | public function test_build_schema_url_custom(): void |
||
| 986 | { |
||
| 987 | $this->assertEquals( |
||
| 988 | $this->buildSetting('settings.schema.url.custom'), |
||
| 989 | '<tr class="glsr-setting-field" data-field="settings.schema.url.custom">'. |
||
| 990 | '<th scope="row">'. |
||
| 991 | '<label for="site_reviews-settings-schema-url-custom">Custom URL</label>'. |
||
| 992 | '</th>'. |
||
| 993 | '<td>'. |
||
| 994 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-url-custom" name="site_reviews[settings][schema][url][custom]" value="" />'. |
||
| 995 | '</td>'. |
||
| 996 | '</tr>' |
||
| 997 | ); |
||
| 998 | } |
||
| 999 | |||
| 1000 | public function test_build_schema_image_default(): void |
||
| 1001 | { |
||
| 1002 | $this->assertEquals( |
||
| 1003 | $this->buildSetting('settings.schema.image.default'), |
||
| 1004 | '<tr class="glsr-setting-field" data-field="settings.schema.image.default">'. |
||
| 1005 | '<th scope="row">'. |
||
| 1006 | '<label for="site_reviews-settings-schema-image-default">Default Image</label>'. |
||
| 1007 | '</th>'. |
||
| 1008 | '<td>'. |
||
| 1009 | '<select class="regular-text" id="site_reviews-settings-schema-image-default" name="site_reviews[settings][schema][image][default]">'. |
||
| 1010 | '<option value="post">Use the featured image of the assigned or current page</option>'. |
||
| 1011 | '<option value="custom">Enter a custom image URL</option>'. |
||
| 1012 | '</select>'. |
||
| 1013 | '</td>'. |
||
| 1014 | '</tr>' |
||
| 1015 | ); |
||
| 1016 | } |
||
| 1017 | |||
| 1018 | public function test_build_schema_image_custom(): void |
||
| 1019 | { |
||
| 1020 | $this->assertEquals( |
||
| 1021 | $this->buildSetting('settings.schema.image.custom'), |
||
| 1022 | '<tr class="glsr-setting-field" data-field="settings.schema.image.custom">'. |
||
| 1023 | '<th scope="row">'. |
||
| 1024 | '<label for="site_reviews-settings-schema-image-custom">Custom Image URL</label>'. |
||
| 1025 | '</th>'. |
||
| 1026 | '<td>'. |
||
| 1027 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-image-custom" name="site_reviews[settings][schema][image][custom]" value="" />'. |
||
| 1028 | '</td>'. |
||
| 1029 | '</tr>' |
||
| 1030 | ); |
||
| 1031 | } |
||
| 1032 | |||
| 1033 | public function test_build_schema_address(): void |
||
| 1034 | { |
||
| 1035 | $this->assertEquals( |
||
| 1036 | $this->buildSetting('settings.schema.address'), |
||
| 1037 | '<tr class="glsr-setting-field" data-field="settings.schema.address">'. |
||
| 1038 | '<th scope="row">'. |
||
| 1039 | '<label for="site_reviews-settings-schema-address">Address</label>'. |
||
| 1040 | '</th>'. |
||
| 1041 | '<td>'. |
||
| 1042 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-address" name="site_reviews[settings][schema][address]" placeholder="Placeholder" value="" />'. |
||
| 1043 | '</td>'. |
||
| 1044 | '</tr>' |
||
| 1045 | ); |
||
| 1046 | } |
||
| 1047 | |||
| 1048 | public function test_build_schema_telephone(): void |
||
| 1049 | { |
||
| 1050 | $this->assertEquals( |
||
| 1051 | $this->buildSetting('settings.schema.telephone'), |
||
| 1052 | '<tr class="glsr-setting-field" data-field="settings.schema.telephone">'. |
||
| 1053 | '<th scope="row">'. |
||
| 1054 | '<label for="site_reviews-settings-schema-telephone">Telephone Number</label>'. |
||
| 1055 | '</th>'. |
||
| 1056 | '<td>'. |
||
| 1057 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-telephone" name="site_reviews[settings][schema][telephone]" placeholder="Placeholder" value="" />'. |
||
| 1058 | '</td>'. |
||
| 1059 | '</tr>' |
||
| 1060 | ); |
||
| 1061 | } |
||
| 1062 | |||
| 1063 | public function test_build_schema_pricerange(): void |
||
| 1064 | { |
||
| 1065 | $this->assertEquals( |
||
| 1066 | $this->buildSetting('settings.schema.pricerange'), |
||
| 1067 | '<tr class="glsr-setting-field" data-field="settings.schema.pricerange">'. |
||
| 1068 | '<th scope="row">'. |
||
| 1069 | '<label for="site_reviews-settings-schema-pricerange">Price Range</label>'. |
||
| 1070 | '</th>'. |
||
| 1071 | '<td>'. |
||
| 1072 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-pricerange" name="site_reviews[settings][schema][pricerange]" placeholder="Placeholder" value="" />'. |
||
| 1073 | '</td>'. |
||
| 1074 | '</tr>' |
||
| 1075 | ); |
||
| 1076 | } |
||
| 1077 | |||
| 1078 | public function test_build_schema_offertype(): void |
||
| 1079 | { |
||
| 1080 | $this->assertEquals( |
||
| 1081 | $this->buildSetting('settings.schema.offertype'), |
||
| 1082 | '<tr class="glsr-setting-field" data-field="settings.schema.offertype">'. |
||
| 1083 | '<th scope="row">'. |
||
| 1084 | '<label for="site_reviews-settings-schema-offertype">Offer Type</label>'. |
||
| 1085 | '</th>'. |
||
| 1086 | '<td>'. |
||
| 1087 | '<select class="regular-text" id="site_reviews-settings-schema-offertype" name="site_reviews[settings][schema][offertype]">'. |
||
| 1088 | '<option value="AggregateOffer">AggregateOffer</option>'. |
||
| 1089 | '<option value="Offer">Offer</option>'. |
||
| 1090 | '</select>'. |
||
| 1091 | '</td>'. |
||
| 1092 | '</tr>' |
||
| 1093 | ); |
||
| 1094 | } |
||
| 1095 | |||
| 1096 | public function test_build_schema_price(): void |
||
| 1097 | { |
||
| 1098 | $this->assertEquals( |
||
| 1099 | $this->buildSetting('settings.schema.price'), |
||
| 1100 | '<tr class="glsr-setting-field" data-field="settings.schema.price">'. |
||
| 1101 | '<th scope="row">'. |
||
| 1102 | '<label for="site_reviews-settings-schema-price">Price</label>'. |
||
| 1103 | '</th>'. |
||
| 1104 | '<td>'. |
||
| 1105 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-price" name="site_reviews[settings][schema][price]" placeholder="Placeholder" value="" />'. |
||
| 1106 | '</td>'. |
||
| 1107 | '</tr>' |
||
| 1108 | ); |
||
| 1109 | } |
||
| 1110 | |||
| 1111 | public function test_build_schema_lowprice(): void |
||
| 1112 | { |
||
| 1113 | $this->assertEquals( |
||
| 1114 | $this->buildSetting('settings.schema.lowprice'), |
||
| 1115 | '<tr class="glsr-setting-field" data-field="settings.schema.lowprice">'. |
||
| 1116 | '<th scope="row">'. |
||
| 1117 | '<label for="site_reviews-settings-schema-lowprice">Low Price</label>'. |
||
| 1118 | '</th>'. |
||
| 1119 | '<td>'. |
||
| 1120 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-lowprice" name="site_reviews[settings][schema][lowprice]" placeholder="Placeholder" value="" />'. |
||
| 1121 | '</td>'. |
||
| 1122 | '</tr>' |
||
| 1123 | ); |
||
| 1124 | } |
||
| 1125 | |||
| 1126 | public function test_build_schema_highprice(): void |
||
| 1127 | { |
||
| 1128 | $this->assertEquals( |
||
| 1129 | $this->buildSetting('settings.schema.highprice'), |
||
| 1130 | '<tr class="glsr-setting-field" data-field="settings.schema.highprice">'. |
||
| 1131 | '<th scope="row">'. |
||
| 1132 | '<label for="site_reviews-settings-schema-highprice">High Price</label>'. |
||
| 1133 | '</th>'. |
||
| 1134 | '<td>'. |
||
| 1135 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-highprice" name="site_reviews[settings][schema][highprice]" placeholder="Placeholder" value="" />'. |
||
| 1136 | '</td>'. |
||
| 1137 | '</tr>' |
||
| 1138 | ); |
||
| 1139 | } |
||
| 1140 | |||
| 1141 | public function test_build_schema_pricecurrency(): void |
||
| 1142 | { |
||
| 1143 | $this->assertEquals( |
||
| 1144 | $this->buildSetting('settings.schema.pricecurrency'), |
||
| 1145 | '<tr class="glsr-setting-field" data-field="settings.schema.pricecurrency">'. |
||
| 1146 | '<th scope="row">'. |
||
| 1147 | '<label for="site_reviews-settings-schema-pricecurrency">Price Currency</label>'. |
||
| 1148 | '</th>'. |
||
| 1149 | '<td>'. |
||
| 1150 | '<input type="text" class="regular-text" id="site_reviews-settings-schema-pricecurrency" name="site_reviews[settings][schema][pricecurrency]" placeholder="Placeholder" value="" />'. |
||
| 1151 | '</td>'. |
||
| 1152 | '</tr>' |
||
| 1153 | ); |
||
| 1154 | } |
||
| 1155 | |||
| 1156 | public function test_build_forms_required(): void |
||
| 1157 | { |
||
| 1158 | $this->assertEquals( |
||
| 1159 | $this->buildSetting('settings.forms.required'), |
||
| 1160 | '<tr class="glsr-setting-field" data-field="settings.forms.required">'. |
||
| 1161 | '<th scope="row">'. |
||
| 1162 | '<label>Required Fields</label>'. |
||
| 1163 | '</th>'. |
||
| 1164 | '<td>'. |
||
| 1165 | '<fieldset data-depends="">'. |
||
| 1166 | '<legend class="screen-reader-text">'. |
||
| 1167 | '<span>Required Fields</span>'. |
||
| 1168 | '</legend>'. |
||
| 1169 | '<div>'. |
||
| 1170 | '<label for="site_reviews-settings-forms-required-1">'. |
||
| 1171 | '<input type="checkbox" id="site_reviews-settings-forms-required-1" name="site_reviews[settings][forms][required][]" value="rating" /> Rating'. |
||
| 1172 | '</label>'. |
||
| 1173 | '<br>'. |
||
| 1174 | '<label for="site_reviews-settings-forms-required-2">'. |
||
| 1175 | '<input type="checkbox" id="site_reviews-settings-forms-required-2" name="site_reviews[settings][forms][required][]" value="title" /> Title'. |
||
| 1176 | '</label>'. |
||
| 1177 | '<br>'. |
||
| 1178 | '<label for="site_reviews-settings-forms-required-3">'. |
||
| 1179 | '<input type="checkbox" id="site_reviews-settings-forms-required-3" name="site_reviews[settings][forms][required][]" value="content" /> Review'. |
||
| 1180 | '</label>'. |
||
| 1181 | '<br>'. |
||
| 1182 | '<label for="site_reviews-settings-forms-required-4">'. |
||
| 1183 | '<input type="checkbox" id="site_reviews-settings-forms-required-4" name="site_reviews[settings][forms][required][]" value="name" /> Name'. |
||
| 1184 | '</label>'. |
||
| 1185 | '<br>'. |
||
| 1186 | '<label for="site_reviews-settings-forms-required-5">'. |
||
| 1187 | '<input type="checkbox" id="site_reviews-settings-forms-required-5" name="site_reviews[settings][forms][required][]" value="email" /> Email'. |
||
| 1188 | '</label>'. |
||
| 1189 | '<br>'. |
||
| 1190 | '<label for="site_reviews-settings-forms-required-6">'. |
||
| 1191 | '<input type="checkbox" id="site_reviews-settings-forms-required-6" name="site_reviews[settings][forms][required][]" value="terms" /> Terms'. |
||
| 1192 | '</label>'. |
||
| 1193 | '</div>'. |
||
| 1194 | '<p class="description">Description</p>'. |
||
| 1195 | '</fieldset>'. |
||
| 1196 | '</td>'. |
||
| 1197 | '</tr>' |
||
| 1198 | ); |
||
| 1199 | } |
||
| 1200 | |||
| 1201 | public function test_build_forms_limit(): void |
||
| 1202 | { |
||
| 1203 | $this->assertEquals( |
||
| 1204 | $this->buildSetting('settings.forms.limit'), |
||
| 1205 | '<tr class="glsr-setting-field" data-field="settings.forms.limit">'. |
||
| 1206 | '<th scope="row">'. |
||
| 1207 | '<label for="site_reviews-settings-forms-limit">Limit Reviews</label>'. |
||
| 1208 | '</th>'. |
||
| 1209 | '<td>'. |
||
| 1210 | '<select class="regular-text" id="site_reviews-settings-forms-limit" name="site_reviews[settings][forms][limit]">'. |
||
| 1211 | '<option value="">No Limit</option>'. |
||
| 1212 | '<option value="email">By Email Address</option>'. |
||
| 1213 | '<option value="ip_address">By IP Address</option>'. |
||
| 1214 | '<option value="username">By Username (will only work for registered users)</option>'. |
||
| 1215 | '</select>'. |
||
| 1216 | '</td>'. |
||
| 1217 | '</tr>' |
||
| 1218 | ); |
||
| 1219 | } |
||
| 1220 | |||
| 1221 | public function test_build_forms_limit_time(): void |
||
| 1222 | { |
||
| 1223 | $this->assertEquals( |
||
| 1224 | $this->buildSetting('settings.forms.limit_time'), |
||
| 1225 | '<tr class="glsr-setting-field" data-field="settings.forms.limit_time">'. |
||
| 1226 | '<th scope="row">'. |
||
| 1227 | '<label for="site_reviews-settings-forms-limit_time">Limit Reviews For</label>'. |
||
| 1228 | '</th>'. |
||
| 1229 | '<td>'. |
||
| 1230 | '<input type="number" class="small-text" id="site_reviews-settings-forms-limit_time" name="site_reviews[settings][forms][limit_time]" min="0" value="" /> days'. |
||
| 1231 | '</td>'. |
||
| 1232 | '</tr>' |
||
| 1233 | ); |
||
| 1234 | } |
||
| 1235 | |||
| 1236 | public function test_build_forms_limit_assignments(): void |
||
| 1265 | ); |
||
| 1266 | } |
||
| 1267 | |||
| 1268 | public function test_build_forms_limit_whitelist_email(): void |
||
| 1269 | { |
||
| 1270 | $this->assertEquals( |
||
| 1271 | $this->buildSetting('settings.forms.limit_whitelist.email'), |
||
| 1272 | '<tr class="glsr-setting-field" data-field="settings.forms.limit_whitelist.email">'. |
||
| 1273 | '<th scope="row">'. |
||
| 1274 | '<label for="site_reviews-settings-forms-limit_whitelist-email">Email Whitelist</label>'. |
||
| 1275 | '</th>'. |
||
| 1276 | '<td>'. |
||
| 1277 | '<textarea class="autosized code large-text" id="site_reviews-settings-forms-limit_whitelist-email" name="site_reviews[settings][forms][limit_whitelist][email]" rows="3"></textarea>'. |
||
| 1278 | '</td>'. |
||
| 1279 | '</tr>' |
||
| 1280 | ); |
||
| 1281 | } |
||
| 1282 | |||
| 1283 | public function test_build_forms_limit_whitelist_ip_address(): void |
||
| 1284 | { |
||
| 1285 | $this->assertEquals( |
||
| 1286 | $this->buildSetting('settings.forms.limit_whitelist.ip_address'), |
||
| 1287 | '<tr class="glsr-setting-field" data-field="settings.forms.limit_whitelist.ip_address">'. |
||
| 1288 | '<th scope="row">'. |
||
| 1289 | '<label for="site_reviews-settings-forms-limit_whitelist-ip_address">IP Address Whitelist</label>'. |
||
| 1290 | '</th>'. |
||
| 1291 | '<td>'. |
||
| 1292 | '<textarea class="autosized code large-text" id="site_reviews-settings-forms-limit_whitelist-ip_address" name="site_reviews[settings][forms][limit_whitelist][ip_address]" rows="3"></textarea>'. |
||
| 1293 | '</td>'. |
||
| 1294 | '</tr>' |
||
| 1295 | ); |
||
| 1296 | } |
||
| 1297 | |||
| 1298 | public function test_build_forms_limit_whitelist_username(): void |
||
| 1299 | { |
||
| 1300 | $this->assertEquals( |
||
| 1301 | $this->buildSetting('settings.forms.limit_whitelist.username'), |
||
| 1302 | '<tr class="glsr-setting-field" data-field="settings.forms.limit_whitelist.username">'. |
||
| 1303 | '<th scope="row">'. |
||
| 1304 | '<label for="site_reviews-settings-forms-limit_whitelist-username">Username Whitelist</label>'. |
||
| 1305 | '</th>'. |
||
| 1306 | '<td>'. |
||
| 1307 | '<textarea class="autosized code large-text" id="site_reviews-settings-forms-limit_whitelist-username" name="site_reviews[settings][forms][limit_whitelist][username]" rows="3"></textarea>'. |
||
| 1308 | '</td>'. |
||
| 1309 | '</tr>' |
||
| 1310 | ); |
||
| 1311 | } |
||
| 1312 | |||
| 1313 | public function test_build_forms_captcha_integration(): void |
||
| 1314 | { |
||
| 1315 | $this->assertEquals( |
||
| 1316 | $this->buildSetting('settings.forms.captcha.integration'), |
||
| 1317 | '<tr class="glsr-setting-field" data-field="settings.forms.captcha.integration">'. |
||
| 1318 | '<th scope="row">'. |
||
| 1319 | '<label for="site_reviews-settings-forms-captcha-integration">CAPTCHA</label>'. |
||
| 1320 | '</th>'. |
||
| 1321 | '<td>'. |
||
| 1322 | '<select class="regular-text" id="site_reviews-settings-forms-captcha-integration" name="site_reviews[settings][forms][captcha][integration]">'. |
||
| 1323 | '<option value="">Do not use</option>'. |
||
| 1324 | '<option value="turnstile">Use Cloudflare Turnstile</option>'. |
||
| 1325 | '<option value="friendlycaptcha">Use Friendly Captcha</option>'. |
||
| 1326 | '<option value="hcaptcha">Use hCaptcha</option>'. |
||
| 1327 | '<option value="procaptcha">Use Prosopo Procaptcha</option>'. |
||
| 1328 | '<option value="recaptcha_v2_invisible">Use reCAPTCHA v2 Invisible</option>'. |
||
| 1329 | '<option value="recaptcha_v3">Use reCAPTCHA v3</option>'. |
||
| 1330 | '</select>'. |
||
| 1331 | '</td>'. |
||
| 1332 | '</tr>' |
||
| 1333 | ); |
||
| 1334 | } |
||
| 1335 | |||
| 1336 | public function test_build_forms_friendlycaptcha_key(): void |
||
| 1337 | { |
||
| 1338 | $this->assertEquals( |
||
| 1339 | $this->buildSetting('settings.forms.friendlycaptcha.key'), |
||
| 1340 | '<tr class="glsr-setting-field" data-field="settings.forms.friendlycaptcha.key">'. |
||
| 1341 | '<th scope="row">'. |
||
| 1342 | '<label for="site_reviews-settings-forms-friendlycaptcha-key">Site Key</label>'. |
||
| 1343 | '</th>'. |
||
| 1344 | '<td>'. |
||
| 1345 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-friendlycaptcha-key" name="site_reviews[settings][forms][friendlycaptcha][key]" autocomplete="off" value="" />'. |
||
| 1346 | '</td>'. |
||
| 1347 | '</tr>' |
||
| 1348 | ); |
||
| 1349 | } |
||
| 1350 | |||
| 1351 | public function test_build_forms_friendlycaptcha_secret(): void |
||
| 1352 | { |
||
| 1353 | $this->assertEquals( |
||
| 1354 | $this->buildSetting('settings.forms.friendlycaptcha.secret'), |
||
| 1355 | '<tr class="glsr-setting-field" data-field="settings.forms.friendlycaptcha.secret">'. |
||
| 1356 | '<th scope="row">'. |
||
| 1357 | '<label for="site_reviews-settings-forms-friendlycaptcha-secret">API Key</label>'. |
||
| 1358 | '</th>'. |
||
| 1359 | '<td>'. |
||
| 1360 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-friendlycaptcha-secret" name="site_reviews[settings][forms][friendlycaptcha][secret]" autocomplete="off" value="" />'. |
||
| 1361 | '</td>'. |
||
| 1362 | '</tr>' |
||
| 1363 | ); |
||
| 1364 | } |
||
| 1365 | |||
| 1366 | public function test_build_forms_hcaptcha_key(): void |
||
| 1367 | { |
||
| 1368 | $this->assertEquals( |
||
| 1369 | $this->buildSetting('settings.forms.hcaptcha.key'), |
||
| 1370 | '<tr class="glsr-setting-field" data-field="settings.forms.hcaptcha.key">'. |
||
| 1371 | '<th scope="row">'. |
||
| 1372 | '<label for="site_reviews-settings-forms-hcaptcha-key">Site Key</label>'. |
||
| 1373 | '</th>'. |
||
| 1374 | '<td>'. |
||
| 1375 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-hcaptcha-key" name="site_reviews[settings][forms][hcaptcha][key]" autocomplete="off" value="" />'. |
||
| 1376 | '</td>'. |
||
| 1377 | '</tr>' |
||
| 1378 | ); |
||
| 1379 | } |
||
| 1380 | |||
| 1381 | public function test_build_forms_hcaptcha_secret(): void |
||
| 1382 | { |
||
| 1383 | $this->assertEquals( |
||
| 1384 | $this->buildSetting('settings.forms.hcaptcha.secret'), |
||
| 1385 | '<tr class="glsr-setting-field" data-field="settings.forms.hcaptcha.secret">'. |
||
| 1386 | '<th scope="row">'. |
||
| 1387 | '<label for="site_reviews-settings-forms-hcaptcha-secret">Secret Key</label>'. |
||
| 1388 | '</th>'. |
||
| 1389 | '<td>'. |
||
| 1390 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-hcaptcha-secret" name="site_reviews[settings][forms][hcaptcha][secret]" autocomplete="off" value="" />'. |
||
| 1391 | '</td>'. |
||
| 1392 | '</tr>' |
||
| 1393 | ); |
||
| 1394 | } |
||
| 1395 | |||
| 1396 | public function test_build_forms_procaptcha_key(): void |
||
| 1408 | ); |
||
| 1409 | } |
||
| 1410 | |||
| 1411 | public function test_build_forms_procaptcha_secret(): void |
||
| 1412 | { |
||
| 1413 | $this->assertEquals( |
||
| 1414 | $this->buildSetting('settings.forms.procaptcha.secret'), |
||
| 1415 | '<tr class="glsr-setting-field" data-field="settings.forms.procaptcha.secret">'. |
||
| 1416 | '<th scope="row">'. |
||
| 1417 | '<label for="site_reviews-settings-forms-procaptcha-secret">Secret Key</label>'. |
||
| 1418 | '</th>'. |
||
| 1419 | '<td>'. |
||
| 1420 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-procaptcha-secret" name="site_reviews[settings][forms][procaptcha][secret]" autocomplete="off" value="" />'. |
||
| 1421 | '</td>'. |
||
| 1422 | '</tr>' |
||
| 1423 | ); |
||
| 1424 | } |
||
| 1425 | |||
| 1426 | public function test_build_forms_procaptcha_type(): void |
||
| 1427 | { |
||
| 1428 | $this->assertEquals( |
||
| 1429 | $this->buildSetting('settings.forms.procaptcha.type'), |
||
| 1430 | '<tr class="glsr-setting-field" data-field="settings.forms.procaptcha.type">'. |
||
| 1431 | '<th scope="row">'. |
||
| 1432 | '<label for="site_reviews-settings-forms-procaptcha-type">CAPTCHA Type</label>'. |
||
| 1433 | '</th>'. |
||
| 1434 | '<td>'. |
||
| 1435 | '<select class="regular-text" id="site_reviews-settings-forms-procaptcha-type" name="site_reviews[settings][forms][procaptcha][type]">'. |
||
| 1436 | '<option value="frictionless">Frictionless (invisible to the user)</option>'. |
||
| 1437 | '<option value="image">Image (solve a simple image CAPTCHA)</option>'. |
||
| 1438 | '<option value="pow">Proof of Work (solve a cryptographic puzzle)</option>'. |
||
| 1439 | '</select>'. |
||
| 1440 | '</td>'. |
||
| 1441 | '</tr>' |
||
| 1442 | ); |
||
| 1443 | } |
||
| 1444 | |||
| 1445 | public function test_build_forms_recaptcha_key(): void |
||
| 1446 | { |
||
| 1447 | $this->assertEquals( |
||
| 1448 | $this->buildSetting('settings.forms.recaptcha.key'), |
||
| 1449 | '<tr class="glsr-setting-field" data-field="settings.forms.recaptcha.key">'. |
||
| 1450 | '<th scope="row">'. |
||
| 1451 | '<label for="site_reviews-settings-forms-recaptcha-key">Site Key</label>'. |
||
| 1452 | '</th>'. |
||
| 1453 | '<td>'. |
||
| 1454 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-recaptcha-key" name="site_reviews[settings][forms][recaptcha][key]" autocomplete="off" value="" />'. |
||
| 1455 | '</td>'. |
||
| 1456 | '</tr>' |
||
| 1457 | ); |
||
| 1458 | } |
||
| 1459 | |||
| 1460 | public function test_build_forms_recaptcha_secret(): void |
||
| 1461 | { |
||
| 1462 | $this->assertEquals( |
||
| 1463 | $this->buildSetting('settings.forms.recaptcha.secret'), |
||
| 1464 | '<tr class="glsr-setting-field" data-field="settings.forms.recaptcha.secret">'. |
||
| 1465 | '<th scope="row">'. |
||
| 1466 | '<label for="site_reviews-settings-forms-recaptcha-secret">Secret Key</label>'. |
||
| 1467 | '</th>'. |
||
| 1468 | '<td>'. |
||
| 1469 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-recaptcha-secret" name="site_reviews[settings][forms][recaptcha][secret]" autocomplete="off" value="" />'. |
||
| 1470 | '</td>'. |
||
| 1471 | '</tr>' |
||
| 1472 | ); |
||
| 1473 | } |
||
| 1474 | |||
| 1475 | public function test_build_forms_recaptcha_v3_key(): void |
||
| 1476 | { |
||
| 1477 | $this->assertEquals( |
||
| 1478 | $this->buildSetting('settings.forms.recaptcha_v3.key'), |
||
| 1479 | '<tr class="glsr-setting-field" data-field="settings.forms.recaptcha_v3.key">'. |
||
| 1480 | '<th scope="row">'. |
||
| 1481 | '<label for="site_reviews-settings-forms-recaptcha_v3-key">Site Key</label>'. |
||
| 1482 | '</th>'. |
||
| 1483 | '<td>'. |
||
| 1484 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-recaptcha_v3-key" name="site_reviews[settings][forms][recaptcha_v3][key]" autocomplete="off" value="" />'. |
||
| 1485 | '</td>'. |
||
| 1486 | '</tr>' |
||
| 1487 | ); |
||
| 1488 | } |
||
| 1489 | |||
| 1490 | public function test_build_forms_recaptcha_v3_secret(): void |
||
| 1502 | ); |
||
| 1503 | } |
||
| 1504 | |||
| 1505 | public function test_build_forms_recaptcha_v3_threshold(): void |
||
| 1506 | { |
||
| 1507 | $this->assertEquals( |
||
| 1508 | $this->buildSetting('settings.forms.recaptcha_v3.threshold'), |
||
| 1509 | '<tr class="glsr-setting-field" data-field="settings.forms.recaptcha_v3.threshold">'. |
||
| 1510 | '<th scope="row">'. |
||
| 1511 | '<label for="site_reviews-settings-forms-recaptcha_v3-threshold">Score Threshold</label>'. |
||
| 1512 | '</th>'. |
||
| 1513 | '<td>'. |
||
| 1514 | '<input type="number" class="small-text" id="site_reviews-settings-forms-recaptcha_v3-threshold" name="site_reviews[settings][forms][recaptcha_v3][threshold]" min="0" max="1" step="0.1" value="" />'. |
||
| 1515 | '<p class="description">Description</p>'. |
||
| 1516 | '</td>'. |
||
| 1517 | '</tr>' |
||
| 1518 | ); |
||
| 1519 | } |
||
| 1520 | |||
| 1521 | public function test_build_forms_turnstile_key(): void |
||
| 1522 | { |
||
| 1523 | $this->assertEquals( |
||
| 1524 | $this->buildSetting('settings.forms.turnstile.key'), |
||
| 1525 | '<tr class="glsr-setting-field" data-field="settings.forms.turnstile.key">'. |
||
| 1526 | '<th scope="row">'. |
||
| 1527 | '<label for="site_reviews-settings-forms-turnstile-key">Site Key</label>'. |
||
| 1528 | '</th>'. |
||
| 1529 | '<td>'. |
||
| 1530 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-turnstile-key" name="site_reviews[settings][forms][turnstile][key]" autocomplete="off" value="" />'. |
||
| 1531 | '</td>'. |
||
| 1532 | '</tr>' |
||
| 1533 | ); |
||
| 1534 | } |
||
| 1535 | |||
| 1536 | public function test_build_forms_turnstile_secret(): void |
||
| 1537 | { |
||
| 1538 | $this->assertEquals( |
||
| 1539 | $this->buildSetting('settings.forms.turnstile.secret'), |
||
| 1540 | '<tr class="glsr-setting-field" data-field="settings.forms.turnstile.secret">'. |
||
| 1541 | '<th scope="row">'. |
||
| 1542 | '<label for="site_reviews-settings-forms-turnstile-secret">Secret Key</label>'. |
||
| 1543 | '</th>'. |
||
| 1544 | '<td>'. |
||
| 1545 | '<input type="text" class="regular-text" id="site_reviews-settings-forms-turnstile-secret" name="site_reviews[settings][forms][turnstile][secret]" autocomplete="off" value="" />'. |
||
| 1546 | '</td>'. |
||
| 1547 | '</tr>' |
||
| 1548 | ); |
||
| 1549 | } |
||
| 1550 | |||
| 1551 | public function test_build_forms_captcha_badge(): void |
||
| 1552 | { |
||
| 1553 | $this->assertEquals( |
||
| 1554 | $this->buildSetting('settings.forms.captcha.badge'), |
||
| 1555 | '<tr class="glsr-setting-field" data-field="settings.forms.captcha.badge">'. |
||
| 1556 | '<th scope="row">'. |
||
| 1557 | '<label for="site_reviews-settings-forms-captcha-badge">CAPTCHA Badge</label>'. |
||
| 1558 | '</th>'. |
||
| 1559 | '<td>'. |
||
| 1560 | '<select class="regular-text" id="site_reviews-settings-forms-captcha-badge" name="site_reviews[settings][forms][captcha][badge]">'. |
||
| 1561 | '<option value="bottomleft">Bottom Left</option>'. |
||
| 1562 | '<option value="bottomright">Bottom Right</option>'. |
||
| 1563 | '<option value="inline_above">Inline (Above Submit Button)</option>'. |
||
| 1564 | '<option value="inline_below">Inline (Below Submit Button)</option>'. |
||
| 1565 | '</select>'. |
||
| 1566 | '</td>'. |
||
| 1567 | '</tr>' |
||
| 1568 | ); |
||
| 1569 | } |
||
| 1570 | |||
| 1571 | public function test_build_forms_captcha_theme(): void |
||
| 1572 | { |
||
| 1573 | $this->assertEquals( |
||
| 1574 | $this->buildSetting('settings.forms.captcha.theme'), |
||
| 1575 | '<tr class="glsr-setting-field" data-field="settings.forms.captcha.theme">'. |
||
| 1576 | '<th scope="row">'. |
||
| 1577 | '<label for="site_reviews-settings-forms-captcha-theme">CAPTCHA Theme</label>'. |
||
| 1578 | '</th>'. |
||
| 1579 | '<td>'. |
||
| 1580 | '<select class="regular-text" id="site_reviews-settings-forms-captcha-theme" name="site_reviews[settings][forms][captcha][theme]">'. |
||
| 1581 | '<option value="light">Light</option>'. |
||
| 1582 | '<option value="dark">Dark</option>'. |
||
| 1583 | '</select>'. |
||
| 1584 | '</td>'. |
||
| 1585 | '</tr>' |
||
| 1586 | ); |
||
| 1587 | } |
||
| 1588 | |||
| 1589 | public function test_build_forms_captcha_usage(): void |
||
| 1590 | { |
||
| 1591 | $this->assertEquals( |
||
| 1592 | $this->buildSetting('settings.forms.captcha.usage'), |
||
| 1593 | '<tr class="glsr-setting-field" data-field="settings.forms.captcha.usage">'. |
||
| 1594 | '<th scope="row">'. |
||
| 1595 | '<label for="site_reviews-settings-forms-captcha-usage">CAPTCHA Usage</label>'. |
||
| 1596 | '</th>'. |
||
| 1597 | '<td>'. |
||
| 1598 | '<select class="regular-text" id="site_reviews-settings-forms-captcha-usage" name="site_reviews[settings][forms][captcha][usage]">'. |
||
| 1599 | '<option value="all">Use for everyone</option>'. |
||
| 1600 | '<option value="guest">Use only for guest users</option>'. |
||
| 1601 | '</select>'. |
||
| 1602 | '</td>'. |
||
| 1603 | '</tr>' |
||
| 1604 | ); |
||
| 1605 | } |
||
| 1606 | |||
| 1607 | public function test_build_forms_akismet(): void |
||
| 1608 | { |
||
| 1609 | $this->assertEquals( |
||
| 1610 | $this->buildSetting('settings.forms.akismet'), |
||
| 1611 | '<tr class="glsr-setting-field" data-field="settings.forms.akismet">'. |
||
| 1612 | '<th scope="row">'. |
||
| 1613 | '<label>Enable Akismet</label>'. |
||
| 1614 | '</th>'. |
||
| 1615 | '<td>'. |
||
| 1616 | '<fieldset data-depends="">'. |
||
| 1617 | '<legend class="screen-reader-text">'. |
||
| 1618 | '<span>Enable Akismet</span>'. |
||
| 1619 | '</legend>'. |
||
| 1620 | '<div class="inline">'. |
||
| 1621 | '<label for="site_reviews-settings-forms-akismet-1">'. |
||
| 1622 | '<input type="radio" id="site_reviews-settings-forms-akismet-1" name="site_reviews[settings][forms][akismet]" value="no" /> No'. |
||
| 1623 | '</label>'. |
||
| 1624 | '<br>'. |
||
| 1625 | '<label for="site_reviews-settings-forms-akismet-2">'. |
||
| 1626 | '<input type="radio" id="site_reviews-settings-forms-akismet-2" name="site_reviews[settings][forms][akismet]" value="yes" /> Yes'. |
||
| 1627 | '</label>'. |
||
| 1628 | '</div>'. |
||
| 1629 | '</fieldset>'. |
||
| 1630 | '</td>'. |
||
| 1631 | '</tr>' |
||
| 1632 | ); |
||
| 1633 | } |
||
| 1634 | |||
| 1635 | public function test_build_forms_prevent_duplicates(): void |
||
| 1660 | ); |
||
| 1661 | } |
||
| 1662 | |||
| 1663 | public function test_build_forms_blacklist_integration(): void |
||
| 1664 | { |
||
| 1665 | $this->assertEquals( |
||
| 1666 | $this->buildSetting('settings.forms.blacklist.integration'), |
||
| 1667 | '<tr class="glsr-setting-field" data-field="settings.forms.blacklist.integration">'. |
||
| 1668 | '<th scope="row">'. |
||
| 1669 | '<label for="site_reviews-settings-forms-blacklist-integration">Blacklist</label>'. |
||
| 1670 | '</th>'. |
||
| 1671 | '<td>'. |
||
| 1672 | '<select class="regular-text" id="site_reviews-settings-forms-blacklist-integration" name="site_reviews[settings][forms][blacklist][integration]">'. |
||
| 1673 | '<option value="">Use the Site Reviews Blacklist</option>'. |
||
| 1674 | '<option value="comments">Use the WordPress Disallowed Comment Keys</option>'. |
||
| 1675 | '</select>'. |
||
| 1676 | '</td>'. |
||
| 1677 | '</tr>' |
||
| 1678 | ); |
||
| 1679 | } |
||
| 1680 | |||
| 1681 | public function test_build_forms_blacklist_entries(): void |
||
| 1682 | { |
||
| 1683 | $this->assertEquals( |
||
| 1684 | $this->buildSetting('settings.forms.blacklist.entries'), |
||
| 1685 | '<tr class="glsr-setting-field" data-field="settings.forms.blacklist.entries">'. |
||
| 1686 | '<th scope="row">'. |
||
| 1687 | '<label for="site_reviews-settings-forms-blacklist-entries">Review Blacklist</label>'. |
||
| 1688 | '</th>'. |
||
| 1689 | '<td>'. |
||
| 1690 | '<textarea class="autosized code large-text" id="site_reviews-settings-forms-blacklist-entries" name="site_reviews[settings][forms][blacklist][entries]" rows="3"></textarea>'. |
||
| 1691 | '</td>'. |
||
| 1692 | '</tr>' |
||
| 1693 | ); |
||
| 1694 | } |
||
| 1695 | |||
| 1696 | public function test_build_forms_blacklist_action(): void |
||
| 1697 | { |
||
| 1698 | $this->assertEquals( |
||
| 1699 | $this->buildSetting('settings.forms.blacklist.action'), |
||
| 1700 | '<tr class="glsr-setting-field" data-field="settings.forms.blacklist.action">'. |
||
| 1701 | '<th scope="row">'. |
||
| 1702 | '<label for="site_reviews-settings-forms-blacklist-action">Blacklist Action</label>'. |
||
| 1703 | '</th>'. |
||
| 1704 | '<td>'. |
||
| 1705 | '<select class="regular-text" id="site_reviews-settings-forms-blacklist-action" name="site_reviews[settings][forms][blacklist][action]">'. |
||
| 1706 | '<option value="unapprove">Require approval</option>'. |
||
| 1707 | '<option value="reject">Reject submission</option>'. |
||
| 1708 | '</select>'. |
||
| 1709 | '</td>'. |
||
| 1710 | '</tr>' |
||
| 1711 | ); |
||
| 1712 | } |
||
| 1713 | |||
| 1714 | protected function build(array $args = []): string |
||
| 1721 | } |
||
| 1722 | |||
| 1723 | protected function buildSetting(string $name): string |
||
| 1724 | { |
||
| 1725 | $args = glsr()->settings($name); |
||
| 1726 | $args = wp_parse_args($args, compact('name')); |
||
| 1727 | return $this->build($args); |
||
| 1728 | } |
||
| 1729 | |||
| 1730 | protected function field(array $args = []): FieldContract |
||
| 1731 | { |
||
| 1732 | $field = new SettingField($args); |
||
| 1733 | if ($field->description) { |
||
| 1734 | $field->description = 'Description'; |
||
| 1741 | } |
||
| 1742 | } |
||
| 1743 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths