- Timestamp:
- 08/28/2024 04:39:30 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/wpSetOptionAutoloadValues.php
r57920 r58945 12 12 * Tests setting options' autoload to 'yes' where for some options this is already the case. 13 13 * 14 * The values 'yes' and 'no' are only supported for backward compatibility. 15 * 14 16 * @ticket 58964 15 17 */ … … 21 23 'test_option2' => 'yes', 22 24 ); 23 add_option( 'test_option1', 'value1', '', 'yes');24 add_option( 'test_option2', 'value2', '', 'no');25 add_option( 'test_option1', 'value1', '', true ); 26 add_option( 'test_option2', 'value2', '', false ); 25 27 $expected = array( 26 28 'test_option1' => false, … … 43 45 * In this case, the 'alloptions' cache should not be cleared, but only its options set to 'no' should be deleted. 44 46 * 47 * The values 'yes' and 'no' are only supported for backward compatibility. 48 * 45 49 * @ticket 58964 46 50 */ … … 52 56 'test_option2' => 'no', 53 57 ); 54 add_option( 'test_option1', 'value1', '', 'yes');55 add_option( 'test_option2', 'value2', '', 'no');58 add_option( 'test_option1', 'value1', '', true ); 59 add_option( 'test_option2', 'value2', '', false ); 56 60 $expected = array( 57 61 'test_option1' => true, … … 71 75 * Tests setting options' autoload to 'yes' where for all of them this is already the case. 72 76 * 77 * The values 'yes' and 'no' are only supported for backward compatibility. 78 * 73 79 * @ticket 58964 74 80 */ … … 80 86 'test_option2' => 'yes', 81 87 ); 82 add_option( 'test_option1', 'value1', '', 'yes');83 add_option( 'test_option2', 'value2', '', 'yes');88 add_option( 'test_option1', 'value1', '', true ); 89 add_option( 'test_option2', 'value2', '', true ); 84 90 $expected = array( 85 91 'test_option1' => false, … … 97 103 98 104 /** 99 * Tests setting options' autoload to either 'yes' or 'no'where for some options this is already the case.105 * Tests setting options' autoload to either true or false where for some options this is already the case. 100 106 * 101 107 * The test also covers one option that is entirely missing. … … 107 113 108 114 $options = array( 109 'test_option1' => 'yes',110 'test_option2' => 'no',111 'test_option3' => 'yes',112 'missing_opt' => 'yes',113 ); 114 add_option( 'test_option1', 'value1', '', 'no');115 add_option( 'test_option2', 'value2', '', 'yes');116 add_option( 'test_option3', 'value3', '', 'yes');115 'test_option1' => true, 116 'test_option2' => false, 117 'test_option3' => true, 118 'missing_opt' => true, 119 ); 120 add_option( 'test_option1', 'value1', '', false ); 121 add_option( 'test_option2', 'value2', '', true ); 122 add_option( 'test_option3', 'value3', '', true ); 117 123 $expected = array( 118 124 'test_option1' => true, … … 133 139 134 140 /** 135 * Tests setting options' autoload to either 'yes' or 'no' while only the 'no'options actually need to be updated.141 * Tests setting options' autoload to either true or false while only the false options actually need to be updated. 136 142 * 137 143 * In this case, the 'alloptions' cache should not be cleared, but only its options set to 'no' should be deleted. … … 143 149 144 150 $options = array( 145 'test_option1' => 'yes',146 'test_option2' => 'no',147 'test_option3' => 'yes',148 ); 149 add_option( 'test_option1', 'value1', '', 'yes');150 add_option( 'test_option2', 'value2', '', 'yes');151 add_option( 'test_option3', 'value3', '', 'yes');151 'test_option1' => true, 152 'test_option2' => false, 153 'test_option3' => true, 154 ); 155 add_option( 'test_option1', 'value1', '', true ); 156 add_option( 'test_option2', 'value2', '', true ); 157 add_option( 'test_option3', 'value3', '', true ); 152 158 $expected = array( 153 159 'test_option1' => false, … … 161 167 $this->assertSameSets( array( 'on', 'off', 'on' ), $wpdb->get_col( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name IN (" . implode( ',', array_fill( 0, count( $options ), '%s' ) ) . ')', ...array_keys( $options ) ) ), 'Option autoload values not updated in database' ); 162 168 foreach ( $options as $option => $autoload ) { 163 if ( 'no'=== $autoload ) {169 if ( false === $autoload ) { 164 170 $this->assertArrayNotHasKey( $option, wp_cache_get( 'alloptions', 'options' ), sprintf( 'Option %s not deleted from alloptions cache', $option ) ); 165 171 } else { … … 178 184 179 185 $options = array( 180 'test_option1' => 'yes',181 'test_option2' => 'yes',182 ); 183 add_option( 'test_option1', 'value1', '', 'no');184 add_option( 'test_option2', 'value2', '', 'no');186 'test_option1' => true, 187 'test_option2' => true, 188 ); 189 add_option( 'test_option1', 'value1', '', false ); 190 add_option( 'test_option2', 'value2', '', false ); 185 191 186 192 // Force UPDATE queries to fail, leading to no autoload values being updated. … … 204 210 205 211 /** 206 * Tests setting options' autoload with boolean values.212 * Tests setting options' autoload with now encouraged boolean values. 207 213 * 208 214 * @ticket 58964
Note: See TracChangeset
for help on using the changeset viewer.