Changeset 46413 for trunk/tests/phpunit/tests/menu/walker-nav-menu.php
- Timestamp:
- 10/06/2019 03:04:18 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/menu/walker-nav-menu.php
r45141 r46413 4 4 * @group walker 5 5 */ 6 class Tests_ Walker_Nav_Menu extends WP_UnitTestCase {6 class Tests_Menu_Walker_Nav_Menu extends WP_UnitTestCase { 7 7 8 8 /** … … 19 19 parent::setUp(); 20 20 21 /** Walker_Nav_Menu _Editclass */21 /** Walker_Nav_Menu class */ 22 22 require_once ABSPATH . 'wp-includes/class-walker-nav-menu.php'; 23 23 $this->walker = new Walker_Nav_Menu(); … … 38 38 39 39 /** 40 * Tests when an item s target it _blank, that rel="'noopener noreferrer" is added.40 * Tests when an item's target is _blank, that rel="noopener noreferrer" is added. 41 41 * 42 * @ticket #4329042 * @ticket 43290 43 43 */ 44 44 public function test_noopener_no_referrer_for_target_blank() { … … 67 67 $this->assertSame( "<li id=\"menu-item-{$post_id}\" class=\"menu-item-{$post_id}\"><a target=\"_blank\" rel=\"noopener noreferrer\">{$post_title}</a>", $expected ); 68 68 } 69 70 /** 71 * @ticket 47720 72 * 73 * @dataProvider data_start_el_with_empty_attributes 74 */ 75 public function test_start_el_with_empty_attributes( $value, $expected ) { 76 $output = ''; 77 $post_id = $this->factory->post->create(); 78 $post_title = get_the_title( $post_id ); 79 80 $item = array( 81 'ID' => $post_id, 82 'object_id' => $post_id, 83 'title' => $post_title, 84 'target' => '', 85 'xfn' => '', 86 'current' => false, 87 ); 88 89 $args = array( 90 'before' => '', 91 'after' => '', 92 'link_before' => '', 93 'link_after' => '', 94 ); 95 96 add_filter( 97 'nav_menu_link_attributes', 98 function( $atts ) use ( $value ) { 99 $atts['data-test'] = $value; 100 return $atts; 101 } 102 ); 103 104 $this->walker->start_el( $output, (object) $item, 0, (object) $args ); 105 106 if ( '' !== $expected ) { 107 $expected = sprintf( ' data-test="%s"', $expected ); 108 } 109 110 $this->assertSame( "<li id=\"menu-item-{$post_id}\" class=\"menu-item-{$post_id}\"><a{$expected}>{$post_title}</a>", $output ); 111 } 112 113 public function data_start_el_with_empty_attributes() { 114 return array( 115 array( 116 '', 117 '', 118 ), 119 array( 120 0, 121 '0', 122 ), 123 array( 124 0.0, 125 '0', 126 ), 127 array( 128 '0', 129 '0', 130 ), 131 array( 132 null, 133 '', 134 ), 135 array( 136 false, 137 '', 138 ), 139 array( 140 true, 141 '1', 142 ), 143 array( 144 array(), 145 '', 146 ), 147 ); 148 } 69 149 }
Note: See TracChangeset
for help on using the changeset viewer.