Changeset 57020 for branches/6.4/tests/phpunit/tests/block-template.php
- Timestamp:
- 10/27/2023 06:34:11 PM (12 months ago)
- Location:
- branches/6.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.4
-
branches/6.4/tests/phpunit/tests/block-template.php
r57010 r57020 20 20 21 21 public function tear_down() { 22 global $_wp_current_template_ content;23 unset( $_wp_current_template_ content );22 global $_wp_current_template_id, $_wp_current_template_content; 23 unset( $_wp_current_template_id, $_wp_current_template_content ); 24 24 25 25 parent::tear_down(); … … 194 194 * 195 195 * @ticket 58154 196 * @ticket 59736 196 197 * @covers ::get_the_block_template_html 197 198 */ 198 199 public function test_get_the_block_template_html_enforces_singular_query_loop() { 199 global $_wp_current_template_ content, $wp_query, $wp_the_query;200 global $_wp_current_template_id, $_wp_current_template_content, $wp_query, $wp_the_query; 200 201 201 202 // Register test block to log `in_the_loop()` results. … … 208 209 $wp_the_query = $wp_query; 209 210 211 // Force a template ID that is for the current stylesheet. 212 $_wp_current_template_id = get_stylesheet() . '//single'; 210 213 // Use block template that just renders post title and the above test block. 211 214 $_wp_current_template_content = '<!-- wp:post-title /--><!-- wp:test/in-the-loop-logger /-->'; … … 228 231 */ 229 232 public function test_get_the_block_template_html_does_not_generally_enforce_loop() { 230 global $_wp_current_template_ content, $wp_query, $wp_the_query;233 global $_wp_current_template_id, $_wp_current_template_content, $wp_query, $wp_the_query; 231 234 232 235 // Register test block to log `in_the_loop()` results. … … 248 251 ); 249 252 $wp_the_query = $wp_query; 253 254 // Force a template ID that is for the current stylesheet. 255 $_wp_current_template_id = get_stylesheet() . '//home'; 250 256 251 257 /* … … 278 284 279 285 /** 286 * Tests that `get_the_block_template_html()` does not start the main query loop when on a template that is not from the current theme. 287 * 288 * @ticket 58154 289 * @ticket 59736 290 * @covers ::get_the_block_template_html 291 */ 292 public function test_get_the_block_template_html_skips_singular_query_loop_when_non_theme_template() { 293 global $_wp_current_template_id, $_wp_current_template_content, $wp_query, $wp_the_query; 294 295 // Register test block to log `in_the_loop()` results. 296 $in_the_loop_logs = array(); 297 $this->register_in_the_loop_logger_block( $in_the_loop_logs ); 298 299 // Set main query to single post. 300 $post_id = self::factory()->post->create( array( 'post_title' => 'A single post' ) ); 301 $wp_query = new WP_Query( array( 'p' => $post_id ) ); 302 $wp_the_query = $wp_query; 303 304 // Force a template ID that is not for the current stylesheet. 305 $_wp_current_template_id = 'some-plugin-slug//single'; 306 // Use block template that just renders post title and the above test block. 307 $_wp_current_template_content = '<!-- wp:post-title /--><!-- wp:test/in-the-loop-logger /-->'; 308 309 $output = get_the_block_template_html(); 310 $this->unregister_in_the_loop_logger_block(); 311 $this->assertSame( array( false ), $in_the_loop_logs, 'Main query loop was triggered despite a custom block template outside the current theme being used' ); 312 } 313 314 /** 280 315 * @ticket 58319 281 316 *
Note: See TracChangeset
for help on using the changeset viewer.