Make WordPress Core


Ignore:
Timestamp:
08/30/2020 01:34:38 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Tests: Move the tests for selected() and checked() to a more appropriate place.

Convert the tests to use data providers.

Props wittich.
Fixes #51166.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/template.php

    r48878 r48907  
    691691        get_template_part( 'template', 'part', array( 'foo' => 'baz' ) );
    692692    }
     693
     694    /**
     695     * @ticket 9862
     696     * @dataProvider data_selected_and_checked_with_equal_values
     697     */
     698    function test_selected_and_checked_with_equal_values( $selected, $current ) {
     699        $this->assertEquals( " selected='selected'", selected( $selected, $current, false ) );
     700        $this->assertEquals( " checked='checked'", checked( $selected, $current, false ) );
     701    }
     702
     703    function data_selected_and_checked_with_equal_values() {
     704        return array(
     705            array( 'foo', 'foo' ),
     706            array( '1', 1 ),
     707            array( '1', true ),
     708            array( 1, 1 ),
     709            array( 1, true ),
     710            array( true, true ),
     711            array( '0', 0 ),
     712            array( 0, 0 ),
     713            array( '', false ),
     714            array( false, false ),
     715        );
     716    }
     717
     718    /**
     719     * @ticket 9862
     720     * @dataProvider data_selected_and_checked_with_non_equal_values
     721     */
     722    function test_selected_and_checked_with_non_equal_values( $selected, $current ) {
     723        $this->assertEquals( '', selected( $selected, $current, false ) );
     724        $this->assertEquals( '', checked( $selected, $current, false ) );
     725    }
     726
     727    function data_selected_and_checked_with_non_equal_values() {
     728        return array(
     729            array( '0', '' ),
     730            array( 0, '' ),
     731            array( 0, false ),
     732        );
     733    }
    693734}
Note: See TracChangeset for help on using the changeset viewer.