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 / RegisterWebsiteRoutineTest.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
RegisterWebsiteRoutineTest.php
77 lines
1 <?php
2
3 namespace SmashBalloon\Reviews\Tests\Unit;
4
5 use PHPUnit\Framework\TestCase;
6 use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\RegisterWebsiteRoutine;
7
8 /**
9 * Regression coverage for the rate-limit transient that bounds /auth/register
10 * traffic per site to 1 call / 5 minutes regardless of upstream loop behaviour.
11 *
12 * @see SMASH-1274 — the earlier 2.5.3 version of this routine cleared the
13 * transient on successful registration, which defeated the limiter during
14 * the migration-detect loop (token wipe + successful re-register +
15 * transient clear repeated every request). 2.5.5 keeps the transient
16 * active regardless of outcome.
17 */
18 class RegisterWebsiteRoutineTest extends TestCase
19 {
20 protected function setUp(): void
21 {
22 parent::setUp();
23 global $wp_options_mock, $wp_transients_mock, $wp_home_url_mock;
24 $wp_options_mock = [];
25 $wp_transients_mock = [];
26 $wp_home_url_mock = 'https://example.com';
27 }
28
29 /** Exposes protected will_run() for direct testing. */
30 private function will_run(RegisterWebsiteRoutine $routine): bool
31 {
32 $reflection = new \ReflectionClass($routine);
33 $method = $reflection->getMethod('will_run');
34 $method->setAccessible(true);
35 return (bool) $method->invoke($routine);
36 }
37
38 public function test_will_run_returns_true_when_no_token_and_no_cooldown(): void
39 {
40 global $wp_options_mock;
41 $wp_options_mock['sbr_settings'] = [];
42
43 $this->assertTrue($this->will_run(new RegisterWebsiteRoutine()));
44 }
45
46 public function test_will_run_returns_false_when_token_is_present(): void
47 {
48 global $wp_options_mock;
49 $wp_options_mock['sbr_settings'] = ['access_token' => 'tok-abc'];
50
51 $this->assertFalse($this->will_run(new RegisterWebsiteRoutine()));
52 }
53
54 /**
55 * Core regression for the 2.5.5 fix — when the cooldown transient is set,
56 * will_run() must return false even though the access_token is empty. If
57 * it doesn't, the migration-detect loop (wipe → re-register → repeat)
58 * will hammer /auth/register regardless of the rate-limit intent.
59 */
60 public function test_will_run_returns_false_when_cooldown_transient_is_set(): void
61 {
62 global $wp_options_mock, $wp_transients_mock;
63 $wp_options_mock['sbr_settings'] = []; // no access_token
64 $wp_transients_mock['sbr_register_retry_cooldown'] = time();
65
66 $this->assertFalse($this->will_run(new RegisterWebsiteRoutine()));
67 }
68
69 public function test_will_run_returns_true_on_corrupted_settings(): void
70 {
71 global $wp_options_mock;
72 $wp_options_mock['sbr_settings'] = 'not-an-array'; // simulate corruption
73
74 $this->assertTrue($this->will_run(new RegisterWebsiteRoutine()));
75 }
76 }
77