forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwalkerPage.php
More file actions
87 lines (78 loc) · 1.42 KB
/
walkerPage.php
File metadata and controls
87 lines (78 loc) · 1.42 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
<?php
/**
* @group post
* @group walker
*/
class Tests_Post_Walker_Page extends WP_UnitTestCase {
/**
* @var \Walker_Page The instance of the walker.
*/
public $walker;
/**
* Setup.
*/
public function setUp() {
parent::setUp();
/** Walker_Page class */
require_once ABSPATH . 'wp-includes/class-walker-page.php';
$this->walker = new Walker_Page();
}
/**
* @ticket 47720
*
* @dataProvider data_start_el_with_empty_attributes
*/
public function test_start_el_with_empty_attributes( $value, $expected ) {
$output = '';
$page = $this->factory->post->create_and_get( array( 'post_type' => 'page' ) );
$link = get_permalink( $page );
add_filter(
'page_menu_link_attributes',
function( $atts ) use ( $value ) {
$atts['data-test'] = $value;
return $atts;
}
);
$this->walker->start_el( $output, $page, 0 );
if ( '' !== $expected ) {
$expected = sprintf( ' data-test="%s"', $expected );
}
$this->assertSame( "<li class=\"page_item page-item-{$page->ID}\"><a href=\"{$link}\"{$expected}>{$page->post_title}</a>", $output );
}
public function data_start_el_with_empty_attributes() {
return array(
array(
'',
'',
),
array(
0,
'0',
),
array(
0.0,
'0',
),
array(
'0',
'0',
),
array(
null,
'',
),
array(
false,
'',
),
array(
true,
'1',
),
array(
array(),
'',
),
);
}
}