Index: wp-testcase/test_option.php
===================================================================
--- wp-testcase/test_option.php	(revision 457)
+++ wp-testcase/test_option.php	(working copy)
@@ -46,6 +46,35 @@
 		$this->assertEquals( $value, get_option( $key ) );
 		$this->assertTrue( delete_option( $key ) );
 	}
+
+	function _option_filter() {
+		return current_filter();
+	}
+
+	function test_filter_order() {
+		$option = rand_str();
+		add_option( $option, 'value' );
+
+		// override update_option()
+		add_filter( 'pre_update_option_' . $option, array( $this, '_option_filter' ) );
+		$this->assertTrue( update_option( $option, 'value' ) );
+		$this->assertEquals( 'pre_update_option_' . $option, get_option( $option ) );
+
+		remove_filter( 'pre_update_option_' . $option, array( $this, '_option_filter' ) );
+		update_option( $option, 'value' );
+
+		$this->assertEquals( 'value', get_option( $option ) );
+		// override get_option() at the end
+		add_filter( 'option_' . $option, array( $this, '_option_filter' ) );
+		$this->assertEquals( 'option_' . $option, get_option( $option ) );
+
+		delete_option( $option );
+		// the default value trumps the option_$option filter
+		$this->assertEquals( 'default', get_option( $option, 'default' ) );
+		// but pre_option_$option beats default
+		add_filter( 'pre_option_' . $option, array( $this, '_option_filter' ) );
+		$this->assertEquals( 'pre_option_' . $option, get_option( $option, 'default' ) );
+	}
 }
 
 class TestSiteOption extends WPTestCase {
@@ -114,6 +143,35 @@
 		$this->assertEquals( get_site_option( $option, $default ), $default );
 		$this->assertFalse( get_site_option( $option ) );	
 	}
+
+	function _option_filter() {
+		return current_filter();
+	}
+
+	function test_filter_order() {
+		$option = rand_str();
+		add_site_option( $option, 'value' );
+
+		// override update_site_option()
+		add_filter( 'pre_update_site_option_' . $option, array( $this, '_option_filter' ) );
+		$this->assertTrue( update_site_option( $option, 'value' ) );
+		$this->assertEquals( 'pre_update_site_option_' . $option, get_site_option( $option ) );
+
+		remove_filter( 'pre_update_site_option_' . $option, array( $this, '_option_filter' ) );
+		update_site_option( $option, 'value' );
+
+		$this->assertEquals( 'value', get_site_option( $option ) );
+		// override get_site_option() at the end
+		add_filter( 'site_option_' . $option, array( $this, '_option_filter' ) );
+		$this->assertEquals( 'site_option_' . $option, get_site_option( $option ) );
+
+		delete_site_option( $option );
+		// the default value trumps the site_option_$option filter
+		$this->assertEquals( 'default', get_site_option( $option, 'default' ) );
+		// but pre_site_option_$option beats default
+		add_filter( 'pre_site_option_' . $option, array( $this, '_option_filter' ) );
+		$this->assertEquals( 'pre_site_option_' . $option, get_site_option( $option, 'default' ) );
+	}
 }
 
 class TestTransient extends WPTestCase {
