Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template save and format slugify: Use remove_accents() to convert all…
… accent characters to ASCII characters, before creating slug with sanitize_title_with_dashes() - Resolves #96 - See https://developer.wordpress.org/reference/functions/remove_accents/
- Loading branch information
1 parent
782a1c4
commit a7af4a1
Showing
3 changed files
with
47 additions
and
9 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
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,37 @@ | ||
<?php | ||
namespace Tests\Admin; | ||
use tangible\template_system; | ||
use tangible\format; | ||
|
||
class Template_Save_TestCase extends \WP_UnitTestCase { | ||
|
||
/** | ||
* Generate template slug from title | ||
* | ||
* @see /admin/template-post/save.php | ||
*/ | ||
function test_template_slug() { | ||
|
||
$plugin = tangible_template_system(); | ||
|
||
$title = 'Test - éùæøŸ'; | ||
|
||
$post_id = self::factory()->post->create_object([ | ||
'post_type' => 'post', | ||
'post_status' => 'publish', | ||
'post_title' => $title, | ||
// Important: wp_insert_post() throws error if these are not defined | ||
'post_content' => '', | ||
'post_excerpt' => '', | ||
]); | ||
|
||
$expected = 'test-euaeoy'; | ||
|
||
$this->assertEquals($expected, format\slugify($title)); | ||
|
||
$post = get_post($post_id); | ||
|
||
$this->assertEquals($expected, $post->post_name); | ||
|
||
} | ||
} |