PluginProbe ʕ •ᴥ•ʔ
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More / 2.7.0
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More v2.7.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 / Providers / EddProviderGateTest.php
reviews-feed / tests / Unit / Providers Last commit date
DuplicatePreventionTest.php 1 month ago EddItemTemplateBcTest.php 1 month ago EddProviderGateTest.php 1 month ago EddTitleRenderingBcTest.php 1 month ago Smash782BookingUrlHotelIdTest.php 1 month ago
EddProviderGateTest.php
122 lines
1 <?php
2
3 namespace SmashBalloon\Reviews\Tests\Unit\Providers;
4
5 use PHPUnit\Framework\TestCase;
6 use SmashBalloon\Reviews\Pro\Integrations\Providers\EDD;
7
8 /**
9 * EDD provider Add-Source gate.
10 *
11 * Covers the strict pluginRequired check used by Util::get_providers()
12 * and EDD::registerProvider() so the customizer modal disables the EDD
13 * tile (and shows the precise tooltip) when either EDD core or the
14 * EDD Reviews extension is missing.
15 *
16 * Matrix:
17 * - no EDD core → gate blocks, message points at EDD core
18 * - EDD core only → gate blocks, message points at EDD Reviews extension
19 * - EDD core + extension → gate opens
20 * - alternate extension path → gate opens (covers easy-digital-downloads-reviews/edd-reviews.php)
21 */
22 class EddProviderGateTest extends TestCase
23 {
24 const EDD_CORE_PATH = 'easy-digital-downloads/easy-digital-downloads.php';
25 const EDD_REVIEWS_PATH = 'edd-reviews/edd-reviews.php';
26 const EDD_REVIEWS_ALT_PATH = 'easy-digital-downloads-reviews/edd-reviews.php';
27
28 protected function setUp(): void
29 {
30 parent::setUp();
31
32 global $wp_active_plugins_mock;
33 $wp_active_plugins_mock = [];
34 }
35
36 protected function tearDown(): void
37 {
38 global $wp_active_plugins_mock;
39 $wp_active_plugins_mock = [];
40
41 parent::tearDown();
42 }
43
44 /**
45 * Cell 1: nothing installed — message must steer the user to install
46 * EDD core, not the extension.
47 */
48 public function test_gate_blocks_and_points_at_core_when_nothing_installed(): void
49 {
50 $this->assertFalse(EDD::is_active_static());
51 $this->assertSame(
52 'Enable Easy Digital Downloads plugin to use it as a source',
53 EDD::plugin_required_message()
54 );
55 }
56
57 /**
58 * Cell 2: EDD core present, extension absent — exactly the QA failure
59 * mode that motivated this fix. The gate must stay closed and the
60 * message must call out the missing extension.
61 */
62 public function test_gate_blocks_and_points_at_extension_when_only_core(): void
63 {
64 global $wp_active_plugins_mock;
65 $wp_active_plugins_mock = [self::EDD_CORE_PATH];
66
67 $this->assertFalse(EDD::is_active_static());
68 $this->assertSame(
69 'EDD Reviews extension is required. Install and activate EDD Reviews to use it as a source.',
70 EDD::plugin_required_message()
71 );
72 }
73
74 /**
75 * Cell 3: both plugins active — gate opens. Message returned in this
76 * state is unused by the modal (tile isn't disabled), but we keep it
77 * deterministic regardless.
78 */
79 public function test_gate_opens_when_core_and_reviews_extension_active(): void
80 {
81 global $wp_active_plugins_mock;
82 $wp_active_plugins_mock = [self::EDD_CORE_PATH, self::EDD_REVIEWS_PATH];
83
84 $this->assertTrue(EDD::is_active_static());
85 }
86
87 /**
88 * Cell 4: alternate slug used by older bundles of the EDD Reviews
89 * extension (`easy-digital-downloads-reviews/edd-reviews.php`). The
90 * gate must accept it — otherwise legitimate Pro Plus customers on
91 * older installs would be blocked.
92 */
93 public function test_gate_opens_for_alternate_extension_slug(): void
94 {
95 global $wp_active_plugins_mock;
96 $wp_active_plugins_mock = [self::EDD_CORE_PATH, self::EDD_REVIEWS_ALT_PATH];
97
98 $this->assertTrue(EDD::is_active_static());
99 }
100
101 /**
102 * BC contract: the static gate must NOT fall back to "DB has orphan
103 * edd_review rows". The runtime is_edd_active() instance method keeps
104 * that fallback (so existing sources still display when the extension
105 * was uninstalled later), but the Add-Source flow needs the live
106 * extension to capture new reviews — otherwise the integration would
107 * silently stop syncing for the customer.
108 *
109 * If a future refactor reintroduces the DB fallback here, this test
110 * fails and forces the author to revisit the trade-off.
111 */
112 public function test_gate_does_not_fallback_to_db_when_extension_missing(): void
113 {
114 global $wp_active_plugins_mock;
115 $wp_active_plugins_mock = [self::EDD_CORE_PATH];
116
117 // Note: we don't touch $wpdb here. The test passing means the
118 // static gate didn't query the DB — which is the contract.
119 $this->assertFalse(EDD::is_active_static());
120 }
121 }
122