Skip to content

Commit

Permalink
Tests: Add tests to ensure that the WP_Network::$blog_id property i…
Browse files Browse the repository at this point in the history
…s a string.

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

Fixes #62035.

git-svn-id: https://develop.svn.wordpress.org/trunk@59021 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Sep 14, 2024
1 parent be75ea8 commit dc60d05
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions tests/phpunit/tests/multisite/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public function get_main_network_id() {
}

/**
* Tests that the `WP_Network::$id` property is an integer.
*
* @ticket 37050
*
* @covers WP_Network::__get
Expand All @@ -139,10 +141,10 @@ public function test_wp_network_object_id_property_is_int() {
}

/**
* Tests that the `WP_Network::$id` property is stored as int.
* Tests that the `WP_Network::$id` property is stored as an integer.
*
* Uses reflection to access the private property.
* Differs from using the public getter method, which casts to int.
* Differs from using the public getter method, which casts to an integer.
*
* @ticket 62035
*
Expand All @@ -160,6 +162,43 @@ public function test_wp_network_object_id_property_stored_as_int() {
$this->assertSame( (int) $id, $property->getValue( $network ) );
}

/**
* Tests that the `WP_Network::$blog_id` property is a string.
*
* @ticket 62035
*
* @covers WP_Network::__get
*/
public function test_wp_network_object_blog_id_property_is_int() {
$id = self::factory()->network->create();

$network = WP_Network::get_instance( $id );

$this->assertIsString( $network->blog_id );
}

/**
* Tests that the `WP_Network::$blog_id` property is stored as a string.
*
* Uses reflection to access the private property.
* Differs from using the public getter method, which casts to a string.
*
* @ticket 62035
*
* @covers WP_Network::__construct
*/
public function test_wp_network_object_blog_id_property_stored_as_string() {
$id = self::factory()->network->create();

$network = WP_Network::get_instance( $id );

$reflection = new ReflectionObject( $network );
$property = $reflection->getProperty( 'blog_id' );
$property->setAccessible( true );

$this->assertIsString( $property->getValue( $network ) );
}

/**
* @ticket 22917
*/
Expand Down

0 comments on commit dc60d05

Please sign in to comment.