forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomHeader.php
More file actions
125 lines (100 loc) · 2.67 KB
/
customHeader.php
File metadata and controls
125 lines (100 loc) · 2.67 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* @group themes
*/
class Tests_Theme_Custom_Header extends WP_UnitTestCase {
static $post;
public static function wpSetUpBeforeClass( $factory ) {
self::$post = self::factory()->post->create( array(
'post_status' => 'publish',
) );
}
function tearDown() {
remove_theme_support( 'custom-header' );
parent::tearDown();
}
/**
* @ticket 38738
*/
function test_video_header_callback_front_page_from_front_page() {
$this->_add_theme_support( array(
'video' => true,
) );
$this->go_to( home_url() );
$result = is_header_video_active();
$this->assertTrue( $result );
}
/**
* @ticket 38738
*/
function test_video_header_callback_front_page_from_elsewhere() {
$this->_add_theme_support( array(
'video' => true,
) );
$this->go_to( get_permalink( self::$post ) );
$result = is_header_video_active();
$this->assertFalse( $result );
}
/**
* @ticket 38738
*/
function test_video_header_callback_globally_from_front_page() {
$this->_add_theme_support( array(
'video' => true,
'video-active-callback' => '__return_true',
) );
$this->go_to( home_url() );
$result = is_header_video_active();
$this->assertTrue( $result );
}
/**
* @ticket 38738
*/
function test_video_header_callback_globally_from_elsewhere() {
$this->_add_theme_support( array(
'video' => true,
'video-active-callback' => '__return_true',
) );
$this->go_to( get_permalink( self::$post ) );
$result = is_header_video_active();
$this->assertTrue( $result );
}
/**
* @ticket 38738
*/
function test_video_header_callback_globally_with_negative_filter() {
$this->_add_theme_support( array(
'video' => true,
'video-active-callback' => '__return_true',
) );
$this->go_to( get_permalink( self::$post ) );
add_filter( 'is_header_video_active', '__return_false' );
$result = is_header_video_active();
remove_filter( 'is_header_video_active', '__return_false' );
$this->assertFalse( $result );
}
/**
* Adds arguments directly to the $_wp_theme_features global. Calling
* add_theme_support( 'custom-header' ) will poison subsequent tests since
* it defines constants.
*/
function _add_theme_support( $args = array() ) {
global $_wp_theme_features;
$_wp_theme_features['custom-header'][0] = wp_parse_args( $args, array(
'default-image' => '',
'random-default' => false,
'width' => 0,
'height' => 0,
'flex-height' => false,
'flex-width' => false,
'default-text-color' => '',
'header-text' => true,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
'video' => false,
'video-active-callback' => 'is_front_page',
) );
}
}