|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Test_WPCOM_CSS_Customizer_Nudge file. |
|
4
|
|
|
* Test WPCOM_CSS_Customizer_Nudge. |
|
5
|
|
|
* |
|
6
|
|
|
* @package Jetpack |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Automattic\Jetpack\Dashboard_Customizations; |
|
10
|
|
|
|
|
11
|
|
|
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; |
|
12
|
|
|
require_once ABSPATH . WPINC . '/class-wp-customize-control.php'; |
|
13
|
|
|
require_once ABSPATH . WPINC . '/class-wp-customize-section.php'; |
|
14
|
|
|
|
|
15
|
|
|
require_jetpack_file( 'modules/masterbar/nudges/bootstrap.php' ); |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class Test_CSS_Customizer_Nudge |
|
19
|
|
|
*/ |
|
20
|
|
|
class Test_CSS_Customizer_Nudge extends \WP_UnitTestCase { |
|
21
|
|
|
/** |
|
22
|
|
|
* A mock Customize manager. |
|
23
|
|
|
* |
|
24
|
|
|
* @var \WP_Customize_Manager |
|
25
|
|
|
*/ |
|
26
|
|
|
private $wp_customize; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Register a customizer manager. |
|
30
|
|
|
* |
|
31
|
|
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
|
|
public function setUp() { |
|
34
|
|
|
parent::setUp(); |
|
35
|
|
|
|
|
36
|
|
|
$this->wp_customize = new \WP_Customize_Manager(); |
|
37
|
|
|
register_css_nudge_control( $this->wp_customize ); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Check if the assets are registered. |
|
42
|
|
|
*/ |
|
43
|
|
|
public function test_it_enqueues_the_assets() { |
|
44
|
|
|
$nudge = new CSS_Customizer_Nudge( 'url', 'message' ); |
|
45
|
|
|
|
|
46
|
|
|
$nudge->customize_register_nudge( $this->wp_customize ); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertEquals( |
|
49
|
|
|
10, |
|
50
|
|
|
has_action( |
|
51
|
|
|
'customize_controls_enqueue_scripts', |
|
52
|
|
|
array( |
|
53
|
|
|
$nudge, |
|
54
|
|
|
'customize_controls_enqueue_scripts_nudge', |
|
55
|
|
|
) |
|
56
|
|
|
) |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Check if it creates the css nudge control. |
|
62
|
|
|
*/ |
|
63
|
|
|
public function test_if_it_creates_a_css_nudge_control() { |
|
64
|
|
|
$nudge = new CSS_Customizer_Nudge( 'url', 'message' ); |
|
65
|
|
|
|
|
66
|
|
|
$nudge->customize_register_nudge( $this->wp_customize ); |
|
67
|
|
|
|
|
68
|
|
|
$this->assertArrayHasKey( 'custom_css_control', $this->wp_customize->controls() ); |
|
69
|
|
|
$this->assertArrayHasKey( 'custom_css', $this->wp_customize->sections() ); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Check if the url and message are passed correctly to the custom control object. |
|
74
|
|
|
*/ |
|
75
|
|
|
public function test_if_the_url_and_message_are_passed_correctly() { |
|
76
|
|
|
$nudge = new CSS_Customizer_Nudge( 'url', 'message' ); |
|
77
|
|
|
|
|
78
|
|
|
$nudge->customize_register_nudge( $this->wp_customize ); |
|
79
|
|
|
|
|
80
|
|
|
$this->assertEquals( 'url', $this->wp_customize->controls()['custom_css_control']->cta_url ); |
|
81
|
|
|
$this->assertEquals( 'message', $this->wp_customize->controls()['custom_css_control']->nudge_copy ); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
|