Skip to content

Commit

Permalink
Small adjustments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauteri committed Oct 4, 2024
1 parent 8cdd523 commit 864c10a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions test/unit/php/includes/core/classes/class-test-topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

namespace GatherPress\Tests\Core;

use GatherPress\Core\Event;
use GatherPress\Core\Rsvp;
use GatherPress\Core\Topic;
use PMC\Unit_Test\Base;

Expand Down Expand Up @@ -76,6 +74,13 @@ public function test_get_localized_taxonomy_slug(): void {
'Failed to assert english taxonomy slug is "topic".'
);

$filter = static function ( string $translation, string $text, string $context ): string {
if ( 'topic' !== $text || 'Taxonomy Slug' !== $context ) {
return $translation;
}
return 'Ünit Tést';
};

/**
* Instead of loading additional languages into the unit test suite,
* we just filter the translated value, to mock different languages.
Expand All @@ -87,22 +92,14 @@ public function test_get_localized_taxonomy_slug(): void {
* @param string $context Context information for the translators.
* @return string Translated text.
*/
add_filter(
'gettext_with_context_gatherpress',
function ( string $translation, string $text, string $context ): string {
if ( 'topic' !== $text || 'Taxonomy Slug' !== $context ) {
return $translation;
}
return 'Ünit Tést';
},
10,
3
);
add_filter( 'gettext_with_context_gatherpress', $filter, 10, 3 );

$this->assertSame(
'unit-test',
$instance->get_localized_taxonomy_slug(),
'Failed to assert taxonomy slug is "unit-test".'
);

remove_filter( 'gettext_with_context_gatherpress', $filter );
}
}

0 comments on commit 864c10a

Please sign in to comment.