From 864c10a6d17ddcbababc54d3f594edf4e4137e01 Mon Sep 17 00:00:00 2001 From: Mike Auteri Date: Fri, 4 Oct 2024 12:33:14 -0400 Subject: [PATCH] Small adjustments. --- .../core/classes/class-test-topic.php | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test/unit/php/includes/core/classes/class-test-topic.php b/test/unit/php/includes/core/classes/class-test-topic.php index 5aa69a1d0..4a3c315dd 100644 --- a/test/unit/php/includes/core/classes/class-test-topic.php +++ b/test/unit/php/includes/core/classes/class-test-topic.php @@ -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; @@ -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. @@ -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 ); } }