Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (3 years ago)
Author:
hellofromTonya
Message:

Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a public visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a private visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a _ prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/file.php

    r51568 r52010  
    66class Tests_File extends WP_UnitTestCase {
    77
    8     function set_up() {
     8    public function set_up() {
    99        parent::set_up();
    1010
     
    1818     * @group themes
    1919     */
    20     function test_get_file_data() {
     20    public function test_get_file_data() {
    2121        $theme_headers = array(
    2222            'Name'        => 'Theme Name',
     
    4949     * @group themes
    5050     */
    51     function test_get_file_data_with_cr_line_endings() {
     51    public function test_get_file_data_with_cr_line_endings() {
    5252        $headers = array(
    5353            'SomeHeader'  => 'Some Header',
     
    7373     * @group themes
    7474     */
    75     function test_get_file_data_with_php_open_tag_prefix() {
     75    public function test_get_file_data_with_php_open_tag_prefix() {
    7676        $headers = array(
    7777            'TemplateName' => 'Template Name',
     
    8888    }
    8989
    90     function is_unique_writable_file( $path, $filename ) {
     90    private function is_unique_writable_file( $path, $filename ) {
    9191        $fullpath = $path . DIRECTORY_SEPARATOR . $filename;
    9292
     
    111111    }
    112112
    113     function test_unique_filename_is_valid() {
     113    public function test_unique_filename_is_valid() {
    114114        // Make sure it produces a valid, writable, unique filename.
    115115        $filename = wp_unique_filename( $this->dir, __FUNCTION__ . '.txt' );
     
    120120    }
    121121
    122     function test_unique_filename_is_unique() {
     122    public function test_unique_filename_is_unique() {
    123123        // Make sure it produces two unique filenames.
    124124        $name = __FUNCTION__;
     
    136136    }
    137137
    138     function test_unique_filename_is_sanitized() {
     138    public function test_unique_filename_is_sanitized() {
    139139        $name     = __FUNCTION__;
    140140        $filename = wp_unique_filename( $this->dir, $name . $this->badchars . '.txt' );
     
    148148    }
    149149
    150     function test_unique_filename_with_slashes() {
     150    public function test_unique_filename_with_slashes() {
    151151        $name = __FUNCTION__;
    152152        // "foo/foo.txt"
     
    161161    }
    162162
    163     function test_unique_filename_multiple_ext() {
     163    public function test_unique_filename_multiple_ext() {
    164164        $name     = __FUNCTION__;
    165165        $filename = wp_unique_filename( $this->dir, $name . '.php.txt' );
     
    173173    }
    174174
    175     function test_unique_filename_no_ext() {
     175    public function test_unique_filename_no_ext() {
    176176        $name     = __FUNCTION__;
    177177        $filename = wp_unique_filename( $this->dir, $name );
     
    187187     * @dataProvider data_wp_tempnam_filenames
    188188     */
    189     function test_wp_tempnam( $case ) {
     189    public function test_wp_tempnam( $case ) {
    190190        $file = wp_tempnam( $case );
    191191        unlink( $file );
     
    193193        $this->assertNotEmpty( basename( basename( $file, '.tmp' ), '.zip' ) );
    194194    }
    195     function data_wp_tempnam_filenames() {
     195    public function data_wp_tempnam_filenames() {
    196196        return array(
    197197            array( '0.zip' ),
     
    207207     * @ticket 47186
    208208     */
    209     function test_file_signature_functions_as_expected() {
     209    public function test_file_signature_functions_as_expected() {
    210210        $file = wp_tempnam();
    211211        file_put_contents( $file, 'WordPress' );
     
    240240     * @ticket 47186
    241241     */
    242     function test_file_signature_expected_failure() {
     242    public function test_file_signature_expected_failure() {
    243243        $file = wp_tempnam();
    244244        file_put_contents( $file, 'WordPress' );
     
    257257    }
    258258
    259     function filter_trust_plus85Tq_key( $keys ) {
     259    public function filter_trust_plus85Tq_key( $keys ) {
    260260        // A static once-off key used to verify verify_file_signature() works as expected.
    261261        $keys[] = '+85TqMhxQVAYVW4BSCVkJQvZH4q7z8I9lePbvngvf7A=';
Note: See TracChangeset for help on using the changeset viewer.