- Timestamp:
- 10/11/2018 04:41:28 AM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tests/phpunit/tests/category/wpListCategories.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/tests/phpunit/tests/category/wpListCategories.php
r43620 r43711 88 88 } 89 89 90 public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() { 91 $cats = self::factory()->category->create_many( 2 ); 92 93 $found = wp_list_categories( array( 94 'echo' => false, 95 'show_option_all' => 'All', 96 'hide_empty' => false, 97 'taxonomy' => 'category', 98 ) ); 99 100 $this->assertContains( "<li class='cat-item-all'><a href='" . home_url( '/' ) . "'>All</a></li>", $found ); 101 } 102 103 public function test_show_option_all_link_should_respect_page_for_posts() { 104 $cats = self::factory()->category->create_many( 2 ); 105 $p = self::factory()->post->create( array( 'post_type' => 'page' ) ); 106 107 update_option( 'show_on_front', 'page' ); 108 update_option( 'page_for_posts', $p ); 109 110 $found = wp_list_categories( array( 111 'echo' => false, 112 'show_option_all' => 'All', 113 'hide_empty' => false, 114 'taxonomy' => 'category', 115 ) ); 116 117 $this->assertContains( "<li class='cat-item-all'><a href='" . get_permalink( $p ) . "'>All</a></li>", $found ); 118 } 119 120 /** 121 * @ticket 21881 122 */ 123 public function test_show_option_all_link_should_link_to_post_type_archive_when_taxonomy_does_not_apply_to_posts() { 124 register_post_type( 'wptests_pt', array( 'has_archive' => true ) ); 125 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); 126 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); 127 128 $terms = self::factory()->term->create_many( 2, array( 129 'taxonomy' => 'wptests_tax', 130 ) ); 131 132 $found = wp_list_categories( array( 133 'echo' => false, 134 'show_option_all' => 'All', 135 'hide_empty' => false, 136 'taxonomy' => 'wptests_tax', 137 ) ); 138 139 $pt_archive = get_post_type_archive_link( 'wptests_pt' ); 140 141 $this->assertContains( "<li class='cat-item-all'><a href='" . $pt_archive . "'>All</a></li>", $found ); 142 } 143 144 /** 145 * @ticket 21881 146 */ 147 public function test_show_option_all_link_should_not_link_to_post_type_archive_if_has_archive_is_false() { 148 register_post_type( 'wptests_pt', array( 'has_archive' => false ) ); 149 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); 150 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); 151 152 $terms = self::factory()->term->create_many( 2, array( 153 'taxonomy' => 'wptests_tax', 154 ) ); 155 156 $found = wp_list_categories( array( 157 'echo' => false, 158 'show_option_all' => 'All', 159 'hide_empty' => false, 160 'taxonomy' => 'wptests_tax', 161 ) ); 162 163 $pt_archive = get_post_type_archive_link( 'wptests_pt2' ); 164 165 $this->assertContains( "<li class='cat-item-all'><a href='" . $pt_archive . "'>All</a></li>", $found ); 166 } 167 168 public function test_show_option_all_link_should_link_to_post_archive_if_available() { 169 register_post_type( 'wptests_pt', array( 'has_archive' => true ) ); 170 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); 171 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'post', 'wptests_pt2' ) ); 172 173 $terms = self::factory()->term->create_many( 2, array( 174 'taxonomy' => 'wptests_tax', 175 ) ); 176 177 $found = wp_list_categories( array( 178 'echo' => false, 179 'show_option_all' => 'All', 180 'hide_empty' => false, 181 'taxonomy' => 'wptests_tax', 182 ) ); 183 184 $url = home_url( '/' ); 185 186 $this->assertContains( "<li class='cat-item-all'><a href='" . $url . "'>All</a></li>", $found ); 187 } 188 189 public function test_show_option_all_link_should_link_to_post_archive_if_no_associated_post_types_have_archives() { 190 register_post_type( 'wptests_pt', array( 'has_archive' => false ) ); 191 register_post_type( 'wptests_pt2', array( 'has_archive' => false ) ); 192 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); 193 194 $terms = self::factory()->term->create_many( 2, array( 195 'taxonomy' => 'wptests_tax', 196 ) ); 197 198 $found = wp_list_categories( array( 199 'echo' => false, 200 'show_option_all' => 'All', 201 'hide_empty' => false, 202 'taxonomy' => 'wptests_tax', 203 ) ); 204 205 $url = home_url( '/' ); 206 207 $this->assertContains( "<li class='cat-item-all'><a href='" . $url . "'>All</a></li>", $found ); 208 } 209 90 210 public function list_cats_callback( $cat ) { 91 211 if ( 'Test Cat 1' === $cat ) { … … 94 214 95 215 return $cat; 96 }97 98 /**99 * @ticket 44872100 */101 public function test_should_create_element_when_cat_name_is_zero() {102 $c = self::factory()->category->create(103 array(104 'name' => '0',105 )106 );107 108 $found = wp_list_categories(109 array(110 'hide_empty' => false,111 'echo' => false,112 )113 );114 115 $this->assertContains( "cat-item-$c", $found );116 $this->assertContains( '0', $found );117 }118 119 public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() {120 $cats = self::factory()->category->create_many( 2 );121 122 $found = wp_list_categories( array(123 'echo' => false,124 'show_option_all' => 'All',125 'hide_empty' => false,126 'taxonomy' => 'category',127 ) );128 129 $this->assertContains( "<li class='cat-item-all'><a href='" . home_url( '/' ) . "'>All</a></li>", $found );130 }131 132 public function test_show_option_all_link_should_respect_page_for_posts() {133 $cats = self::factory()->category->create_many( 2 );134 $p = self::factory()->post->create( array( 'post_type' => 'page' ) );135 136 update_option( 'show_on_front', 'page' );137 update_option( 'page_for_posts', $p );138 139 $found = wp_list_categories( array(140 'echo' => false,141 'show_option_all' => 'All',142 'hide_empty' => false,143 'taxonomy' => 'category',144 ) );145 146 $this->assertContains( "<li class='cat-item-all'><a href='" . get_permalink( $p ) . "'>All</a></li>", $found );147 }148 149 /**150 * @ticket 21881151 */152 public function test_show_option_all_link_should_link_to_post_type_archive_when_taxonomy_does_not_apply_to_posts() {153 register_post_type( 'wptests_pt', array( 'has_archive' => true ) );154 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );155 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );156 157 $terms = self::factory()->term->create_many( 2, array(158 'taxonomy' => 'wptests_tax',159 ) );160 161 $found = wp_list_categories( array(162 'echo' => false,163 'show_option_all' => 'All',164 'hide_empty' => false,165 'taxonomy' => 'wptests_tax',166 ) );167 168 $pt_archive = get_post_type_archive_link( 'wptests_pt' );169 170 $this->assertContains( "<li class='cat-item-all'><a href='" . $pt_archive . "'>All</a></li>", $found );171 }172 173 /**174 * @ticket 21881175 */176 public function test_show_option_all_link_should_not_link_to_post_type_archive_if_has_archive_is_false() {177 register_post_type( 'wptests_pt', array( 'has_archive' => false ) );178 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );179 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );180 181 $terms = self::factory()->term->create_many( 2, array(182 'taxonomy' => 'wptests_tax',183 ) );184 185 $found = wp_list_categories( array(186 'echo' => false,187 'show_option_all' => 'All',188 'hide_empty' => false,189 'taxonomy' => 'wptests_tax',190 ) );191 192 $pt_archive = get_post_type_archive_link( 'wptests_pt2' );193 194 $this->assertContains( "<li class='cat-item-all'><a href='" . $pt_archive . "'>All</a></li>", $found );195 }196 197 public function test_show_option_all_link_should_link_to_post_archive_if_available() {198 register_post_type( 'wptests_pt', array( 'has_archive' => true ) );199 register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );200 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'post', 'wptests_pt2' ) );201 202 $terms = self::factory()->term->create_many( 2, array(203 'taxonomy' => 'wptests_tax',204 ) );205 206 $found = wp_list_categories( array(207 'echo' => false,208 'show_option_all' => 'All',209 'hide_empty' => false,210 'taxonomy' => 'wptests_tax',211 ) );212 213 $url = home_url( '/' );214 215 $this->assertContains( "<li class='cat-item-all'><a href='" . $url . "'>All</a></li>", $found );216 }217 218 public function test_show_option_all_link_should_link_to_post_archive_if_no_associated_post_types_have_archives() {219 register_post_type( 'wptests_pt', array( 'has_archive' => false ) );220 register_post_type( 'wptests_pt2', array( 'has_archive' => false ) );221 register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );222 223 $terms = self::factory()->term->create_many( 2, array(224 'taxonomy' => 'wptests_tax',225 ) );226 227 $found = wp_list_categories( array(228 'echo' => false,229 'show_option_all' => 'All',230 'hide_empty' => false,231 'taxonomy' => 'wptests_tax',232 ) );233 234 $url = home_url( '/' );235 236 $this->assertContains( "<li class='cat-item-all'><a href='" . $url . "'>All</a></li>", $found );237 216 } 238 217
Note: See TracChangeset
for help on using the changeset viewer.