Skip to content

Commit d17a292

Browse files
authored
Merge pull request #336 from lloc/refactoring-version-2-8
Bugfix
2 parents c22cb9c + a508833 commit d17a292

File tree

5 files changed

+8
-16
lines changed

5 files changed

+8
-16
lines changed

includes/Component/Icon/IconLabel.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/**
99
* Class IconLabel
10+
*
1011
* @package lloc\Msls\Component
1112
*/
1213
class IconLabel extends Icon {
@@ -24,11 +25,6 @@ protected function get_include(): string {
2425
* @return string
2526
*/
2627
public function get( string $language ): string {
27-
// if ( isset( $this->map[ $language ] ) ) {
28-
// return $this->map[ $language ];
29-
// }
30-
3128
return '<span>' . implode( '</span><span>', explode( '_', $language ) ) . '</span>';
3229
}
33-
34-
}
30+
}

includes/MslsAdminIcon.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function get_icon(): string {
243243
$icon = sprintf(
244244
'<span class="language-badge %s">%s</span>',
245245
esc_attr( $this->language ),
246-
esc_html( $text )
246+
wp_kses( $text, array( 'span' => array() ) )
247247
);
248248
break;
249249
default:

tests/phpunit/MslsUnitTestCase.php

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ protected function setUp(): void {
2525
Functions\when( 'esc_attr' )->returnArg();
2626
Functions\when( 'esc_url' )->returnArg();
2727
Functions\when( '__' )->returnArg();
28+
Functions\when( 'wp_kses' )->returnArg();
2829
}
2930

3031

tests/phpunit/TestMslsAdminIcon.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function icon_type_provider(): array {
190190
* @dataProvider icon_type_provider
191191
*/
192192
public function test_get_icon_flag( ?string $icon_type, ?string $language, string $expected ): void {
193-
Functions\expect( 'plugin_dir_path' )->atLeast( 1 )->andReturn( dirname( __DIR__, 2 ) . '/' );
193+
Functions\expect( 'plugin_dir_path' )->andReturn( dirname( __DIR__, 2 ) . '/' );
194194

195195
$obj = new MslsAdminIcon( 'post' );
196196
$obj->set_icon_type( $icon_type );

tests/phpunit/TestMslsPostTagClassic.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ protected function setUp(): void {
2020

2121
foreach ( array( 'de_DE', 'en_US' ) as $locale ) {
2222
$blog = \Mockery::mock( MslsBlog::class );
23-
$blog->shouldReceive(
24-
array(
25-
'get_language' => $locale,
26-
)
27-
);
23+
$blog->shouldReceive( 'get_language' )->andReturn( $locale );
2824

2925
$blogs[] = $blog;
3026
}
@@ -54,10 +50,9 @@ public function test_edit_input(): void {
5450
Functions\expect( 'get_queried_object_id' )->andReturn( 42 );
5551
Functions\expect( 'get_current_blog_id' )->andReturn( 23 );
5652
Functions\expect( 'get_admin_url' )->andReturn( '/wp-admin/edit-tags.php' );
57-
Functions\expect( 'switch_to_blog' )->atLeast();
58-
Functions\expect( 'restore_current_blog' )->atLeast();
53+
Functions\expect( 'switch_to_blog' )->twice();
54+
Functions\expect( 'restore_current_blog' )->twice();
5955
Functions\expect( 'get_terms' )->andReturn( array() );
60-
Functions\expect( 'plugin_dir_path' )->atLeast( 1 )->andReturn( dirname( __DIR__, 1 ) . '/' );
6156
Functions\expect( 'is_woocommerce' )->once()->andReturn( false );
6257

6358
$output = '<tr>

0 commit comments

Comments
 (0)