From 2660b1cd98dacd65af82a15bb063af5c629d1a62 Mon Sep 17 00:00:00 2001
From: jrfnl <github_nospam@adviesenzo.nl>
Date: Thu, 10 Dec 2015 06:24:51 +0100
Subject: [PATCH] Add unit test for ticket 22233. Props @exz.
---
tests/phpunit/tests/option/updateOption.php | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/tests/phpunit/tests/option/updateOption.php b/tests/phpunit/tests/option/updateOption.php
index 01064ca..a3c1fbd 100644
|
a
|
b
|
class Tests_Option_UpdateOption extends WP_UnitTestCase { |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | | * @group 26394 |
| | 102 | * @ticket 26394 |
| 103 | 103 | */ |
| 104 | 104 | public function test_autoload_should_be_updated_for_existing_option_when_value_is_changed() { |
| 105 | 105 | global $wpdb; |
| … |
… |
class Tests_Option_UpdateOption extends WP_UnitTestCase { |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | | * @group 26394 |
| | 123 | * @ticket 26394 |
| 124 | 124 | */ |
| 125 | 125 | public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_unchanged() { |
| 126 | 126 | global $wpdb; |
| … |
… |
class Tests_Option_UpdateOption extends WP_UnitTestCase { |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | | * @group 26394 |
| | 145 | * @ticket 26394 |
| 146 | 146 | */ |
| 147 | 147 | public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_changed_but_no_value_of_autoload_is_provided() { |
| 148 | 148 | global $wpdb; |
| … |
… |
class Tests_Option_UpdateOption extends WP_UnitTestCase { |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
| | 169 | * @ticket 22233 |
| | 170 | */ |
| | 171 | public function test_update_option_should_save_on_changed_instance_of_nested_object() { |
| | 172 | $key = rand_str(); |
| | 173 | |
| | 174 | $obj1 = new stdClass; |
| | 175 | $obj2 = new stdClass; |
| | 176 | |
| | 177 | $obj1->prop = false; |
| | 178 | $obj2->prop = false; |
| | 179 | |
| | 180 | $array = array( $obj1, $obj2 ); |
| | 181 | $this->assertTrue( add_option( $key, $array ) ); |
| | 182 | |
| | 183 | $array[0]->prop = true; |
| | 184 | $this->assertTrue( update_option( $key, $array ) ); |
| | 185 | $array[1]->prop = true; |
| | 186 | $this->assertTrue( update_option( $key, $array ) ); |
| | 187 | } |
| | 188 | |
| | 189 | /** |
| 169 | 190 | * `add_filter()` callback for test_should_respect_default_option_filter_when_option_does_not_yet_exist_in_database(). |
| 170 | 191 | */ |
| 171 | 192 | public function __return_foo() { |