Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add & updated unit tests for localized slugs #939

Merged
merged 10 commits into from
Oct 11, 2024

Conversation

carstingaxion
Copy link
Collaborator

@carstingaxion carstingaxion commented Oct 5, 2024

Description of the Change

This PR adds new tests for existing methods which prepare the localized post type & taxonomy slugs, before saving them into GatherPress' options.

It also and additionally fixes one left-over from the development of the methods. The default strings used for the slugs were new, additional strings to translate. This PR replaces the default slugs, with the already existing Post Type Singular Name and Taxonomy Singular Name labels.

Closes #

How to test the Change

Changelog Entry

Added - ... and updated unit tests for the preparation of localized post type and taxonomy slugs

Credits

Props @carstingaxion @mauteri

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

Copy link

what-the-diff bot commented Oct 5, 2024

PR Summary

  • Improved User Interface Consistency
    The labels for different types of posts and taxonomies on our platform have been updated to use consistent capitalization. This change will make our platform easier to use and navigate, as the format and presentation will remain constant across the system.

  • Enhanced Clarity in Taxonomy Labels
    Adjustments have been made in the taxonomy label keys for improved clarity. The terms 'Taxonomy General Name' and 'Taxonomy Singular Name' are now being used, making the information easier to understand.

  • Included Unit Tests for New Methods
    Additional unit tests have been added for the methods get_localized_post_type_slug and get_localized_taxonomy_slug. These tests will ensure that the newly introduced features function as expected and are capable of supporting various languages.

  • Implemented Enhanced Testing Logic
    The testing logic for functions related to post types and taxonomies has been bolstered through the use of mocked translations. This enhancement enables us to verify that these functions behave correctly in the context of different language interpretations.

@carstingaxion carstingaxion marked this pull request as draft October 5, 2024 12:48
@carstingaxion
Copy link
Collaborator Author

Another unit-test curiosity, that isn't clear to me @mauteri :

Why does this one test fail now?

From an untouched file.
I called $user_id = $this->factory->user->create(); three times, which might be the cause.

@carstingaxion carstingaxion marked this pull request as ready for review October 5, 2024 17:29
@mauteri mauteri changed the base branch from main to develop October 10, 2024 12:57
$slug = _x( 'venue', 'Post Type Slug', 'gatherpress' );
$slug = sanitize_title( $slug );
$slug = _x( 'Venue', 'Post Type Singular Name', 'gatherpress' );
$slug = sanitize_title( $slug, 'save' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting third argument as second argument. should be sanitize_title( $slug, '', 'save' );

Copy link

Preview changes with Playground

You can preview the recent changes for PR#939 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@mauteri mauteri merged commit 4f685de into GatherPress:develop Oct 11, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants