- Timestamp:
- 08/28/2024 04:39:30 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/wpSetOptionsAutoload.php
r57920 r58945 12 12 * Tests that setting options' autoload value to 'yes' works as expected. 13 13 * 14 * The values 'yes' and 'no' are only supported for backward compatibility. 15 * 14 16 * @ticket 58964 15 17 */ … … 24 26 $expected = array(); 25 27 foreach ( $options as $option => $value ) { 26 add_option( $option, $value, '', 'no');28 add_option( $option, $value, '', false ); 27 29 $expected[ $option ] = true; 28 30 } … … 41 43 * Tests that setting options' autoload value to 'no' works as expected. 42 44 * 45 * The values 'yes' and 'no' are only supported for backward compatibility. 46 * 43 47 * @ticket 58964 44 48 */ … … 53 57 $expected = array(); 54 58 foreach ( $options as $option => $value ) { 55 add_option( $option, $value, '', 'yes');59 add_option( $option, $value, '', true ); 56 60 $expected[ $option ] = true; 57 61 } … … 81 85 $expected = array(); 82 86 foreach ( $options as $option => $value ) { 83 add_option( $option, $value, '', 'yes');87 add_option( $option, $value, '', true ); 84 88 $expected[ $option ] = false; 85 89 } 86 90 87 91 $num_queries = get_num_queries(); 88 $this->assertSame( $expected, wp_set_options_autoload( array_keys( $options ), 'yes'), 'Function did unexpectedly succeed' );92 $this->assertSame( $expected, wp_set_options_autoload( array_keys( $options ), true ), 'Function did unexpectedly succeed' ); 89 93 $this->assertSame( $num_queries + 1, get_num_queries(), 'Function attempted to update options autoload value in database' ); 90 94 $this->assertSame( array( 'on', '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 ) ) ), 'Options autoload value unexpectedly updated in database' ); … … 109 113 } 110 114 111 $this->assertSame( $expected, wp_set_options_autoload( $options, 'yes'), 'Function did unexpectedly succeed' );115 $this->assertSame( $expected, wp_set_options_autoload( $options, true ), 'Function did unexpectedly succeed' ); 112 116 $this->assertSame( array(), $wpdb->get_col( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name IN (" . implode( ',', array_fill( 0, count( $options ), '%s' ) ) . ')', ...array_keys( $options ) ) ), 'Missing options autoload value was set in database' ); 113 117 } … … 126 130 ); 127 131 128 add_option( 'test_option1', $options['test_option1'], '', 'yes');129 add_option( 'test_option2', $options['test_option2'], '', 'no');132 add_option( 'test_option1', $options['test_option1'], '', true ); 133 add_option( 'test_option2', $options['test_option2'], '', false ); 130 134 $expected = array( 131 135 'test_option1' => false, … … 133 137 ); 134 138 135 $this->assertSame( $expected, wp_set_options_autoload( array_keys( $options ), 'yes'), 'Function produced unexpected result' );139 $this->assertSame( $expected, wp_set_options_autoload( array_keys( $options ), true ), 'Function produced unexpected result' ); 136 140 $this->assertSame( array( 'on', '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' ); 137 141 foreach ( $options as $option => $value ) {
Note: See TracChangeset
for help on using the changeset viewer.