Make WordPress Core

Ticket #44956: 44956.2.diff

File 44956.2.diff, 1.4 KB (added by bor0, 7 years ago)

Unit tests

  • tests/phpunit/tests/option/networkOption.php

     
    169169
    170170                $this->assertSame( array( 'this_does_not_exist' => true ), $cache );
    171171        }
     172
     173        /**
     174         * @ticket 44956
     175         */
     176        public function test_update_network_option_array_with_object() {
     177                $array_w_object = array(
     178                        'url'       => 'http://src.wordpress-develop.dev/wp-content/uploads/2016/10/cropped-Blurry-Lights.jpg',
     179                        'meta_data' => (object) array(
     180                                'attachment_id' => 292,
     181                                'height'        => 708,
     182                                'width'         => 1260,
     183                        ),
     184                );
     185
     186                $array_w_object_2 = array(
     187                        'url'       => 'http://src.wordpress-develop.dev/wp-content/uploads/2016/10/cropped-Blurry-Lights.jpg',
     188                        'meta_data' => (object) array(
     189                                'attachment_id' => 292,
     190                                'height'        => 708,
     191                                'width'         => 1260,
     192                        ),
     193                );
     194
     195                // Add the option, it did not exist before this.
     196                add_network_option( null, 'array_w_object', $array_w_object );
     197
     198                $num_queries_pre_update = get_num_queries();
     199
     200                // Update the option using the same array with an object for the value.
     201                $this->assertFalse( update_network_option( null, 'array_w_object', $array_w_object_2 ) );
     202
     203                // Check that no new database queries were performed.
     204                $this->assertEquals( $num_queries_pre_update, get_num_queries() );
     205        }
    172206}