PluginProbe
Extendify / 3.1.1
Extendify v3.1.1
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 / Shared / Services / PluginsActivation / ImagifyTest.php

ImagifyTest.php in Extendify 3.1.1, at tests/Integration/Shared/Services/PluginsActivation/ImagifyTest.php

46 lines 1.3 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\Shared\Services\PluginsActivation;
4
5 use Extendify\Shared\Services\PluginsActivation\Imagify;
6 use ReflectionMethod;
7 use WP_UnitTestCase;
8
9 class ImagifyTest extends WP_UnitTestCase
10 {
11 private static function saveKey(array $data)
12 {
13 $method = new ReflectionMethod(Imagify::class, 'saveKey');
14 $method->setAccessible(true);
15 $method->invoke(null, $data);
16 }
17
18 public function test_save_key_stores_api_key_when_settings_absent()
19 {
20 self::saveKey(['api_key' => 'abc123']);
21
22 $this->assertSame(['api_key' => 'abc123'], get_option('imagify_settings'));
23 }
24
25 public function test_save_key_preserves_existing_settings()
26 {
27 update_option('imagify_settings', ['optimization_level' => 2, 'api_key' => 'old']);
28
29 self::saveKey(['api_key' => 'new456']);
30
31 $this->assertSame(
32 ['optimization_level' => 2, 'api_key' => 'new456'],
33 get_option('imagify_settings')
34 );
35 }
36
37 public function test_save_key_does_nothing_without_api_key()
38 {
39 update_option('imagify_settings', ['optimization_level' => 2]);
40
41 self::saveKey([]);
42
43 $this->assertSame(['optimization_level' => 2], get_option('imagify_settings'));
44 }
45 }
46