| 169 | * @ticket 38903 |
| 170 | */ |
| 171 | public function test_update_option_array_with_object() { |
| 172 | $array_w_object = array( |
| 173 | 'url' => 'http://src.wordpress-develop.dev/wp-content/uploads/2016/10/cropped-Blurry-Lights.jpg', |
| 174 | 'meta_data' => ( object ) array( |
| 175 | 'attachment_id' => 292, |
| 176 | 'height' => 708, |
| 177 | 'width' => 1260, |
| 178 | ) |
| 179 | ); |
| 180 | |
| 181 | // Add the option, it did not exist before this. |
| 182 | add_option( 'array_w_object', $array_w_object ); |
| 183 | |
| 184 | // Add an action that should NOT occur, if it does occur it indicates a failure. |
| 185 | add_action( 'update_option', array( $this, 'fail_no_redundant_option_update' ) ); |
| 186 | // Update the option using the same array with an object for the value. |
| 187 | update_option( 'array_w_object', $array_w_object ); |
| 188 | |
| 189 | remove_action( 'update_option', array( $this, 'fail_no_redundant_option_update' ) ); |
| 190 | |
| 191 | // If the action added above has NOT occurred, the test passes. |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * `add_action()` callback for test_update_option_array_with_object(). |
| 197 | * This callback should never occur. |
| 198 | */ |
| 199 | public function fail_no_redundant_option_update() { |
| 200 | $this->fail( 'A database call occurred for update_option even though the value was the same array with an object as an element' ); |
| 201 | } |
| 202 | |
| 203 | /** |