Make WordPress Core

Changeset 63948


Ignore:
Timestamp:
09/26/2026 11:12:47 PM (3 days ago)
Author:
SergeyBiryukov
Message:

Tests: Remove unused properties and helper methods from test classes.

Removes obsolete code from the PHPUnit test suite: six private properties that are never read, and nine helper methods in Tests_HTTPS_Detection that lost their callers when changeset r56664 removed the tests hooking them onto pre_http_request.

No test behavior changes.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/13435

Follow-up to r32648, r43584, r54799, r56664, r61700.

Props Soean.
See #65819.

Location:
trunk/tests/phpunit/tests
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ai-client/wpAiClientHttpClient.php

    r62753 r63948  
    2323
    2424        /**
    25          * Captured URL from the last intercepted HTTP request.
    26          *
    27          * @var string
    28          */
    29         private $captured_url;
    30 
    31         /**
    32          * Captured args from the last intercepted HTTP request.
    33          *
    34          * @var array
    35          */
    36         private $captured_args;
    37 
    38         /**
    3925         * Sets up a fresh client instance before each test.
    4026         */
  • trunk/tests/phpunit/tests/https-detection.php

    r59517 r63948  
    55 */
    66class Tests_HTTPS_Detection extends WP_UnitTestCase {
    7 
    8         private $last_request_url;
    97
    108        public function set_up() {
    … …  
    137135        }
    138136
    139         public function record_request_url( $response, $parsed_args, $url ) {
    140                 $this->last_request_url = $url;
    141                 return $response;
    142         }
    143 
    144         public function mock_success_with_sslverify( $response, $parsed_args ) {
    145                 if ( ! empty( $parsed_args['sslverify'] ) ) {
    146                         return $this->mock_success();
    147                 }
    148                 return $response;
    149         }
    150 
    151         public function mock_error_with_sslverify( $response, $parsed_args ) {
    152                 if ( ! empty( $parsed_args['sslverify'] ) ) {
    153                         return $this->mock_error();
    154                 }
    155                 return $response;
    156         }
    157 
    158         public function mock_success_without_sslverify( $response, $parsed_args ) {
    159                 if ( empty( $parsed_args['sslverify'] ) ) {
    160                         return $this->mock_success();
    161                 }
    162                 return $response;
    163         }
    164 
    165         public function mock_error_without_sslverify( $response, $parsed_args ) {
    166                 if ( empty( $parsed_args['sslverify'] ) ) {
    167                         return $this->mock_error();
    168                 }
    169                 return $response;
    170         }
    171 
    172         public function mock_not_found() {
    173                 return array(
    174                         'body'     => '<!DOCTYPE html><html><head><title>404</title></head><body>Not Found</body></html>',
    175                         'response' => array(
    176                                 'code'    => 404,
    177                                 'message' => 'Not Found',
    178                         ),
    179                 );
    180         }
    181 
    182         public function mock_bad_source() {
    183                 // Looks like a success response, but is not generated by WordPress (e.g. missing RSD link).
    184                 return array(
    185                         'body'     => $this->get_sample_html_string(),
    186                         'response' => array(
    187                                 'code'    => 200,
    188                                 'message' => 'OK',
    189                         ),
    190                 );
    191         }
    192 
    193         private function mock_success() {
    194                 // Success response containing RSD link.
    195                 return array(
    196                         'body'     => $this->get_sample_html_string( get_echo( 'rsd_link' ) ),
    197                         'response' => array(
    198                                 'code'    => 200,
    199                                 'message' => 'OK',
    200                         ),
    201                 );
    202         }
    203 
    204         private function mock_error() {
    205                 return new WP_Error( 'bad_ssl_certificate', 'Bad SSL certificate.' );
    206         }
    207 
    208137        private function get_sample_html_string( $head_tag = '' ) {
    209138                return '<!DOCTYPE html><html><head><title>Page Title</title>' . $head_tag . '</head><body>Page Content.</body></html>';
  • trunk/tests/phpunit/tests/rest-api/rest-revisions-controller.php

    r63896 r63948  
    1818        private int $total_revisions;
    1919
    20         private $revisions;
    21 
    2220        private WP_Post $revision_1;
    2321        private int $revision_id1;
    … …  
    9492                $revisions             = wp_get_post_revisions( self::$post_id );
    9593                $this->total_revisions = count( $revisions );
    96                 $this->revisions       = $revisions;
    9794                $this->revision_1      = array_pop( $revisions );
    9895                $this->revision_id1    = $this->revision_1->ID;
  • trunk/tests/phpunit/tests/rewrite/numericSlugs.php

    r53948 r63948  
    66 */
    77class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase {
    8         private $old_current_user;
    98        private $author_id;
    109
  • trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php

    r63610 r63948  
    6262        private $orig_theme_dir;
    6363
    64         /**
    65          * @var array|null
    66          */
    67         private $queries;
    68 
    6964        public static function set_up_before_class() {
    7065                parent::set_up_before_class();
    … …  
    109104                add_filter( 'template_root', array( $this, 'filter_set_theme_root' ) );
    110105                add_filter( 'theme_file_uri', array( $this, 'filter_theme_file_uri' ) );
    111                 $this->queries = array();
    112106                // Clear caches.
    113107                wp_clean_themes_cache();
Note: See TracChangeset for help on using the changeset viewer.