PluginProbe ʕ •ᴥ•ʔ
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More / 2.11.0
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More v2.11.0
2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.7 2.6.8 2.6.5 2.6.4 2.6.3 2.6.2 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1 1.1.1 1.1.2 1.2.0 2.0 2.1.0 2.1.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1
reviews-feed / tests / Unit / LicenseDeactivateStaleStateTest.php
reviews-feed / tests / Unit Last commit date
Doubles 1 week ago Providers 1 week ago BulkRearmOnGrowthTest.php 1 week ago BulkReviewsUpdateStuckStateTest.php 1 week ago ClearCacheRelayResetTest.php 1 week ago DeleteSourceRelayFailureTest.php 1 week ago ErrorHandlerFalsyOptionTest.php 1 week ago FeedCacheUpdateServiceTest.php 1 week ago FeedMalformedPayloadTest.php 1 week ago ForceKeylessRefetchTest.php 1 week ago LicenseDeactivateStaleStateTest.php 1 week ago MediaFinderMemoTest.php 1 week ago MultiSourceAggregationTest.php 1 week ago ReconcileMigratedLicenseRoutineTest.php 1 week ago ReconcileRemovalTest.php 1 week ago RegisterWebsiteRoutineTest.php 1 week ago RelaySlowEndpointsTest.php 1 week ago RemoteRequestMemoTest.php 1 week ago ReviewAlertHeaderTotalsTest.php 1 week ago ReviewAlertPageTargetingTest.php 1 week ago ReviewAlertStarFillTest.php 1 week ago ShortcodeNeutralizationTest.php 1 week ago SiteMigrationRecoveryTest.php 1 week ago Smash1130UsageTrackingHardeningTest.php 1 week ago Smash1130UsageTrackingHooksTest.php 1 week ago Smash1583HeaderParityTest.php 1 week ago Smash1631MultiLanguageBulkTest.php 1 week ago Smash1631UpdateSingleLangScopeTest.php 1 week ago Smash1706TripAdvisorPlaceIdTest.php 1 week ago Smash1756SchemaServiceTest.php 1 week ago Smash1785AvatarLocalUrlGuardTest.php 1 week ago Smash1785AvatarReHealTest.php 1 week ago Smash1795ReviewTextXssTest.php 1 week ago Smash1835TripAdvisorKeyShapeTest.php 1 week ago Smash1973WordpressOrgPlaceIdNullTest.php 1 week ago Smash1987NestedSourceErrorShapeTest.php 1 week ago Smash782BookingHeaderRatingTest.php 1 week ago Smash782CountryFlagEmojiTest.php 1 week ago Smash782ExternalRefreshCronTest.php 1 week ago Smash782ExtrasTemplateTest.php 1 week ago Smash782ReviewAlertProviderDataTest.php 1 week ago SourceIdLookupTest.php 1 week ago WpmlGetCurrentLanguageTest.php 1 week ago WpmlLanguageMappingTest.php 1 week ago
LicenseDeactivateStaleStateTest.php
92 lines
1 <?php
2
3 namespace SmashBalloon\Reviews\Tests\Unit;
4
5 use PHPUnit\Framework\TestCase;
6 use SmashBalloon\Reviews\Pro\Integrations\LicenseManagerService;
7
8 /**
9 * SMASH-1585 — deactivate stale-state recovery.
10 *
11 * When a migrated site clicks Deactivate, EDD has no activation for the new
12 * URL, so the relay returns errorId `licenseNotDeactivated` + edd_reason
13 * `failed`. ajax_deactivate_license() must recognize that as "nothing to
14 * deactivate, the local `valid` flag is stale" and clear local state so the
15 * panel falls back to Activate — instead of dead-ending on an error the
16 * customer cannot clear.
17 *
18 * These pin the detection predicate `is_nothing_to_deactivate()`, including the
19 * load-bearing detail that it reads FLAT keys (`$response['id']` /
20 * `$response['edd_reason']`) because SBRelay::call() unwraps the error envelope
21 * — reading `$response['data'][...]` (as the original support report proposed)
22 * would never fire.
23 */
24 class LicenseDeactivateStaleStateTest extends TestCase
25 {
26 private function predicate($response): bool
27 {
28 // The predicate only reads its argument — construct without deps.
29 $svc = (new \ReflectionClass(LicenseManagerService::class))
30 ->newInstanceWithoutConstructor();
31 $method = new \ReflectionMethod(LicenseManagerService::class, 'is_nothing_to_deactivate');
32 $method->setAccessible(true);
33
34 return $method->invoke($svc, $response);
35 }
36
37 public function test_fires_on_flat_licenseNotDeactivated_failed(): void
38 {
39 // The shape SBRelay::call() actually hands the plugin on this error
40 // (envelope unwrapped → flat keys).
41 $this->assertTrue($this->predicate([
42 'id' => 'licenseNotDeactivated',
43 'edd_reason' => 'failed',
44 ]));
45 }
46
47 public function test_does_not_fire_on_nested_shape(): void
48 {
49 // Proves we read FLAT keys. The original report's `$response['data']['id']`
50 // read would match this shape but never the real (unwrapped) response —
51 // so this MUST be false.
52 $this->assertFalse($this->predicate([
53 'data' => [
54 'id' => 'licenseNotDeactivated',
55 'edd_reason' => 'failed',
56 ],
57 ]));
58 }
59
60 public function test_does_not_fire_on_other_edd_reason(): void
61 {
62 // Scoped to `failed` — the "no activation for this URL" code. A transient
63 // or different reason must not clear local state.
64 $this->assertFalse($this->predicate([
65 'id' => 'licenseNotDeactivated',
66 'edd_reason' => 'expired',
67 ]));
68 }
69
70 public function test_does_not_fire_on_different_error_id(): void
71 {
72 $this->assertFalse($this->predicate([
73 'id' => 'invalidToken',
74 'edd_reason' => 'failed',
75 ]));
76 }
77
78 public function test_does_not_fire_on_success_response(): void
79 {
80 $this->assertFalse($this->predicate([
81 'success' => true,
82 'data' => ['license' => 'deactivated'],
83 ]));
84 }
85
86 public function test_does_not_fire_on_non_array(): void
87 {
88 $this->assertFalse($this->predicate(null));
89 $this->assertFalse($this->predicate('licenseNotDeactivated'));
90 }
91 }
92