Skip to content

Commit

Permalink
Merge pull request #336 from lloc/refactoring-version-2-8
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
lloc authored Jun 12, 2024
2 parents c22cb9c + a508833 commit d17a292
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
8 changes: 2 additions & 6 deletions includes/Component/Icon/IconLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Class IconLabel
*
* @package lloc\Msls\Component
*/
class IconLabel extends Icon {
Expand All @@ -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 '<span>' . implode( '</span><span>', explode( '_', $language ) ) . '</span>';
}

}
}
2 changes: 1 addition & 1 deletion includes/MslsAdminIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function get_icon(): string {
$icon = sprintf(
'<span class="language-badge %s">%s</span>',
esc_attr( $this->language ),
esc_html( $text )
wp_kses( $text, array( 'span' => array() ) )
);
break;
default:
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/MslsUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/TestMslsAdminIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
11 changes: 3 additions & 8 deletions tests/phpunit/TestMslsPostTagClassic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 = '<tr>
Expand Down

0 comments on commit d17a292

Please sign in to comment.