From 8cb6599d54e5f2533e1d4131bc69d4d23358c2fa Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Sun, 15 Sep 2024 12:08:26 +0200 Subject: [PATCH] Tests added --- tests/phpunit/MslsUnitTestCase.php | 1 + tests/phpunit/TestMslsPostTag.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/tests/phpunit/MslsUnitTestCase.php b/tests/phpunit/MslsUnitTestCase.php index 2fbb62cc..1b711bc4 100644 --- a/tests/phpunit/MslsUnitTestCase.php +++ b/tests/phpunit/MslsUnitTestCase.php @@ -26,6 +26,7 @@ protected function setUp(): void { Functions\when( 'esc_url' )->returnArg(); Functions\when( '__' )->returnArg(); Functions\when( 'wp_kses' )->returnArg(); + Functions\when( 'sanitize_text_field' )->returnArg(); } diff --git a/tests/phpunit/TestMslsPostTag.php b/tests/phpunit/TestMslsPostTag.php index 3708cb82..597ba8ef 100644 --- a/tests/phpunit/TestMslsPostTag.php +++ b/tests/phpunit/TestMslsPostTag.php @@ -61,7 +61,16 @@ public function test_init(): void { * Verify the static suggest-method */ public function test_suggest(): void { + $term = \Mockery::mock( \WP_Term::class ); + $term->term_id = 42; + $term->name = 'test'; + Functions\expect( 'wp_die' ); + Functions\expect( 'filter_has_var' )->atLeast()->once()->andReturnTrue(); + Functions\expect( 'filter_input' )->atLeast()->once()->andReturn( 'suggest_terms' ); + Functions\expect( 'switch_to_blog' )->atLeast()->once(); + Functions\expect( 'restore_current_blog' )->atLeast()->once(); + Functions\expect( 'get_terms' )->atLeast()->once()->andReturn( array( $term ) ); self::expectOutputString( '' );