Skip to content

Commit d0e8a44

Browse files
committed
Tests fixed
1 parent c2283a2 commit d0e8a44

9 files changed

+11
-26
lines changed

includes/MslsAdminIcon.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class MslsAdminIcon {
6969
* @param string $type
7070
*/
7171
public function __construct( ?string $type = null ) {
72-
$this->type = esc_attr( $type );
72+
$this->type = $type;
73+
7374
$this->set_path();
7475
}
7576

tests/phpunit/MslsUnitTestCase.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,21 @@ protected function setUp(): void {
2121

2222
\Mockery::namedMock( 'WooCommerce', \stdClass::class );
2323

24+
Functions\when( '__' )->returnArg();
25+
Functions\when( 'esc_attr' )->returnArg();
2426
Functions\when( 'esc_html' )->returnArg();
2527
Functions\when( 'esc_html__' )->returnArg();
26-
Functions\when( 'esc_attr' )->returnArg();
2728
Functions\when( 'esc_url' )->returnArg();
28-
Functions\when( '__' )->returnArg();
2929
Functions\when( 'wp_kses' )->returnArg();
3030
Functions\when( 'wp_kses_post' )->returnArg();
3131
Functions\when( 'sanitize_text_field' )->returnArg();
3232
}
3333

34-
3534
protected function tearDown(): void {
3635
restore_error_handler();
3736

38-
Monkey\tearDown();
3937
\Mockery::close();
38+
Monkey\tearDown();
4039

4140
parent::tearDown();
4241
}

tests/phpunit/TestMslsLink.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ public function test_get_types(): void {
2727
}
2828

2929
public function test_get_description(): void {
30-
Functions\when( '__' )->returnArg();
31-
3230
$this->assertEquals( 'Flag and description', MslsLink::get_description() );
3331
}
3432

3533
public function test_get_types_description(): void {
36-
Functions\when( '__' )->returnArg();
37-
3834
$this->assertCount( 4, MslsLink::get_types_description() );
3935
}
4036

tests/phpunit/TestMslsLinkImageOnly.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
class TestMslsLinkImageOnly extends MslsUnitTestCase {
99

1010
public function test_get_description_method(): void {
11-
Functions\when( '__' )->returnArg();
12-
1311
$this->assertIsSTring( MslsLinkImageOnly::get_description() );
1412
}
1513
}

tests/phpunit/TestMslsLinkTextImage.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
class TestMslsLinkTextImage extends MslsUnitTestCase {
99

1010
public function test_get_description_method(): void {
11-
Functions\when( '__' )->returnArg();
12-
1311
$this->assertIsSTring( MslsLinkTextImage::get_description() );
1412
}
1513
}

tests/phpunit/TestMslsLinkTextOnly.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
class TestMslsLinkTextOnly extends MslsUnitTestCase {
99

1010
public function test_get_description_method(): void {
11-
Functions\when( '__' )->returnArg();
12-
1311
$this->assertIsSTring( MslsLinkTextOnly::get_description() );
1412
}
1513
}

tests/phpunit/TestMslsMetaBox.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@
1717
class TestMslsMetaBox extends MslsUnitTestCase {
1818

1919
protected function setUp(): void {
20-
Functions\when( 'plugin_dir_path' )->justReturn( dirname( __DIR__, 2 ) . '/' );
20+
parent::setUp();
2121

22-
Functions\when( 'esc_attr' )->returnArg();
23-
Functions\when( 'esc_html' )->returnArg();
24-
Functions\when( 'esc_url' )->returnArg();
25-
Functions\when( 'wp_kses' )->returnArg();
26-
Functions\when( '__' )->returnArg();
22+
Functions\when( 'plugin_dir_path' )->justReturn( dirname( __DIR__, 2 ) . '/' );
2723

2824
$blog = \Mockery::mock( MslsBlog::class );
2925
$blog->shouldReceive( 'get_language' )->andReturn( 'de_DE' );
@@ -69,7 +65,6 @@ public function test_suggest(): void {
6965
Functions\expect( 'filter_input' )->once()->with( INPUT_POST, MslsFields::FIELD_S, FILTER_SANITIZE_FULL_SPECIAL_CHARS )->andReturn( 17 );
7066
Functions\expect( 'get_post_stati' )->once()->andReturn( array( 'pending', 'draft', 'future' ) );
7167
Functions\expect( 'get_the_title' )->once()->andReturn( 'Test' );
72-
Functions\expect( 'sanitize_text_field' )->times( 2 )->andReturnFirstArg();
7368
Functions\expect( 'get_posts' )->once()->andReturn( array( $post ) );
7469
Functions\expect( 'switch_to_blog' )->once();
7570
Functions\expect( 'restore_current_blog' )->once();

tests/phpunit/TestMslsSqlCacher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
class TestMslsSqlCacher extends MslsUnitTestCase {
99

1010
protected function setUp(): void {
11+
parent::setUp();
12+
1113
$wpdb = \Mockery::mock( \WPDB::class );
1214

1315
$wpdb->shouldReceive( 'prepare' )->andReturn( '' );
@@ -19,8 +21,6 @@ protected function setUp(): void {
1921
public function test_create(): void {
2022
global $wpdb;
2123

22-
Functions\expect( 'esc_attr' )->atLeast()->once()->andReturnFirstArg();
23-
2424
$wpdb = \Mockery::mock( \WPDB::class );
2525

2626
$this->assertInstanceOf( MslsSqlCacher::class, MslsSqlCacher::create( 'MslsSqlCacherTest', '' ) );

tests/phpunit/WP_Widget.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct( $id_base, $name, $widget_options = array(), $contro
3030
* @return string ID attribute for `$field_name`.
3131
*/
3232
public function get_field_id( string $field_name ) {
33-
return sprintf( 'field-id-%s', esc_attr( $field_name ) );
33+
return sprintf( 'field-id-%s', $field_name );
3434
}
3535

3636
/**
@@ -39,6 +39,6 @@ public function get_field_id( string $field_name ) {
3939
* @return string Name attribute for `$field_name`.
4040
*/
4141
public function get_field_name( $field_name ) {
42-
return sprintf( 'field-name-%s', esc_attr( $field_name ) );
42+
return sprintf( 'field-name-%s', $field_name );
4343
}
4444
}

0 commit comments

Comments
 (0)