From 0c4cc89447e32dadfb1e45ac3de1b2aafc0a962f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 27 Jan 2024 20:35:27 +0000 Subject: [PATCH] Tests: Expand `sanitize_text_field()` tests. This change ensures that the `sanitize_text_field` and `sanitize_textarea_field` filters are correctly invoked for the respective functions. Follow-up to [38944]. Props pbearne, audrasjb. Fixes #60357. git-svn-id: https://develop.svn.wordpress.org/trunk@57368 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/formatting/sanitizeTextField.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/phpunit/tests/formatting/sanitizeTextField.php b/tests/phpunit/tests/formatting/sanitizeTextField.php index d7a58486d1..82cef34a38 100644 --- a/tests/phpunit/tests/formatting/sanitizeTextField.php +++ b/tests/phpunit/tests/formatting/sanitizeTextField.php @@ -143,4 +143,26 @@ class Tests_Formatting_SanitizeTextField extends WP_UnitTestCase { ), ); } + + /** + * @ticket 60357 + */ + public function test_sanitize_text_field_filter() { + $filter = new MockAction(); + add_filter( 'sanitize_text_field', array( $filter, 'filter' ) ); + + $this->assertSame( 'example', sanitize_text_field( 'example' ) ); + $this->assertSame( 1, $filter->get_call_count(), 'The sanitize_text_field filter was not called.' ); + } + + /** + * @ticket 60357 + */ + public function test_sanitize_textarea_field_filter() { + $filter = new MockAction(); + add_filter( 'sanitize_textarea_field', array( $filter, 'filter' ) ); + + $this->assertSame( 'example', sanitize_textarea_field( 'example' ) ); + $this->assertSame( 1, $filter->get_call_count(), 'The sanitize_textarea_field filter was not called.' ); + } }