Make WordPress Core

Changeset 57368


Ignore:
Timestamp:
01/27/2024 08:35:27 PM (5 weeks ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/sanitizeTextField.php

    r56548 r57368  
    144144        );
    145145    }
     146
     147    /**
     148     * @ticket 60357
     149     */
     150    public function test_sanitize_text_field_filter() {
     151        $filter = new MockAction();
     152        add_filter( 'sanitize_text_field', array( $filter, 'filter' ) );
     153
     154        $this->assertSame( 'example', sanitize_text_field( 'example' ) );
     155        $this->assertSame( 1, $filter->get_call_count(), 'The sanitize_text_field filter was not called.' );
     156    }
     157
     158    /**
     159     * @ticket 60357
     160     */
     161    public function test_sanitize_textarea_field_filter() {
     162        $filter = new MockAction();
     163        add_filter( 'sanitize_textarea_field', array( $filter, 'filter' ) );
     164
     165        $this->assertSame( 'example', sanitize_textarea_field( 'example' ) );
     166        $this->assertSame( 1, $filter->get_call_count(), 'The sanitize_textarea_field filter was not called.' );
     167    }
    146168}
Note: See TracChangeset for help on using the changeset viewer.