PluginProbe
Extendify / 3.1.0
Extendify v3.1.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / tests / Integration / PartnerDataTest.php

PartnerDataTest.php in Extendify 3.1.0, at tests/Integration/PartnerDataTest.php

75 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Extendify\Tests\Integration;
4
5 use Extendify\PartnerData;
6 use WP_UnitTestCase;
7
8 /**
9 * showQuickEdit + showSimpleToolbar must round-trip from the partner-data
10 * response into PartnerData::setting(). __construct re-applies ~30 keys
11 * from the merged response onto self::$config, but until this phase had
12 * no line for these two — so setting() returned the hardcoded default
13 * regardless of the partner value (the gate idiom in Toolbar/QuickEdit
14 * would never see a true).
15 */
16 class PartnerDataTest extends WP_UnitTestCase
17 {
18 public static function setUpBeforeClass(): void
19 {
20 parent::setUpBeforeClass();
21 // getPartnerData() opts out (returns []) without a partner id,
22 // which would bypass the response→config re-apply under test.
23 if (!defined('EXTENDIFY_PARTNER_ID')) {
24 define('EXTENDIFY_PARTNER_ID', 'test-partner');
25 }
26 }
27
28 public function setUp(): void
29 {
30 parent::setUp();
31 // self::$config is static and survives across tests in-process;
32 // reset to the declared defaults so each case starts clean.
33 $this->setConfigValue('showQuickEdit', false);
34 $this->setConfigValue('showSimpleToolbar', false);
35 delete_transient('extendify_partner_data_cache_check');
36 }
37
38 public function test_show_quick_edit_true_in_response_round_trips_to_setting()
39 {
40 update_option('extendify_partner_data_v2', ['showQuickEdit' => true]);
41
42 new PartnerData();
43
44 $this->assertTrue(PartnerData::setting('showQuickEdit'));
45 }
46
47 public function test_show_simple_toolbar_true_in_response_round_trips_to_setting()
48 {
49 update_option('extendify_partner_data_v2', ['showSimpleToolbar' => true]);
50
51 new PartnerData();
52
53 $this->assertTrue(PartnerData::setting('showSimpleToolbar'));
54 }
55
56 public function test_flags_default_false_when_absent_from_response()
57 {
58 update_option('extendify_partner_data_v2', ['license' => 'active']);
59
60 new PartnerData();
61
62 $this->assertFalse(PartnerData::setting('showQuickEdit'));
63 $this->assertFalse(PartnerData::setting('showSimpleToolbar'));
64 }
65
66 private function setConfigValue(string $key, $value): void
67 {
68 $prop = new \ReflectionProperty(PartnerData::class, 'config');
69 $prop->setAccessible(true);
70 $config = $prop->getValue();
71 $config[$key] = $value;
72 $prop->setValue(null, $config);
73 }
74 }
75