-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change edit links for templates and template parts (#36294)
* Change edit links for templates and template parts * Unify the filter * Minor adjustments * Add a unit test. Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com> Co-authored-by: Anton Vlasenko <vlasenko.anton@gmail.com>
- Loading branch information
1 parent
e5c5b82
commit 57ebf86
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* This class tests block template loader functions | ||
* | ||
* @package Gutenberg | ||
*/ | ||
|
||
class WP_Template_Loader_Test extends WP_UnitTestCase { | ||
|
||
public function test_gutenberg_get_edit_template_link_returns_admin_url_link_for_template_posts() { | ||
$stylesheet = get_stylesheet(); | ||
$args = array( | ||
'post_type' => 'wp_template', | ||
'post_name' => 'my_template', | ||
'post_title' => 'My Template', | ||
'post_content' => 'Content', | ||
'post_excerpt' => 'Description of my template.', | ||
'tax_input' => array( | ||
'wp_theme' => array( | ||
$stylesheet, | ||
), | ||
), | ||
); | ||
$post = self::factory()->post->create_and_get( $args ); | ||
|
||
wp_set_post_terms( $post->ID, get_stylesheet(), 'wp_theme' ); | ||
$default_url = 'https://some.link'; | ||
$url = gutenberg_get_edit_template_link( $default_url, $post->ID ); | ||
$this->assertIsString( $url ); | ||
$this->assertNotSame( $default_url, $url ); | ||
$this->assertStringContainsString( 'themes.php', $url ); | ||
$this->assertStringContainsString( 'postId', $url ); | ||
$this->assertStringContainsString( $stylesheet, $url ); | ||
wp_delete_post( $post->ID ); | ||
} | ||
|
||
public function test_gutenberg_get_edit_template_link_returns_default_link_for_non_template_posts() { | ||
$post = self::factory()->post->create_and_get(); | ||
$default_url = 'https://some.link'; | ||
$url = gutenberg_get_edit_template_link( $default_url, $post->ID ); | ||
$this->assertSame( $default_url, $url ); | ||
wp_delete_post( $post->ID ); | ||
} | ||
} |