Changeset 32292 for trunk/tests/phpunit/tests/category/wpListCategories.php
- Timestamp:
- 04/24/2015 02:56:37 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/category/wpListCategories.php
r31301 r32292 101 101 } 102 102 103 /** 104 * @ticket 21881 105 */ 106 public function test_show_option_all_link_should_link_to_post_type_archive_when_taxonomy_does_not_apply_to_posts() { 107 register_post_type( 'wptests_pt', array( 'has_archive' => true ) ); 108 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); 109 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); 110 111 $terms = $this->factory->term->create_many( 2, array( 112 'taxonomy' => 'wptests_tax', 113 ) ); 114 115 $found = wp_list_categories( array( 116 'echo' => false, 117 'show_option_all' => 'All', 118 'hide_empty' => false, 119 'taxonomy' => 'wptests_tax', 120 ) ); 121 122 $pt_archive = get_post_type_archive_link( 'wptests_pt' ); 123 124 $this->assertContains( "<li class='cat-item-all'><a href='" . $pt_archive . "'>All</a></li>", $found ); 125 } 126 127 /** 128 * @ticket 21881 129 */ 130 public function test_show_option_all_link_should_not_link_to_post_type_archive_if_has_archive_is_false() { 131 register_post_type( 'wptests_pt', array( 'has_archive' => false ) ); 132 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); 133 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); 134 135 $terms = $this->factory->term->create_many( 2, array( 136 'taxonomy' => 'wptests_tax', 137 ) ); 138 139 $found = wp_list_categories( array( 140 'echo' => false, 141 'show_option_all' => 'All', 142 'hide_empty' => false, 143 'taxonomy' => 'wptests_tax', 144 ) ); 145 146 $pt_archive = get_post_type_archive_link( 'wptests_pt2' ); 147 148 $this->assertContains( "<li class='cat-item-all'><a href='" . $pt_archive . "'>All</a></li>", $found ); 149 } 150 151 public function test_show_option_all_link_should_link_to_post_archive_if_available() { 152 register_post_type( 'wptests_pt', array( 'has_archive' => true ) ); 153 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); 154 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'post', 'wptests_pt2' ) ); 155 156 $terms = $this->factory->term->create_many( 2, array( 157 'taxonomy' => 'wptests_tax', 158 ) ); 159 160 $found = wp_list_categories( array( 161 'echo' => false, 162 'show_option_all' => 'All', 163 'hide_empty' => false, 164 'taxonomy' => 'wptests_tax', 165 ) ); 166 167 $url = home_url( '/' ); 168 169 $this->assertContains( "<li class='cat-item-all'><a href='" . $url . "'>All</a></li>", $found ); 170 } 171 172 public function test_show_option_all_link_should_link_to_post_archive_if_no_associated_post_types_have_archives() { 173 register_post_type( 'wptests_pt', array( 'has_archive' => false ) ); 174 register_post_type( 'wptests_pt2', array( 'has_archive' => false ) ); 175 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); 176 177 $terms = $this->factory->term->create_many( 2, array( 178 'taxonomy' => 'wptests_tax', 179 ) ); 180 181 $found = wp_list_categories( array( 182 'echo' => false, 183 'show_option_all' => 'All', 184 'hide_empty' => false, 185 'taxonomy' => 'wptests_tax', 186 ) ); 187 188 $url = home_url( '/' ); 189 190 $this->assertContains( "<li class='cat-item-all'><a href='" . $url . "'>All</a></li>", $found ); 191 } 192 103 193 public function list_cats_callback( $cat ) { 104 194 if ( 'Test Cat 1' === $cat ) {
Note: See TracChangeset
for help on using the changeset viewer.