From a5088335ad1276f111697f2ac709c9c615e6ad69 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Wed, 12 Jun 2024 13:45:14 +0200 Subject: [PATCH] Bugfix --- includes/Component/Icon/IconLabel.php | 8 ++------ includes/MslsAdminIcon.php | 2 +- tests/phpunit/MslsUnitTestCase.php | 1 + tests/phpunit/TestMslsAdminIcon.php | 2 +- tests/phpunit/TestMslsPostTagClassic.php | 11 +++-------- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/includes/Component/Icon/IconLabel.php b/includes/Component/Icon/IconLabel.php index 5fb56bf65..49151fcae 100644 --- a/includes/Component/Icon/IconLabel.php +++ b/includes/Component/Icon/IconLabel.php @@ -7,6 +7,7 @@ /** * Class IconLabel + * * @package lloc\Msls\Component */ class IconLabel extends Icon { @@ -24,11 +25,6 @@ protected function get_include(): string { * @return string */ public function get( string $language ): string { - // if ( isset( $this->map[ $language ] ) ) { - // return $this->map[ $language ]; - // } - return '' . implode( '', explode( '_', $language ) ) . ''; } - -} \ No newline at end of file +} diff --git a/includes/MslsAdminIcon.php b/includes/MslsAdminIcon.php index cae79669a..7785dcdc2 100644 --- a/includes/MslsAdminIcon.php +++ b/includes/MslsAdminIcon.php @@ -243,7 +243,7 @@ public function get_icon(): string { $icon = sprintf( '%s', esc_attr( $this->language ), - esc_html( $text ) + wp_kses( $text, array( 'span' => array() ) ) ); break; default: diff --git a/tests/phpunit/MslsUnitTestCase.php b/tests/phpunit/MslsUnitTestCase.php index 030ba7cae..2fbb62cc7 100644 --- a/tests/phpunit/MslsUnitTestCase.php +++ b/tests/phpunit/MslsUnitTestCase.php @@ -25,6 +25,7 @@ protected function setUp(): void { Functions\when( 'esc_attr' )->returnArg(); Functions\when( 'esc_url' )->returnArg(); Functions\when( '__' )->returnArg(); + Functions\when( 'wp_kses' )->returnArg(); } diff --git a/tests/phpunit/TestMslsAdminIcon.php b/tests/phpunit/TestMslsAdminIcon.php index 09c75fec8..3f5a0c504 100644 --- a/tests/phpunit/TestMslsAdminIcon.php +++ b/tests/phpunit/TestMslsAdminIcon.php @@ -190,7 +190,7 @@ public function icon_type_provider(): array { * @dataProvider icon_type_provider */ public function test_get_icon_flag( ?string $icon_type, ?string $language, string $expected ): void { - Functions\expect( 'plugin_dir_path' )->atLeast( 1 )->andReturn( dirname( __DIR__, 2 ) . '/' ); + Functions\expect( 'plugin_dir_path' )->andReturn( dirname( __DIR__, 2 ) . '/' ); $obj = new MslsAdminIcon( 'post' ); $obj->set_icon_type( $icon_type ); diff --git a/tests/phpunit/TestMslsPostTagClassic.php b/tests/phpunit/TestMslsPostTagClassic.php index f83eb7f01..38499c54d 100644 --- a/tests/phpunit/TestMslsPostTagClassic.php +++ b/tests/phpunit/TestMslsPostTagClassic.php @@ -20,11 +20,7 @@ protected function setUp(): void { foreach ( array( 'de_DE', 'en_US' ) as $locale ) { $blog = \Mockery::mock( MslsBlog::class ); - $blog->shouldReceive( - array( - 'get_language' => $locale, - ) - ); + $blog->shouldReceive( 'get_language' )->andReturn( $locale ); $blogs[] = $blog; } @@ -54,10 +50,9 @@ public function test_edit_input(): void { Functions\expect( 'get_queried_object_id' )->andReturn( 42 ); Functions\expect( 'get_current_blog_id' )->andReturn( 23 ); Functions\expect( 'get_admin_url' )->andReturn( '/wp-admin/edit-tags.php' ); - Functions\expect( 'switch_to_blog' )->atLeast(); - Functions\expect( 'restore_current_blog' )->atLeast(); + Functions\expect( 'switch_to_blog' )->twice(); + Functions\expect( 'restore_current_blog' )->twice(); Functions\expect( 'get_terms' )->andReturn( array() ); - Functions\expect( 'plugin_dir_path' )->atLeast( 1 )->andReturn( dirname( __DIR__, 1 ) . '/' ); Functions\expect( 'is_woocommerce' )->once()->andReturn( false ); $output = '