Skip to content

Commit

Permalink
Merge pull request #3439 from the-events-calendar/fix/sl-248-seating-…
Browse files Browse the repository at this point in the history
…license-check

[SL-248] Hide seating settings when license is not valid.
  • Loading branch information
rafsuntaskin authored Dec 4, 2024
2 parents d89fe2d + d623046 commit c37e652
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-sl-248-seating-license-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Hide seating reservation settings when seating license is not valid. [SL-248]
8 changes: 8 additions & 0 deletions src/Tickets/Seating/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use TEC\Common\Contracts\Provider\Controller as Controller_Contract;
use TEC\Common\StellarWP\Arrays\Arr;
use TEC\Tickets\Seating\Service\Service;

/**
* Class Settings.
Expand Down Expand Up @@ -51,12 +52,19 @@ public function unregister(): void {
* Add display settings for Event Tickets.
*
* @since 5.17.0
* @since TBD Only add settings if the seating service has a valid license.
*
* @param array $settings List of display settings.
*
* @return array List of display settings.
*/
public function add_frontend_timer_settings( array $settings ): array {
$service_status = tribe( Service::class )->get_status();

if ( $service_status->has_no_license() || $service_status->is_license_invalid() ) {
return $settings;
}

$timer_settings = [
'ticket-seating-options-heading' => [
'type' => 'html',
Expand Down
53 changes: 53 additions & 0 deletions tests/slr_integration/Settings_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use tad\Codeception\SnapshotAssertions\SnapshotAssertions;
use TEC\Common\Tests\Provider\Controller_Test_Case;
use TEC\Tickets\Seating\Frontend\Timer;
use TEC\Tickets\Seating\Service\Service_Status;

class Settings_Test extends Controller_Test_Case {
use SnapshotAssertions;
Expand All @@ -28,6 +29,58 @@ public function test_seating_reservation_setting_is_included_after_login_require
$this->assertMatchesJsonSnapshot( wp_json_encode( $settings, JSON_SNAPSHOT_OPTIONS ) );
}

public function test_seating_reservation_setting_not_included_with_invalid_license() {
add_filter(
'tec_tickets_seating_service_status',
function ( $_status, $backend_base_url ) {
return new Service_Status( $backend_base_url, Service_Status::INVALID_LICENSE );
},
1000,
2
);

$this->make_controller()->register();

$settings = apply_filters(
'tribe_tickets_settings_tab_fields',
[
'ticket-authentication-requirements' => [
'type' => 'checkbox',
'label' => 'Require Login',
],
]
);

$this->assertArrayNotHasKey( 'tickets-seating-timer-limit', $settings );
$this->assertMatchesJsonSnapshot( wp_json_encode( $settings, JSON_SNAPSHOT_OPTIONS ) );
}

public function test_seating_reservation_setting_not_included_with_no_license() {
add_filter(
'tec_tickets_seating_service_status',
function ( $_status, $backend_base_url ) {
return new Service_Status( $backend_base_url, Service_Status::NO_LICENSE );
},
1000,
2
);

$this->make_controller()->register();

$settings = apply_filters(
'tribe_tickets_settings_tab_fields',
[
'ticket-authentication-requirements' => [
'type' => 'checkbox',
'label' => 'Require Login',
],
]
);

$this->assertArrayNotHasKey( 'tickets-seating-timer-limit', $settings );
$this->assertMatchesJsonSnapshot( wp_json_encode( $settings, JSON_SNAPSHOT_OPTIONS ) );
}

public function test_saved_reservation_timer_is_used() {
$this->make_controller()->register();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ticket-authentication-requirements": {
"type": "checkbox",
"label": "Require Login"
},
"ticket-telemetry-optin-heading": {
"type": "html",
"html": "<h3 id=\"event-tickets-telemetry-settings\">Telemetry</h3>"
},
"opt-in-status": {
"type": "checkbox_bool",
"label": "Opt in to Telemetry",
"tooltip": "Enable this option to share usage data with Event Tickets and StellarWP. <a href=\" https://evnt.is/1bcl \">What permissions are being granted?</a> <a href=\" https://evnt.is/1bcm \">Read our Terms of Service</a> <a href=\" https://evnt.is/1bcn \">Read our Privacy Policy</a>",
"default": false,
"validation_type": "boolean"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ticket-authentication-requirements": {
"type": "checkbox",
"label": "Require Login"
},
"ticket-telemetry-optin-heading": {
"type": "html",
"html": "<h3 id=\"event-tickets-telemetry-settings\">Telemetry</h3>"
},
"opt-in-status": {
"type": "checkbox_bool",
"label": "Opt in to Telemetry",
"tooltip": "Enable this option to share usage data with Event Tickets and StellarWP. <a href=\" https://evnt.is/1bcl \">What permissions are being granted?</a> <a href=\" https://evnt.is/1bcm \">Read our Terms of Service</a> <a href=\" https://evnt.is/1bcn \">Read our Privacy Policy</a>",
"default": false,
"validation_type": "boolean"
}
}

0 comments on commit c37e652

Please sign in to comment.