Index: wp-testcase/test_option.php
===================================================================
--- wp-testcase/test_option.php	(revision 717)
+++ wp-testcase/test_option.php	(working copy)
@@ -34,6 +34,35 @@
 		$this->assertFalse( get_option( $key2 ) );
 	}
 
+	function test_default_filter() {
+		$return_foo = function ( $value ) {
+			return 'foo';
+		};
+
+		$random = rand_str();
+
+		$this->assertFalse( get_option( 'doesnotexist' ) );
+
+		// Default filter overrides $default arg.
+		add_filter( 'default_option_doesnotexist', $return_foo );
+		$this->assertEquals( 'foo', get_option( 'doesnotexist', 'bar' ) );
+
+		// Remove the filter and the $default arg is honored.
+		remove_filter( 'default_option_doesnotexist', $return_foo );
+		$this->assertEquals( 'bar', get_option( 'doesnotexist', 'bar' ) );
+
+		// Once the option exists, the $default arg and the default filter are ignored.
+		add_option( 'doesnotexist', $random );
+		$this->assertEquals( $random, get_option( 'doesnotexist', 'foo' ) );
+		add_filter( 'default_option_doesnotexist', $return_foo );
+		$this->assertEquals( $random, get_option( 'doesnotexist', 'foo' ) );
+		remove_filter( 'default_option_doesnotexist', $return_foo );
+
+		// Cleanup
+		$this->assertTrue( delete_option( 'doesnotexist' ) );
+		$this->assertFalse( get_option( 'doesnotexist' ) );
+	}
+
 	function test_serialized_data() {
 		$key = rand_str();
 		$value = array( 'foo' => true, 'bar' => true );
@@ -82,6 +111,35 @@
 		$this->assertFalse( get_site_option( $key2 ) );
 	}
 
+	function test_default_filter() {
+		$return_foo = function ( $value ) {
+			return 'foo';
+		};
+
+		$random = rand_str();
+
+		$this->assertFalse( get_site_option( 'doesnotexist' ) );
+
+		// Default filter overrides $default arg.
+		add_filter( 'default_site_option_doesnotexist', $return_foo );
+		$this->assertEquals( 'foo', get_site_option( 'doesnotexist', 'bar' ) );
+
+		// Remove the filter and the $default arg is honored.
+		remove_filter( 'default_site_option_doesnotexist', $return_foo );
+		$this->assertEquals( 'bar', get_site_option( 'doesnotexist', 'bar' ) );
+
+		// Once the option exists, the $default arg and the default filter are ignored.
+		add_site_option( 'doesnotexist', $random );
+		$this->assertEquals( $random, get_site_option( 'doesnotexist', 'foo' ) );
+		add_filter( 'default_site_option_doesnotexist', $return_foo );
+		$this->assertEquals( $random, get_site_option( 'doesnotexist', 'foo' ) );
+		remove_filter( 'default_site_option_doesnotexist', $return_foo );
+
+		// Cleanup
+		$this->assertTrue( delete_site_option( 'doesnotexist' ) );
+		$this->assertFalse( get_site_option( 'doesnotexist' ) );
+	}
+
 	function test_serialized_data() {
 		$key = rand_str();
 		$value = array( 'foo' => true, 'bar' => true );
