Changeset 867 in tests for trunk/wp-testcase/test_option.php
- Timestamp:
- 07/02/2012 06:35:48 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-testcase/test_option.php
r786 r867 11 11 function tearDown() { 12 12 parent::tearDown(); 13 } 14 15 function __return_foo() { 16 return 'foo'; 13 17 } 14 18 … … 39 43 40 44 function test_default_filter() { 41 $return_foo = function ( $value ) {42 return 'foo';43 };44 45 45 $random = rand_str(); 46 46 … … 48 48 49 49 // Default filter overrides $default arg. 50 add_filter( 'default_option_doesnotexist', $return_foo);50 add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); 51 51 $this->assertEquals( 'foo', get_option( 'doesnotexist', 'bar' ) ); 52 52 53 53 // Remove the filter and the $default arg is honored. 54 remove_filter( 'default_option_doesnotexist', $return_foo);54 remove_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); 55 55 $this->assertEquals( 'bar', get_option( 'doesnotexist', 'bar' ) ); 56 56 … … 58 58 add_option( 'doesnotexist', $random ); 59 59 $this->assertEquals( $random, get_option( 'doesnotexist', 'foo' ) ); 60 add_filter( 'default_option_doesnotexist', $return_foo);60 add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); 61 61 $this->assertEquals( $random, get_option( 'doesnotexist', 'foo' ) ); 62 remove_filter( 'default_option_doesnotexist', $return_foo);62 remove_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); 63 63 64 64 // Cleanup … … 85 85 */ 86 86 class TestSiteOption extends WP_UnitTestCase { 87 function setUp() { 88 parent::setUp(); 89 } 90 91 function tearDown() { 92 parent::tearDown(); 87 function __return_foo() { 88 return 'foo'; 93 89 } 94 90 … … 119 115 120 116 function test_default_filter() { 121 $return_foo = function ( $value ) {122 return 'foo';123 };124 125 117 $random = rand_str(); 126 118 … … 128 120 129 121 // Default filter overrides $default arg. 130 add_filter( 'default_site_option_doesnotexist', $return_foo);122 add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); 131 123 $this->assertEquals( 'foo', get_site_option( 'doesnotexist', 'bar' ) ); 132 124 133 125 // Remove the filter and the $default arg is honored. 134 remove_filter( 'default_site_option_doesnotexist', $return_foo);126 remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); 135 127 $this->assertEquals( 'bar', get_site_option( 'doesnotexist', 'bar' ) ); 136 128 … … 138 130 add_site_option( 'doesnotexist', $random ); 139 131 $this->assertEquals( $random, get_site_option( 'doesnotexist', 'foo' ) ); 140 add_filter( 'default_site_option_doesnotexist', $return_foo);132 add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); 141 133 $this->assertEquals( $random, get_site_option( 'doesnotexist', 'foo' ) ); 142 remove_filter( 'default_site_option_doesnotexist', $return_foo);134 remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); 143 135 144 136 // Cleanup
Note: See TracChangeset
for help on using the changeset viewer.