forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.php
More file actions
88 lines (78 loc) · 2.37 KB
/
control.php
File metadata and controls
88 lines (78 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* Test_WP_Customize_Control tests.
*
* @package WordPress
*/
/**
* Tests for the Test_WP_Customize_Control class.
*
* @todo This is missing dedicated tests for all but one of the methods.
*
* @group customize
*/
class Test_WP_Customize_Control extends WP_UnitTestCase {
/**
* Manager.
*
* @var WP_Customize_Manager
*/
public $wp_customize;
/**
* Set up.
*/
function setUp() {
parent::setUp();
require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
// @codingStandardsIgnoreStart
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
// @codingStandardsIgnoreEnd
$this->wp_customize = $GLOBALS['wp_customize'];
}
/**
* Test WP_Customize_Control::check_capabilities().
*
* @see WP_Customize_Control::check_capabilities()
*/
function test_check_capabilities() {
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
do_action( 'customize_register', $this->wp_customize );
$control = new WP_Customize_Control( $this->wp_customize, 'blogname', array(
'settings' => array( 'blogname' ),
) );
$this->assertTrue( $control->check_capabilities() );
$control = new WP_Customize_Control( $this->wp_customize, 'blogname', array(
'settings' => array( 'blogname', 'non_existing' ),
) );
$this->assertFalse( $control->check_capabilities() );
$this->wp_customize->add_setting( 'top_secret_message', array(
'capability' => 'top_secret_clearance',
) );
$control = new WP_Customize_Control( $this->wp_customize, 'blogname', array(
'settings' => array( 'blogname', 'top_secret_clearance' ),
) );
$this->assertFalse( $control->check_capabilities() );
$control = new WP_Customize_Control( $this->wp_customize, 'no_setting', array(
'settings' => array(),
) );
$this->assertTrue( $control->check_capabilities() );
$control = new WP_Customize_Control( $this->wp_customize, 'no_setting', array(
'settings' => array(),
'capability' => 'top_secret_clearance',
) );
$this->assertFalse( $control->check_capabilities() );
$control = new WP_Customize_Control( $this->wp_customize, 'no_setting', array(
'settings' => array(),
'capability' => 'edit_theme_options',
) );
$this->assertTrue( $control->check_capabilities() );
}
/**
* Tear down.
*/
function tearDown() {
$this->wp_customize = null;
unset( $GLOBALS['wp_customize'] );
parent::tearDown();
}
}