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 / InsightsTest.php

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

51 lines 1.5 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\Insights;
6 use WP_UnitTestCase;
7
8 class InsightsTest extends WP_UnitTestCase
9 {
10 public function test_setup_rolls_a_variant_for_an_active_test()
11 {
12 delete_option(Insights::ACTIVE_TESTS_OPTION);
13
14 Insights::setup(['AutoLaunch.WebsiteTitle']);
15
16 $tests = get_option(Insights::ACTIVE_TESTS_OPTION);
17 $this->assertArrayHasKey('AutoLaunch.WebsiteTitle', $tests);
18 $this->assertContains($tests['AutoLaunch.WebsiteTitle'], ['A', 'B']);
19 }
20
21 public function test_setup_drops_inactive_tests()
22 {
23 update_option(Insights::ACTIVE_TESTS_OPTION, ['AutoLaunch.WebsiteTitle' => 'B']);
24
25 Insights::setup([]);
26
27 $tests = get_option(Insights::ACTIVE_TESTS_OPTION);
28 $this->assertArrayNotHasKey('AutoLaunch.WebsiteTitle', $tests);
29 }
30
31 public function test_setup_keeps_an_already_assigned_variant()
32 {
33 update_option(Insights::ACTIVE_TESTS_OPTION, ['AutoLaunch.WebsiteTitle' => 'B']);
34
35 Insights::setup(['AutoLaunch.WebsiteTitle']);
36
37 $tests = get_option(Insights::ACTIVE_TESTS_OPTION);
38 $this->assertSame('B', $tests['AutoLaunch.WebsiteTitle']);
39 }
40
41 public function test_setup_leaves_unknown_keys_untouched()
42 {
43 update_option(Insights::ACTIVE_TESTS_OPTION, ['SomeOther.Test' => 'A']);
44
45 Insights::setup(['AutoLaunch.WebsiteTitle']);
46
47 $tests = get_option(Insights::ACTIVE_TESTS_OPTION);
48 $this->assertSame('A', $tests['SomeOther.Test']);
49 }
50 }
51