Changeset 42343 for trunk/tests/phpunit/tests/post/getPageByPath.php
- Timestamp:
- 11/30/2017 11:09:33 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getPageByPath.php
r37481 r42343 11 11 global $wpdb; 12 12 13 $attachment = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) ); 14 $page = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) ); 15 $other_att = self::factory()->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) ); 13 $attachment = self::factory()->post->create_and_get( 14 array( 15 'post_title' => 'some-page', 16 'post_type' => 'attachment', 17 ) 18 ); 19 $page = self::factory()->post->create_and_get( 20 array( 21 'post_title' => 'some-page', 22 'post_type' => 'page', 23 ) 24 ); 25 $other_att = self::factory()->post->create_and_get( 26 array( 27 'post_title' => 'some-other-page', 28 'post_type' => 'attachment', 29 ) 30 ); 16 31 17 32 $wpdb->update( $wpdb->posts, array( 'post_name' => 'some-page' ), array( 'ID' => $page->ID ) ); … … 31 46 32 47 public function test_should_match_top_level_page() { 33 $page = self::factory()->post->create( array( 34 'post_type' => 'page', 35 'post_name' => 'foo', 36 ) ); 48 $page = self::factory()->post->create( 49 array( 50 'post_type' => 'page', 51 'post_name' => 'foo', 52 ) 53 ); 37 54 38 55 $found = get_page_by_path( 'foo' ); … … 44 61 register_post_type( 'wptests_pt' ); 45 62 46 $page = self::factory()->post->create( array( 47 'post_type' => 'wptests_pt', 48 'post_name' => 'foo', 49 ) ); 63 $page = self::factory()->post->create( 64 array( 65 'post_type' => 'wptests_pt', 66 'post_name' => 'foo', 67 ) 68 ); 50 69 51 70 $found = get_page_by_path( 'foo' ); … … 57 76 58 77 public function test_should_match_nested_page() { 59 $p1 = self::factory()->post->create( array( 60 'post_type' => 'page', 61 'post_name' => 'foo', 62 ) ); 63 64 $p2 = self::factory()->post->create( array( 65 'post_type' => 'page', 66 'post_name' => 'bar', 67 'post_parent' => $p1, 68 ) ); 69 70 $p3 = self::factory()->post->create( array( 71 'post_type' => 'page', 72 'post_name' => 'baz', 73 'post_parent' => $p2, 74 ) ); 78 $p1 = self::factory()->post->create( 79 array( 80 'post_type' => 'page', 81 'post_name' => 'foo', 82 ) 83 ); 84 85 $p2 = self::factory()->post->create( 86 array( 87 'post_type' => 'page', 88 'post_name' => 'bar', 89 'post_parent' => $p1, 90 ) 91 ); 92 93 $p3 = self::factory()->post->create( 94 array( 95 'post_type' => 'page', 96 'post_name' => 'baz', 97 'post_parent' => $p2, 98 ) 99 ); 75 100 76 101 $found = get_page_by_path( 'foo/bar/baz' ); … … 80 105 81 106 public function test_should_not_make_partial_match() { 82 $p1 = self::factory()->post->create( array( 83 'post_type' => 'page', 84 'post_name' => 'foo', 85 ) ); 86 87 $p2 = self::factory()->post->create( array( 88 'post_type' => 'page', 89 'post_name' => 'bar', 90 'post_parent' => $p1, 91 ) ); 92 93 $p3 = self::factory()->post->create( array( 94 'post_type' => 'page', 95 'post_name' => 'baz', 96 'post_parent' => $p2, 97 ) ); 107 $p1 = self::factory()->post->create( 108 array( 109 'post_type' => 'page', 110 'post_name' => 'foo', 111 ) 112 ); 113 114 $p2 = self::factory()->post->create( 115 array( 116 'post_type' => 'page', 117 'post_name' => 'bar', 118 'post_parent' => $p1, 119 ) 120 ); 121 122 $p3 = self::factory()->post->create( 123 array( 124 'post_type' => 'page', 125 'post_name' => 'baz', 126 'post_parent' => $p2, 127 ) 128 ); 98 129 99 130 $found = get_page_by_path( 'bar/baz' ); … … 103 134 104 135 public function test_should_not_match_parts_out_of_order() { 105 $p1 = self::factory()->post->create( array( 106 'post_type' => 'page', 107 'post_name' => 'foo', 108 ) ); 109 110 $p2 = self::factory()->post->create( array( 111 'post_type' => 'page', 112 'post_name' => 'bar', 113 'post_parent' => $p1, 114 ) ); 115 116 $p3 = self::factory()->post->create( array( 117 'post_type' => 'page', 118 'post_name' => 'baz', 119 'post_parent' => $p2, 120 ) ); 136 $p1 = self::factory()->post->create( 137 array( 138 'post_type' => 'page', 139 'post_name' => 'foo', 140 ) 141 ); 142 143 $p2 = self::factory()->post->create( 144 array( 145 'post_type' => 'page', 146 'post_name' => 'bar', 147 'post_parent' => $p1, 148 ) 149 ); 150 151 $p3 = self::factory()->post->create( 152 array( 153 'post_type' => 'page', 154 'post_name' => 'baz', 155 'post_parent' => $p2, 156 ) 157 ); 121 158 122 159 $found = get_page_by_path( 'bar/foo/baz' ); … … 131 168 global $wpdb; 132 169 133 $page = self::factory()->post->create( array( 134 'post_type' => 'page', 135 'post_name' => 'foo', 136 ) ); 170 $page = self::factory()->post->create( 171 array( 172 'post_type' => 'page', 173 'post_name' => 'foo', 174 ) 175 ); 137 176 138 177 // Prime cache. … … 194 233 register_post_type( 'wptests_pt' ); 195 234 196 $p1 = self::factory()->post->create( array( 197 'post_type' => 'page', 198 'post_name' => 'foo', 199 ) ); 200 201 $p2 = self::factory()->post->create( array( 202 'post_type' => 'wptests_pt', 203 'post_name' => 'foo', 204 ) ); 235 $p1 = self::factory()->post->create( 236 array( 237 'post_type' => 'page', 238 'post_name' => 'foo', 239 ) 240 ); 241 242 $p2 = self::factory()->post->create( 243 array( 244 'post_type' => 'wptests_pt', 245 'post_name' => 'foo', 246 ) 247 ); 205 248 206 249 // Prime cache for the page. … … 222 265 global $wpdb; 223 266 224 $page = self::factory()->post->create( array( 225 'post_type' => 'page', 226 'post_name' => 'foo', 227 ) ); 228 229 // Prime cache. 230 $found = get_page_by_path( 'foo' ); 231 $this->assertSame( $page, $found->ID ); 232 233 wp_update_post( array( 234 'ID' => $page, 235 'post_name' => 'bar', 236 ) ); 267 $page = self::factory()->post->create( 268 array( 269 'post_type' => 'page', 270 'post_name' => 'foo', 271 ) 272 ); 273 274 // Prime cache. 275 $found = get_page_by_path( 'foo' ); 276 $this->assertSame( $page, $found->ID ); 277 278 wp_update_post( 279 array( 280 'ID' => $page, 281 'post_name' => 'bar', 282 ) 283 ); 237 284 238 285 $num_queries = $wpdb->num_queries; … … 248 295 */ 249 296 public function test_output_param_should_be_obeyed_for_cached_value() { 250 $page = self::factory()->post->create( array( 251 'post_type' => 'page', 252 'post_name' => 'foo', 253 ) ); 297 $page = self::factory()->post->create( 298 array( 299 'post_type' => 'page', 300 'post_name' => 'foo', 301 ) 302 ); 254 303 255 304 // Prime cache.
Note: See TracChangeset
for help on using the changeset viewer.