Make WordPress Core

Changeset 59021


Ignore:
Timestamp:
09/14/2024 09:29:25 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Add tests to ensure that the WP_Network::$blog_id property is a string.

Follow-up to [34097], [36340], [37657], [37870], [37871], [59020].

Fixes #62035.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/network.php

    r59020 r59021  
    127127
    128128                /**
     129                 * Tests that the `WP_Network::$id` property is an integer.
     130                 *
    129131                 * @ticket 37050
    130132                 *
    … …  
    140142
    141143                /**
    142                  * Tests that the `WP_Network::$id` property is stored as int.
     144                 * Tests that the `WP_Network::$id` property is stored as an integer.
    143145                 *
    144146                 * Uses reflection to access the private property.
    145                  * Differs from using the public getter method, which casts to int.
     147                 * Differs from using the public getter method, which casts to an integer.
    146148                 *
    147149                 * @ticket 62035
    … …  
    159161
    160162                        $this->assertSame( (int) $id, $property->getValue( $network ) );
     163                }
     164
     165                /**
     166                 * Tests that the `WP_Network::$blog_id` property is a string.
     167                 *
     168                 * @ticket 62035
     169                 *
     170                 * @covers WP_Network::__get
     171                 */
     172                public function test_wp_network_object_blog_id_property_is_int() {
     173                        $id = self::factory()->network->create();
     174
     175                        $network = WP_Network::get_instance( $id );
     176
     177                        $this->assertIsString( $network->blog_id );
     178                }
     179
     180                /**
     181                 * Tests that the `WP_Network::$blog_id` property is stored as a string.
     182                 *
     183                 * Uses reflection to access the private property.
     184                 * Differs from using the public getter method, which casts to a string.
     185                 *
     186                 * @ticket 62035
     187                 *
     188                 * @covers WP_Network::__construct
     189                 */
     190                public function test_wp_network_object_blog_id_property_stored_as_string() {
     191                        $id = self::factory()->network->create();
     192
     193                        $network = WP_Network::get_instance( $id );
     194
     195                        $reflection = new ReflectionObject( $network );
     196                        $property   = $reflection->getProperty( 'blog_id' );
     197                        $property->setAccessible( true );
     198
     199                        $this->assertIsString( $property->getValue( $network ) );
    161200                }
    162201
Note: See TracChangeset for help on using the changeset viewer.