Skip to content

Commit

Permalink
Tests for pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
lloc committed Nov 30, 2023
1 parent 5f7fb32 commit d406679
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
7 changes: 6 additions & 1 deletion includes/MslsAdminIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @package Msls
*/
class MslsAdminIcon {

/**
* IconType
* @var string
Expand Down Expand Up @@ -69,6 +70,10 @@ class MslsAdminIcon {
*/
protected $id;

const TYPE_FLAG = 'flag';

const TYPE_LABEL = 'label';

/**
* Constructor
*
Expand Down Expand Up @@ -228,7 +233,7 @@ public function get_a(): string {
*/
public function get_icon(): string {
if ( 'flag' === $this->iconType ) {
return ! is_string( $this->language ) ? '' : sprintf( '<span class="flag-icon %s">%s</span>',
return sprintf( '<span class="flag-icon %s">%s</span>',
( new IconSvg() )->get( $this->language ),
$this->language
);
Expand Down
2 changes: 1 addition & 1 deletion includes/MslsCustomColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function init() {
public function th( $columns ) {
$blogs = $this->collection->get();
if ( $blogs ) {
$html;
$html = '';
foreach ( $blogs as $blog ) {
$language = $blog->get_language();

Expand Down
9 changes: 2 additions & 7 deletions includes/MslsMetaBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,8 @@ public function render_select() {
switch_to_blog( $blog->userblog_id );

$language = $blog->get_language();
$icon = MslsAdminIcon::create()->set_language( $language );

if ( $this->options->admin_display === 'label' ) {
$icon->set_icon_type( 'label' );
} else {
$icon->set_icon_type( 'flag' );
}
$iconType = MslsAdminIcon::TYPE_FLAG === $this->options->admin_display ? MslsAdminIcon::TYPE_FLAG : MslsAdminIcon::TYPE_LABEL;
$icon = MslsAdminIcon::create()->set_language( $language )->set_icon_type( $iconType );

if ( $mydata->has_value( $language ) ) {
$icon->set_href( $mydata->$language );
Expand Down
1 change: 1 addition & 0 deletions includes/MslsOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @package Msls
* @property bool $activate_autocomplete
* @property int $display
* @property string $admin_display
* @property int $reference_user
* @property int $content_priority
* @property string $admin_language
Expand Down
2 changes: 1 addition & 1 deletion tests/test-mslsadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function test_main_section() {

Functions\when( 'add_settings_field' )->returnArg();

$this->assertEquals( 11, $obj->main_section() );
$this->assertEquals( 12, $obj->main_section() );
}

function test_advanced_section() {
Expand Down
1 change: 1 addition & 0 deletions tests/test-mslsblog.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class WP_Test_MslsBlog extends Msls_UnitTestCase {
*/
function test___get_method() {
Functions\expect( 'get_blog_option' )->once()->andReturn( 'it_IT' );

$blog = new \stdClass();
$blog->userblog_id = 1;
$blog->blogname = 'Test';
Expand Down
2 changes: 1 addition & 1 deletion tests/test-mslscustomcolumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function test_th() {

$options = \Mockery::mock( MslsOptions::class );
$obj = new MslsCustomColumn( $options, $this->getBlogsCollection() );
$expected = [ 'mslscol' => '<span class="flag-icon flag-icon-de">de_DE</span>&nbsp;<span class="flag-icon flag-icon-us">en_US</span>' ];
$expected = [ 'mslscol' => '<span class="msls-icon-wrapper "><span class="flag-icon flag-icon-de">de_DE</span></span><span class="msls-icon-wrapper "><span class="flag-icon flag-icon-us">en_US</span></span>' ];

$this->assertEquals( $expected, $obj->th( [] ) );
}
Expand Down

0 comments on commit d406679

Please sign in to comment.