You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6c3ee0f
Browse filesBrowse the repository at this point in the historyBrowse files
Tests: Cover block template changes after cache population.
Verify `WP_Theme::get_post_templates()` includes newly created custom block templates and excludes deleted templates after its file-based cache has been populated.
Developed in: #14051
Props irozum, huzaifaalmesbah.
See #65819, #57886.
git-svn-id: https://develop.svn.wordpress.org/trunk@65104 602fd350-edb4-49c9-b593-d223f7449a82
// The cached file-based templates must not have locked in the set of block templates from the first call.
135
+
$this->assertArrayHasKey( 'late-added-custom-template', $post_templates['post'], 'A block template created after the cache was populated should still be returned.' );
// First call caches the file-based post templates and merges in the block template created above.
146
+
$post_templates = $theme->get_post_templates();
147
+
$this->assertArrayHasKey( 'removed-custom-template', $post_templates['post'], 'The block template should be present before it is deleted.' );
148
+
149
+
wp_delete_post( $custom_template->ID, true );
150
+
151
+
$post_templates = $theme->get_post_templates();
152
+
153
+
// The cached file-based templates must not have locked in the now-deleted block template.
154
+
$this->assertArrayNotHasKey( 'removed-custom-template', $post_templates['post'], 'A block template deleted after the cache was populated should no longer be returned.' );
155
+
}
156
+
157
+
/**
158
+
* Switches to the "block-theme" test theme and runs the setup hooks it relies on
159
+
* to gain `current_theme_supports( 'block-templates' )` support.
0 commit comments