From dc60d05e4d7f4279b423cabea9d4b16217e77697 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 14 Sep 2024 21:29:25 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@59021 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/multisite/network.php | 43 +++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index 5ca1632469..71e80383f2 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -126,6 +126,8 @@ if ( is_multisite() ) : } /** + * Tests that the `WP_Network::$id` property is an integer. + * * @ticket 37050 * * @covers WP_Network::__get @@ -139,10 +141,10 @@ if ( is_multisite() ) : } /** - * 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 * @@ -160,6 +162,43 @@ if ( is_multisite() ) : $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 */