Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/phpunit/tests/option/wpSetOptionAutoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,23 @@ public function test_wp_set_option_autoload_false() {
$this->assertTrue( wp_set_option_autoload( $option, false ), 'Function did not succeed' );
$this->assertSame( 'no', $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ), 'Option autoload value not updated in database' );
}

public function test_behaviour_of_wp_set_option_autoload() {
global $wpdb;

$option = 'test_option';
$value = 'value';

for ($i=1; $i <= 5; $i++) {
add_option( $option . '_' . $i, $value, '', 'yes' );
}

$this->assertTrue( wp_set_option_autoload( 'test_option_3', false ), 'Function did not succeed' );
$this->assertSame( 'no', $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", 'test_option_3' ) ), 'Option autoload value not updated in database' );

$this->assertSame( 'yes', $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", 'test_option_1' ) ), 'Option autoload value not updated in database' );
$this->assertSame( 'yes', $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", 'test_option_2' ) ), 'Option autoload value not updated in database' );
$this->assertSame( 'yes', $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", 'test_option_4' ) ), 'Option autoload value not updated in database' );
$this->assertSame( 'yes', $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", 'test_option_5' ) ), 'Option autoload value not updated in database' );
}
}