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
This commit is contained in:
Sergey Biryukov 2024-01-27 20:35:27 +00:00
parent 5c4b4887bf
commit 0c4cc89447

View File

@ -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.' );
}
}