Changeset 34758 for trunk/tests/phpunit/tests/option/siteOption.php
- Timestamp:
- 10/02/2015 01:55:52 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/option/siteOption.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/siteOption.php
r34757 r34758 35 35 update_site_option( $key, $new_value ); 36 36 $this->assertEquals( $new_value, get_site_option( $key ) ); 37 } 38 39 function test_get_site_option_does_not_exist_returns_filtered_default_with_no_default_provided() { 40 add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); 41 $site_option = get_site_option( 'doesnotexist' ); 42 remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); 43 $this->assertEquals( 'foo', $site_option ); 44 } 45 46 function test_get_site_option_does_not_exist_returns_filtered_default_with_default_provided() { 47 add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); 48 $site_option = get_site_option( 'doesnotexist', 'bar' ); 49 remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); 50 $this->assertEquals( 'foo', $site_option ); 51 } 52 53 function test_get_site_option_does_not_exist_returns_provided_default() { 54 $this->assertEquals( 'bar', get_site_option( 'doesnotexist', 'bar' ) ); 55 } 56 57 function test_get_site_option_exists_does_not_return_provided_default() { 58 $key = rand_str(); 59 $value = rand_str(); 60 add_site_option( $key, $value ); 61 $this->assertEquals( $value, get_site_option( $key, 'foo' ) ); 62 } 63 64 function test_get_site_option_exists_does_not_return_filtered_default() { 65 $key = rand_str(); 66 $value = rand_str(); 67 add_site_option( $key, $value ); 68 add_filter( 'default_site_option_' . $key , array( $this, '__return_foo' ) ); 69 $site_option = get_site_option( $key ); 70 remove_filter( 'default_site_option_' . $key, array( $this, '__return_foo' ) ); 71 $this->assertEquals( $value, $site_option ); 37 72 } 38 73 … … 80 115 } 81 116 82 function test_default_filter() {83 $random = rand_str();84 85 $this->assertFalse( get_site_option( 'doesnotexist' ) );86 87 // Default filter overrides $default arg.88 add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );89 $this->assertEquals( 'foo', get_site_option( 'doesnotexist', 'bar' ) );90 91 // Remove the filter and the $default arg is honored.92 remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );93 $this->assertEquals( 'bar', get_site_option( 'doesnotexist', 'bar' ) );94 95 // Once the option exists, the $default arg and the default filter are ignored.96 add_site_option( 'doesnotexist', $random );97 $this->assertEquals( $random, get_site_option( 'doesnotexist', 'foo' ) );98 add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );99 $this->assertEquals( $random, get_site_option( 'doesnotexist', 'foo' ) );100 remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );101 102 // Cleanup103 $this->assertTrue( delete_site_option( 'doesnotexist' ) );104 $this->assertFalse( get_site_option( 'doesnotexist' ) );105 }106 107 117 function test_serialized_data() { 108 118 $key = rand_str();
Note: See TracChangeset
for help on using the changeset viewer.